From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 09B8E3858C54; Wed, 24 May 2023 15:40:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 09B8E3858C54 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1684942844; bh=zxz0zpda1IipeoziRHbcYlpTZXZb8Wi3ZLTUptVAWxo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=cW5gzipU6iSY6YXeKP2fpS2Kq5s2uWgLwKaGKp2Hk3zIfM7xCM7vBr9rnvMthaH8c 8h+sbJMgSrNxO5R4UlvT21DuP8AwpEc4t86UqFfNNsQ5XBcCG8He1nXi4BVRWdqAOS SPUbrAm44s1IvXjfFwhcPHqvrkToL26cFaicVuyc= From: "vries at gcc dot gnu.org" To: gdb-prs@sourceware.org Subject: [Bug tui/28800] non-ascii character cannot display correctly in tui-mode's extended-prompt Date: Wed, 24 May 2023 15:40:43 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gdb X-Bugzilla-Component: tui X-Bugzilla-Version: 11.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://sourceware.org/bugzilla/show_bug.cgi?id=3D28800 Tom de Vries changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |vries at gcc dot gnu.org --- Comment #3 from Tom de Vries --- The prompt is printed by tui_puts_internal, which outputs every byte in the string individually. As demonstrator patch, by making tui_puts_internal behave more like tui_put= s, that is, output entire strings: ... diff --git a/gdb/tui/tui-io.c b/gdb/tui/tui-io.c index a1eadcd937d..5cc26f02174 100644 --- a/gdb/tui/tui-io.c +++ b/gdb/tui/tui-io.c @@ -521,8 +521,23 @@ tui_puts_internal (WINDOW *w, const char *string, int *height) int prev_col =3D 0; bool saw_nl =3D false; - while ((c =3D *string++) !=3D 0) + while (true) { + const char *next =3D strpbrk (string, "\n\1\2\033\t"); + + /* Print the plain text prefix. */ + size_t n_chars =3D next =3D=3D nullptr ? strlen (string) : next - st= ring; + if (n_chars > 0) + waddnstr (w, string, n_chars); + + /* We finished. */ + if (next =3D=3D nullptr) + break; + + c =3D *next; + if (c =3D=3D 0) + break; +=20=20=20=20=20=20 if (c =3D=3D '\n') saw_nl =3D true; @@ -530,6 +545,7 @@ tui_puts_internal (WINDOW *w, const char *string, int *height) { /* Ignore these, they are readline escape-marking sequences. */ + ++next; } else { @@ -538,10 +554,12 @@ tui_puts_internal (WINDOW *w, const char *string, int *height) size_t bytes_read =3D apply_ansi_escape (w, string - 1); if (bytes_read > 0) { - string =3D string + bytes_read - 1; + next =3D next + bytes_read - 1; continue; } } + else + next++; do_tui_putc (w, c); if (height !=3D nullptr) @@ -552,6 +570,8 @@ tui_puts_internal (WINDOW *w, const char *string, int *height) prev_col =3D col; } } + + string =3D next; } if (TUI_CMD_WIN !=3D nullptr && w =3D=3D TUI_CMD_WIN->handle.get ()) update_cmdwin_start_line (); ... I can see this that the behaviour is now correct: ... =E2=94=94=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94= =80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80= =E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=98 None No process In: ?? PC: ??=20 /data/vries/gdb : =E2=9D=AF ... I'm not sure yet if this is a proper fix, I suspect that'll involve accumulating using mbrtowc or some such. --=20 You are receiving this mail because: You are on the CC list for the bug.=