texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Patrice Dumas
Date: Sat, 16 Nov 2024 17:28:54 -0500 (EST)

branch: master
commit 1ea8eeed07cb12ee340c7462d48df0c05f677b13
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Nov 16 23:22:33 2024 +0100

    * info/footnotes.c (make_footnotes_node), info/indices.c
    (index_entry_matches, report_index_match), info/infodoc.c
    (replace_in_documentation), info/man.c (xrefs_of_manpage),
    info/search.c (search_forward, search_backward), info/session.c
    (program_name_from_file_name, info_search_1, incremental_search),
    info/util.c (ansi_escape, printed_representation), info/window.c
    (window_make_modeline): cast argument of isdigit, isupper, isalnum,
    islower and iscntrl to unsigned char.  This is recommended as those
    functions expect unsigned argument, and it avoids warnings with
    -Wchar-subscripts when the functions are implemented with an array.
---
 ChangeLog        | 13 +++++++++++++
 info/footnotes.c |  2 +-
 info/indices.c   |  4 ++--
 info/infodoc.c   |  9 +++++----
 info/man.c       |  8 ++++----
 info/search.c    |  8 ++++----
 info/session.c   |  7 ++++---
 info/util.c      |  8 +++++---
 info/window.c    |  4 ++--
 9 files changed, 40 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 830a4c6534..7e73dbb895 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2024-11-16  Patrice Dumas  <pertusus@free.fr>
+
+       * info/footnotes.c (make_footnotes_node), info/indices.c
+       (index_entry_matches, report_index_match), info/infodoc.c
+       (replace_in_documentation), info/man.c (xrefs_of_manpage),
+       info/search.c (search_forward, search_backward), info/session.c
+       (program_name_from_file_name, info_search_1, incremental_search),
+       info/util.c (ansi_escape, printed_representation), info/window.c
+       (window_make_modeline): cast argument of isdigit, isupper, isalnum,
+       islower and iscntrl to unsigned char.  This is recommended as those
+       functions expect unsigned argument, and it avoids warnings with
+       -Wchar-subscripts when the functions are implemented with an array.
+
 2024-11-16  Patrice Dumas  <pertusus@free.fr>
 
        * info/indices.c, info/infodoc.c, info/infomap.c, info/man.c,
diff --git a/info/footnotes.c b/info/footnotes.c
index e33d72da2e..f333614661 100644
--- a/info/footnotes.c
+++ b/info/footnotes.c
@@ -93,7 +93,7 @@ make_footnotes_node (NODE *node)
                 && (strcmp (refs[i]->nodename, refname) == 0 ||
                  (strncmp (refs[i]->nodename, refname, reflen - 1) == 0 &&
                   refs[i]->nodename[reflen - 1] == '-' &&
-                  isdigit (refs[i]->nodename[reflen]))))
+                  isdigit ((unsigned char) refs[i]->nodename[reflen]))))
               {
                 footnotes_node = info_get_node (node->fullpath, refname);
                 if (footnotes_node)
diff --git a/info/indices.c b/info/indices.c
index c4edd88627..17dc7fbac6 100644
--- a/info/indices.c
+++ b/info/indices.c
@@ -294,7 +294,7 @@ index_entry_matches (REFERENCE *ent, const char *str, 
size_t len)
         {
           if (p[0] == '>' && p[1] == 0)
             return 1;
-          else if (!isdigit (*p))
+          else if (!isdigit ((unsigned char) *p))
             return 0;
         }
     }
@@ -430,7 +430,7 @@ report_index_match (int i, int match_offset)
 
       ls = strlen (index_search);
       start = match_offset - ls;
-      upper = isupper (match[start]) ? 1 : 0;
+      upper = isupper ((unsigned char) match[start]) ? 1 : 0;
 
       for (k = 0; k < ls; k++)
         if (upper)
diff --git a/info/infodoc.c b/info/infodoc.c
index 5c0b7c3c58..0bc53064e5 100644
--- a/info/infodoc.c
+++ b/info/infodoc.c
@@ -661,14 +661,15 @@ replace_in_documentation (const char *string, int 
help_is_only_window_p)
             {
               if (string[++j] == '-')
                 j++;
-              if (isdigit(string[j]))
+              if (isdigit ((unsigned char) string[j]))
                 {
-                  while (isdigit(string[j]))
+                  while (isdigit ((unsigned char) string[j]))
                     j++;
-                  if (string[j] == '.' && isdigit(string[j + 1]))
+                  if (string[j] == '.'
+                      && isdigit ((unsigned char) string[j + 1]))
                     {
                       j += 1;
-                      while (isdigit(string[j]))
+                      while (isdigit ((unsigned char) string[j]))
                         j++;
                     }
                   fmt = xmalloc (j - i + 2);
diff --git a/info/man.c b/info/man.c
index cdf40f43d2..c6e4c90c70 100644
--- a/info/man.c
+++ b/info/man.c
@@ -592,7 +592,7 @@ xrefs_of_manpage (NODE *node)
          page name. */
       for (; name > 0; name--)
         if (whitespace_or_newline (s.buffer[name])
-            || (!isalnum (s.buffer[name])
+            || (!isalnum ((unsigned char) s.buffer[name])
                 && s.buffer[name] != '_'
                 && s.buffer[name] != '.'
                 && s.buffer[name] != '-'
@@ -628,7 +628,7 @@ xrefs_of_manpage (NODE *node)
 
       /* Set name_end to the end of the name, but before any SGR sequence. */
       for (name_end = name; name_end < position; name_end++)
-        if (!isalnum (s.buffer[name_end])
+        if (!isalnum ((unsigned char) s.buffer[name_end])
             && s.buffer[name_end] != '_'
             && s.buffer[name_end] != '.'
             && s.buffer[name_end] != '-')
@@ -639,14 +639,14 @@ xrefs_of_manpage (NODE *node)
 
       /* Look for one or two characters within the brackets, the
          first of which must be a non-zero digit and the second a letter. */
-      if (!isdigit (s.buffer[section + 1])
+      if (!isdigit ((unsigned char) s.buffer[section + 1])
           || s.buffer[section + 1] == '0')
         ;
       else if (!s.buffer[section + 2])
         ; /* end of buffer */
       else if (s.buffer[section + 2] == ')')
         section_end = section + 3;
-      else if (!isalpha(s.buffer[section + 2]))
+      else if (!isalpha((unsigned char) s.buffer[section + 2]))
         ;
       else if (s.buffer[section + 3] == ')')
         section_end = section + 4;
diff --git a/info/search.c b/info/search.c
index 51fb4cb4fe..3b4b33f6d2 100644
--- a/info/search.c
+++ b/info/search.c
@@ -246,9 +246,9 @@ search_forward (const char *string, const SEARCH_BINDING 
*binding, long *poff)
 
       for (i = 0; i < len; i++)
         {
-          if (islower (alternate[i]))
+          if (islower ((unsigned char) alternate[i]))
             alternate[i] = toupper (alternate[i]);
-          else if (isupper (alternate[i]))
+          else if (isupper ((unsigned char) alternate[i]))
             alternate[i] = tolower (alternate[i]);
         }
     }
@@ -316,9 +316,9 @@ search_backward (const char *input_string, const 
SEARCH_BINDING *binding,
 
       for (i = 0; i < len; i++)
         {
-          if (islower (alternate[i]))
+          if (islower ((unsigned char) alternate[i]))
             alternate[i] = toupper (alternate[i]);
-          else if (isupper (alternate[i]))
+          else if (isupper ((unsigned char) alternate[i]))
             alternate[i] = tolower (alternate[i]);
         }
     }
diff --git a/info/session.c b/info/session.c
index 5f18198aa0..da3ab087eb 100644
--- a/info/session.c
+++ b/info/session.c
@@ -3552,7 +3552,8 @@ program_name_from_file_name (char *file_name)
 #ifdef __MSDOS__
             || FILENAME_CMPN (program_name + i, ".i", 2) == 0
 #endif
-            || isdigit (program_name[i + 1]))) /* a man page foo.1 */
+                /* a man page foo.1 */
+            || isdigit ((unsigned char) program_name[i + 1])))
       {
         program_name[i] = 0;
         break;
@@ -4334,7 +4335,7 @@ info_search_1 (WINDOW *window, int count, int 
case_sensitive)
      case-sensitive.  */
   if (case_sensitive == 0)
     for (p = search_string; *p; p++)
-      if (isupper (*p))
+      if (isupper ((unsigned char) *p))
         {
           case_sensitive = 1;
           break;
@@ -5270,7 +5271,7 @@ incremental_search (WINDOW *window, int count)
          upper-case letters. */
       case_sensitive = 0;
       for (p = isearch_string; *p; p++)
-        if (isupper (*p))
+        if (isupper ((unsigned char) *p))
           {
             case_sensitive = 1;
             break;
diff --git a/info/util.c b/info/util.c
index 3d616b3a80..c753804421 100644
--- a/info/util.c
+++ b/info/util.c
@@ -140,7 +140,8 @@ ansi_escape (mbi_iterator_t iter, int *plen)
         {
           ITER_SETBYTES (iter, 1);
           mbi_advance (iter);
-          if (isdigit (*mbi_cur_ptr (iter)) && mbi_avail (iter))
+          if (isdigit ((unsigned char) *mbi_cur_ptr (iter))
+              && mbi_avail (iter))
             {
               ITER_SETBYTES (iter, 1);
               mbi_advance (iter);
@@ -149,7 +150,8 @@ ansi_escape (mbi_iterator_t iter, int *plen)
                   *plen = 4;
                   return 1;
                 }
-              else if (isdigit (*mbi_cur_ptr (iter)) && mbi_avail (iter))
+              else if (isdigit ((unsigned char) *mbi_cur_ptr (iter))
+                       && mbi_avail (iter))
                 {
                   ITER_SETBYTES (iter, 1);
                   mbi_advance (iter);
@@ -249,7 +251,7 @@ printed_representation (mbi_iterator_t *iter, int *delim, 
size_t pl_chars,
     }
 
   /* Show CTRL-x as "^X".  */
-  if (iscntrl (*cur_ptr) && *(unsigned char *)cur_ptr < 127)
+  if (iscntrl ((unsigned char) *cur_ptr) && *(unsigned char *)cur_ptr < 127)
     {
       *pchars = 2;
       *pbytes = 2;
diff --git a/info/window.c b/info/window.c
index 0e192e23ed..51af7ab067 100644
--- a/info/window.c
+++ b/info/window.c
@@ -922,11 +922,11 @@ window_make_modeline (WINDOW *window)
 
     /* But include any numbered version suffix in a file name
        like "automake-1.16.info". */
-    while (name[dot] == '.' && isdigit (name[dot+1]))
+    while (name[dot] == '.' && isdigit ((unsigned char) name[dot+1]))
       {
         do
           dot++;
-        while (isdigit (name[dot]));
+        while (isdigit ((unsigned char) name[dot]));
       }
 
     if (name && strcmp ("", name))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]