[gdb/tui] Simplify tui_puts_internal

Simplify tui_puts_internal by using continue, as per this [1] coding standard
rule, making the function more readable and easier to understand.

No functional changes.

Tested on x86_64-linux.

[1] https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code

Reviewed-By: Tom Tromey <tom@tromey.com>
This commit is contained in:
Tom de Vries
2023-06-09 16:44:12 +02:00
parent 68bb2e3ee0
commit a3859ffba3

View File

@@ -523,16 +523,13 @@ tui_puts_internal (WINDOW *w, const char *string, int *height)
while ((c = *string++) != 0) while ((c = *string++) != 0)
{ {
if (c == '\n')
saw_nl = true;
if (c == '\1' || c == '\2') if (c == '\1' || c == '\2')
{ {
/* Ignore these, they are readline escape-marking /* Ignore these, they are readline escape-marking
sequences. */ sequences. */
continue;
} }
else
{
if (c == '\033') if (c == '\033')
{ {
size_t bytes_read = apply_ansi_escape (w, string - 1); size_t bytes_read = apply_ansi_escape (w, string - 1);
@@ -542,6 +539,10 @@ tui_puts_internal (WINDOW *w, const char *string, int *height)
continue; continue;
} }
} }
if (c == '\n')
saw_nl = true;
do_tui_putc (w, c); do_tui_putc (w, c);
if (height != nullptr) if (height != nullptr)
@@ -552,7 +553,7 @@ tui_puts_internal (WINDOW *w, const char *string, int *height)
prev_col = col; prev_col = col;
} }
} }
}
if (TUI_CMD_WIN != nullptr && w == TUI_CMD_WIN->handle.get ()) if (TUI_CMD_WIN != nullptr && w == TUI_CMD_WIN->handle.get ())
update_cmdwin_start_line (); update_cmdwin_start_line ();
if (saw_nl) if (saw_nl)