aboutsummaryrefslogtreecommitdiff
path: root/gdb/cli
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2025-02-07 15:57:24 +0100
committerTom de Vries <tdevries@suse.de>2025-02-07 15:57:24 +0100
commit4fed821ed67c3fb4c57aa43926cf5b1a02a25ccd (patch)
tree5c624c66f4f03bfd7bc361e4431aaa7d9953b85f /gdb/cli
parenta5626289a6292b851f949d64df5927234737bd71 (diff)
downloadbinutils-4fed821ed67c3fb4c57aa43926cf5b1a02a25ccd.zip
binutils-4fed821ed67c3fb4c57aa43926cf5b1a02a25ccd.tar.gz
binutils-4fed821ed67c3fb4c57aa43926cf5b1a02a25ccd.tar.bz2
[gdb/build] Fix x86_64-w64-mingw32 build by avoiding SCNx8
With an x86_64-w64-mingw32 targeted cross-build on x86_64-linux, I run into: ... gdb/cli/cli-decode.c: \ In function 'ui_file_style::color parse_cli_var_color(const char**)': gdb/cli/cli-decode.c:2917:41: error: expected ')' before 'SCNx8' int parsed_args = sscanf (*args, "#%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%n", ... Apparantly, the definition of SCNx8 is missing in inttypes.h. Rewrite the sscanf call to use SCNx32, which is available. Tested by: - completing aforementioned cross-build, and - build & test on x86_64-linux. Suggested-By: Tom Tromey <tom@tromey.com> Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdb/cli')
-rw-r--r--gdb/cli/cli-decode.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c
index c5eab2f..e5de702 100644
--- a/gdb/cli/cli-decode.c
+++ b/gdb/cli/cli-decode.c
@@ -2912,14 +2912,20 @@ parse_cli_var_color (const char **args)
if (len != 7)
error_no_arg (_("invalid RGB hex triplet format"));
+ uint32_t rgb;
uint8_t r, g, b;
int scanned_chars = 0;
- int parsed_args = sscanf (*args, "#%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%n",
- &r, &g, &b, &scanned_chars);
+ int parsed_args = sscanf (*args, "#%6" SCNx32 "%n",
+ &rgb, &scanned_chars);
- if (parsed_args != 3 || scanned_chars != 7)
+ if (parsed_args != 1 || scanned_chars != 7)
error_no_arg (_("invalid RGB hex triplet format"));
+ gdb_assert ((rgb >> 24) == 0);
+ r = (rgb >> 16) & 0xff;
+ g = (rgb >> 8) & 0xff;
+ b = rgb & 0xff;
+
*args += len;
return ui_file_style::color (r, g, b);
}