From: Tom Tromey <tom@tromey.com>
To: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
Cc: Tom de Vries <tdevries@suse.de>, Tom Tromey <tom@tromey.com>
Subject: Re: [PATCH v2 2/2] [gdb/tui] Handle unicode chars in prompt
Date: Fri, 09 Jun 2023 09:39:32 -0600 [thread overview]
Message-ID: <87h6rg7ih7.fsf@tromey.com> (raw)
In-Reply-To: <20230609091850.21301-2-tdevries@suse.de> (Tom de Vries via Gdb-patches's message of "Fri, 9 Jun 2023 11:18:50 +0200")
>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:
Tom> +#ifdef HAVE_BTOWC
Tom> + {
Tom> + int mb_len;
Tom> + if (is_mb_char (string, mb_len) && mb_len != 1)
Tom> + {
Tom> + if (mb_len == 0)
Tom> + {
Tom> + /* Multi-byte null char. */
Tom> + break;
Tom> + }
Tom> +
Tom> + waddnstr (w, string, mb_len);
Tom> + string += mb_len;
Tom> + handled = true;
Tom> + }
Tom> + }
Tom> +#endif
I wonder if this would be simplified by using wchar_iterator.
This iterator tries to convert just a single character, and has out
parameters that reflect which input bytes were converted.
The main benefit would be less #ifdef and no need for is_mb_char in
tui-io.c.
You may need to add a method to wchar_iterator to let the caller skip
some bytes (you wouldn't want to create a new one on each iteration, as
it calls iconv_open). That way the escape handling could stay pretty
much the same.
Tom
next prev parent reply other threads:[~2023-06-09 15:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-09 9:18 [PATCH v2 1/2] [gdb/tui] Simplify tui_puts_internal Tom de Vries
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 [this message]
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=87h6rg7ih7.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
/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).