[binutils-gdb] [gdb/build] Add warning_prefix_default/error_prefix_default constants
Tom de Vries via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a3a56294a7c5e5898309c04cc3b1e490cca76ef7 commit a3a56294a7c5e5898309c04cc3b1e490cca76ef7 Author: Tom de Vries <[email protected]> Date: Fri Aug 21 17:23:39 2026 +0200 [gdb/build] Add warning_prefix_default/error_prefix_default constants Post-commit review of commit f33422af6d8 ("[gdb/build] Fix cli/cli-style.c build error with C++20") pointed out the need for a comment for a reinterpret_cast [1]. While reviewing the comment in gdb/top.c for bd_heavy_horizontal et al, I realized I could use the same style: ... static const char bd_heavy_horizontal[] = u8"\u2501"; ... and get rid of the reinterpret_cast. Add warning_prefix_default and error_prefix_default constants, and copy the comment from gdb/top.c. Tested on x86_64-linux. Approved-By: Tom Tromey <[email protected]> [1] https://sourceware.org/pipermail/gdb-patches/2026-August/229421.html Diff: --- gdb/cli/cli-style.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/gdb/cli/cli-style.c b/gdb/cli/cli-style.c index 5c26519c6d7..cc22b861ca0 100644 --- a/gdb/cli/cli-style.c +++ b/gdb/cli/cli-style.c @@ -449,13 +449,26 @@ no_emojis () emoji_styling = AUTO_BOOLEAN_FALSE; } -/* Emoji warning prefix: +/* Emoji warning prefix default: - u26A0: Warning Sign: ⚠ - uFE0F: Variation Selector-16 (VS16) The VS16 forces "Emoji" presentation. It is needed because the default - presentation for Warning Sign is "Text". Together, we get: ⚠️ . */ -static std::string warning_prefix - = reinterpret_cast<const char *> (u8"\u26A0\uFE0F "); + presentation for Warning Sign is "Text". Together, we get: ⚠️ . + + Emoji error prefix default: + - u274C: Cross Mark: ❌ + No VS16 is needed because the default presentation for Cross Mark is + "Emoji". + + UTF-8 string literals have type: + - const char[N] (until C++20), or + - const char8_t[N] (since C++20). + Assign them to a variable to stabilize the type. */ +static const char warning_prefix_default[] = u8"\u26A0\uFE0F "; +static const char error_prefix_default[] = u8"\u274C "; + +/* Emoji warning prefix. */ +static std::string warning_prefix = warning_prefix_default; /* Implement 'show style warning-prefix'. */ @@ -476,12 +489,8 @@ print_warning_prefix (ui_file *file) gdb_puts (warning_prefix.c_str (), file); } -/* Emoji error prefix: - - u274C: Cross Mark: ❌ - No VS16 is needed because the default presentation for Cross Mark is - "Emoji". */ -static std::string error_prefix - = reinterpret_cast<const char *> (u8"\u274C "); +/* Emoji error prefix. */ +static std::string error_prefix = error_prefix_default; /* Implement 'show style error-prefix'. */