]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/build] Fix x86_64-w64-mingw32 build by avoiding SCNx8
authorTom de Vries <tdevries@suse.de>
Fri, 7 Feb 2025 14:57:24 +0000 (15:57 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 7 Feb 2025 14:57:24 +0000 (15:57 +0100)
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>
gdb/cli/cli-decode.c

index c5eab2f44379639975d48b08c60c02e1f186f69c..e5de7024ebc8e14469b505e808d1351b51e97ac2 100644 (file)
@@ -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);
 }