From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH v2 1/2] [gdb/tui] Simplify tui_puts_internal
Date: Fri, 9 Jun 2023 11:18:49 +0200 [thread overview]
Message-ID: <20230609091850.21301-1-tdevries@suse.de> (raw)
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
---
gdb/tui/tui-io.c | 39 ++++++++++++++++++++-------------------
1 file changed, 20 insertions(+), 19 deletions(-)
diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c
index 908cb834e4c..8cb68d12408 100644
--- a/gdb/tui/tui-io.c
+++ b/gdb/tui/tui-io.c
@@ -523,36 +523,37 @@ tui_puts_internal (WINDOW *w, const char *string, int *height)
while ((c = *string++) != 0)
{
- if (c == '\n')
- saw_nl = true;
-
if (c == '\1' || c == '\2')
{
/* Ignore these, they are readline escape-marking
sequences. */
+ continue;
}
- else
+
+ if (c == '\033')
{
- if (c == '\033')
+ size_t bytes_read = apply_ansi_escape (w, string - 1);
+ if (bytes_read > 0)
{
- size_t bytes_read = apply_ansi_escape (w, string - 1);
- if (bytes_read > 0)
- {
- string = string + bytes_read - 1;
- continue;
- }
+ string = string + bytes_read - 1;
+ continue;
}
- do_tui_putc (w, c);
+ }
- if (height != nullptr)
- {
- int col = getcurx (w);
- if (col <= prev_col)
- ++*height;
- prev_col = col;
- }
+ if (c == '\n')
+ saw_nl = true;
+
+ do_tui_putc (w, c);
+
+ if (height != nullptr)
+ {
+ int col = getcurx (w);
+ if (col <= prev_col)
+ ++*height;
+ prev_col = col;
}
}
+
if (TUI_CMD_WIN != nullptr && w == TUI_CMD_WIN->handle.get ())
update_cmdwin_start_line ();
if (saw_nl)
base-commit: 30711c89cc7dcd2bd4ea772b2f5dc639c5b1cfcc
--
2.35.3
next reply other threads:[~2023-06-09 9:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 9:18 Tom de Vries [this message]
2023-06-09 9:18 ` [PATCH v2 2/2] [gdb/tui] Handle unicode chars in prompt Tom de Vries
2023-06-09 14:40 ` Tom Tromey
2023-06-09 15:39 ` Tom Tromey
2023-06-12 15:19 ` Tom de Vries
2023-06-12 18:44 ` Tom Tromey
2023-06-15 9:42 ` Tom de Vries
2023-06-09 14:35 ` [PATCH v2 1/2] [gdb/tui] Simplify tui_puts_internal Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230609091850.21301-1-tdevries@suse.de \
--to=tdevries@suse.de \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).