]> Savannah Git Hosting - gnulib.git/commitdiff
uniname/uniname: Fix -Wshorten-64-to-32 warnings.
authorBruno Haible <bruno@clisp.org>
Sat, 5 Sep 2020 13:44:29 +0000 (15:44 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 5 Sep 2020 13:44:58 +0000 (15:44 +0200)
* lib/uniname/uniname.c (unicode_name_word_lookup): Change type of last
argument to size_t.
(unicode_name_character): Change type of len, n1, n2, n3, words_length,
n to size_t.

ChangeLog
lib/uniname/uniname.c

index 0d50b68411057828867dc9efcffc37b2867c0ce9..205d98ab133d196da0748dbe1564a2f9906f90e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-09-05  Bruno Haible  <bruno@clisp.org>
+
+       uniname/uniname: Fix -Wshorten-64-to-32 warnings.
+       * lib/uniname/uniname.c (unicode_name_word_lookup): Change type of last
+       argument to size_t.
+       (unicode_name_character): Change type of len, n1, n2, n3, words_length,
+       n to size_t.
+
 2020-09-05  Bruno Haible  <bruno@clisp.org>
 
        unistr/u{8,16,32}-uctomb: Avoid possible trouble with huge strings.
index 7cf1e2e1320b4fc62f2517b7a8aa7fa2ce2a86ec..db8399d6bd7dd4bf0c4523f1f77b1eb6ee31f6ec 100644 (file)
@@ -90,7 +90,7 @@ unicode_name_word (unsigned int index, unsigned int *lengthp)
 
 /* Looks up the index of a word.  */
 static int
-unicode_name_word_lookup (const char *word, unsigned int length)
+unicode_name_word_lookup (const char *word, size_t length)
 {
   if (length > 0 && length < SIZEOF (unicode_name_by_length) - 1)
     {
@@ -359,7 +359,7 @@ unicode_character_name (ucs4_t c, char *buf)
 ucs4_t
 unicode_name_character (const char *name)
 {
-  unsigned int len = strlen (name);
+  size_t len = strlen (name);
   if (len > 1 && len <= UNICODE_CHARNAME_MAX_LENGTH)
     {
       /* Test for "word1 word2 ..." syntax.  */
@@ -469,9 +469,9 @@ unicode_name_character (const char *name)
                         p4++;
                       if (p4 == ptr)
                         {
-                          unsigned int n1 = p2 - p1;
-                          unsigned int n2 = p3 - p2;
-                          unsigned int n3 = p4 - p3;
+                          size_t n1 = p2 - p1;
+                          size_t n2 = p3 - p2;
+                          size_t n3 = p4 - p3;
 
                           if (n1 <= 2 && (n2 >= 1 && n2 <= 3) && n3 <= 2)
                             {
@@ -578,12 +578,15 @@ unicode_name_character (const char *name)
             filled_words:
               {
                 /* Multiply by 2, to simplify later comparisons.  */
-                unsigned int words_length = wordptr - words;
+                size_t words_length = wordptr - words;
                 {
-                  int i = words_length - 1;
+                  size_t i = words_length - 1;
                   words[i] = 2 * words[i];
-                  for (; --i >= 0; )
-                    words[i] = 2 * words[i] + 1;
+                  for (; i > 0; )
+                    {
+                      --i;
+                      words[i] = 2 * words[i] + 1;
+                    }
                 }
                 /* Binary search in unicode_name_to_index.  */
                 {
@@ -594,7 +597,7 @@ unicode_name_character (const char *name)
                       unsigned int i = (i1 + i2) >> 1;
                       const uint16_t *w = words;
                       const uint16_t *p = &unicode_names[unicode_name_to_index[i].name];
-                      unsigned int n = words_length;
+                      size_t n = words_length;
                       for (;;)
                         {
                           if (*p < *w)