In GNU gettext, with gcc 13, I see this warning:
gettext-tools/gnulib-lib/uniname/uniname.c:295:42: warning: format '%d' expects
argument of type 'int', but argument 3 has type 'ucs4_t' {aka 'unsigned int'}
[-Wformat=]
This patch fixes it. The other patch fixes some comments.
2023-06-04 Bruno Haible <[email protected]>
uniname/uniname: Fix -Wformat-signedness warning.
* lib/uniname/uniname.c (unicode_character_name): Use %u instead of %d
in format string.
2023-06-04 Bruno Haible <[email protected]>
uniname/uniname: Improve comments.
* lib/uniname/uniname.c (unicode_character_name): Fix comments.
>From 39167e40eca3e65351ace6db11c8f10adbdf1802 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Sun, 4 Jun 2023 10:45:00 +0200
Subject: [PATCH 1/2] uniname/uniname: Improve comments.
* lib/uniname/uniname.c (unicode_character_name): Fix comments.
---
ChangeLog | 5 +++++
lib/uniname/uniname.c | 9 +++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5c1d3a1edf..959b18d396 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-06-04 Bruno Haible <[email protected]>
+
+ uniname/uniname: Improve comments.
+ * lib/uniname/uniname.c (unicode_character_name): Fix comments.
+
2023-06-03 Bruno Haible <[email protected]>
classpath, csharpexec: Avoid "candidate for attribute 'malloc'" warning.
diff --git a/lib/uniname/uniname.c b/lib/uniname/uniname.c
index 99b303a3d0..f6ef6956e8 100644
--- a/lib/uniname/uniname.c
+++ b/lib/uniname/uniname.c
@@ -245,7 +245,7 @@ unicode_character_name (ucs4_t c, char *buf)
unsigned int index3;
const char *q;
- /* buf needs to have at least 16 + 7 bytes here. */
+ /* buf needs to have at least 16 + 7 + 1 bytes here. */
memcpy (buf, "HANGUL SYLLABLE ", 16);
ptr = buf + 16;
@@ -274,7 +274,7 @@ unicode_character_name (ucs4_t c, char *buf)
char *ptr;
int i;
- /* buf needs to have at least 28 + 5 bytes here. */
+ /* buf needs to have at least 28 + 5 + 1 bytes here. */
memcpy (buf, "CJK COMPATIBILITY IDEOGRAPH-", 28);
ptr = buf + 28;
@@ -291,7 +291,7 @@ unicode_character_name (ucs4_t c, char *buf)
/* Special case for variation selectors. Keeps the tables
small. */
- /* buf needs to have at least 19 + 3 bytes here. */
+ /* buf needs to have at least 19 + 3 + 1 bytes here. */
sprintf (buf, "VARIATION SELECTOR-%d",
c <= 0xFE0F ? c - 0xFE00 + 1 : c - 0xE0100 + 17);
return buf;
@@ -339,7 +339,8 @@ unicode_character_name (ucs4_t c, char *buf)
if (words != NULL)
{
/* Found it in unicode_index_to_name. Now concatenate the words. */
- /* buf needs to have at least UNICODE_CHARNAME_MAX_LENGTH bytes. */
+ /* buf needs to have at least UNICODE_CHARNAME_MAX_LENGTH + 1
+ bytes. */
char *ptr = buf;
for (;;)
{
--
2.34.1
>From 9e13c0d5a8fc925bfb7ad977f69d04f446179143 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Sun, 4 Jun 2023 10:50:29 +0200
Subject: [PATCH 2/2] uniname/uniname: Fix -Wformat-signedness warning.
* lib/uniname/uniname.c (unicode_character_name): Use %u instead of %d
in format string.
---
ChangeLog | 6 ++++++
lib/uniname/uniname.c | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index 959b18d396..72afbccd72 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-06-04 Bruno Haible <[email protected]>
+
+ uniname/uniname: Fix -Wformat-signedness warning.
+ * lib/uniname/uniname.c (unicode_character_name): Use %u instead of %d
+ in format string.
+
2023-06-04 Bruno Haible <[email protected]>
uniname/uniname: Improve comments.
diff --git a/lib/uniname/uniname.c b/lib/uniname/uniname.c
index f6ef6956e8..48bae59bec 100644
--- a/lib/uniname/uniname.c
+++ b/lib/uniname/uniname.c
@@ -292,7 +292,7 @@ unicode_character_name (ucs4_t c, char *buf)
small. */
/* buf needs to have at least 19 + 3 + 1 bytes here. */
- sprintf (buf, "VARIATION SELECTOR-%d",
+ sprintf (buf, "VARIATION SELECTOR-%u",
c <= 0xFE0F ? c - 0xFE00 + 1 : c - 0xE0100 + 17);
return buf;
}
--
2.34.1