]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Correct use of <ctype.h> functions.
authorBruno Haible <bruno@clisp.org>
Tue, 14 Aug 2001 11:49:07 +0000 (11:49 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 14 Aug 2001 11:49:07 +0000 (11:49 +0000)
intl/ChangeLog
intl/l10nflist.c
intl/loadmsgcat.c
intl/localealias.c
lib/ChangeLog
lib/printf-parse.h
src/ChangeLog
src/po-lex.c
src/xgettext.c

index b70893bbfc648ad58428277a8bcea38653c68d49..cbe031f332aadb85e3b5b28a60e63a47a051d631 100644 (file)
@@ -1,3 +1,12 @@
+2001-07-28  Bruno Haible  <haible@clisp.cons.org>
+
+       * l10nflist.c (_nl_normalize_codeset): Cast isalnum, isalpha, isdigit,
+       tolower argument to 'unsigned char'.
+       * loadmsgcat.c (_nl_load_domain): Cast isspace argument to
+       'unsigned char'.
+       * localealias.c (read_alias_file): Cast isspace argument to
+       'unsigned char'.
+
 2001-07-23  Bruno Haible  <haible@clisp.cons.org>
 
        * gettext.h: Assume <limits.h> exists.
index 557253eb985164c1b022a9c0c2cb447e368c2ecf..291a74231e0a9352f5da79d103b01fc8bc9318cb 100644 (file)
@@ -355,11 +355,11 @@ _nl_normalize_codeset (codeset, name_len)
   size_t cnt;
 
   for (cnt = 0; cnt < name_len; ++cnt)
-    if (isalnum (codeset[cnt]))
+    if (isalnum ((unsigned char) codeset[cnt]))
       {
        ++len;
 
-       if (isalpha (codeset[cnt]))
+       if (isalpha ((unsigned char) codeset[cnt]))
          only_digit = 0;
       }
 
@@ -373,9 +373,9 @@ _nl_normalize_codeset (codeset, name_len)
        wp = retval;
 
       for (cnt = 0; cnt < name_len; ++cnt)
-       if (isalpha (codeset[cnt]))
-         *wp++ = tolower (codeset[cnt]);
-       else if (isdigit (codeset[cnt]))
+       if (isalpha ((unsigned char) codeset[cnt]))
+         *wp++ = tolower ((unsigned char) codeset[cnt]);
+       else if (isdigit ((unsigned char) codeset[cnt]))
          *wp++ = codeset[cnt];
 
       *wp = '\0';
index d589243b20ecd34da8fab8edbb5c4504ab65b1ae..fd73bd98feafcf8c275b2161c03ac9f358a33601 100644 (file)
@@ -507,7 +507,7 @@ _nl_load_domain (domain_file, domainbinding)
          struct parse_args args;
 
          nplurals += 9;
-         while (*nplurals != '\0' && isspace (*nplurals))
+         while (*nplurals != '\0' && isspace ((unsigned char) *nplurals))
            ++nplurals;
 #if defined HAVE_STRTOUL || defined _LIBC
          n = strtoul (nplurals, &endp, 10);
index 76f19a9aae08be1e7346d4f65b28f7ee2558446f..76d99fc2403edbc94885c9a444fc4ff1b3230ef6 100644 (file)
@@ -243,21 +243,21 @@ read_alias_file (fname, fname_len)
 
       cp = buf;
       /* Ignore leading white space.  */
-      while (isspace (cp[0]))
+      while (isspace ((unsigned char) cp[0]))
        ++cp;
 
       /* A leading '#' signals a comment line.  */
       if (cp[0] != '\0' && cp[0] != '#')
        {
          alias = cp++;
-         while (cp[0] != '\0' && !isspace (cp[0]))
+         while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
            ++cp;
          /* Terminate alias name.  */
          if (cp[0] != '\0')
            *cp++ = '\0';
 
          /* Now look for the beginning of the value.  */
-         while (isspace (cp[0]))
+         while (isspace ((unsigned char) cp[0]))
            ++cp;
 
          if (cp[0] != '\0')
@@ -266,7 +266,7 @@ read_alias_file (fname, fname_len)
              size_t value_len;
 
              value = cp++;
-             while (cp[0] != '\0' && !isspace (cp[0]))
+             while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
                ++cp;
              /* Terminate value.  */
              if (cp[0] == '\n')
index 858c6069b2b7cbede2f2a6c29e6ae710658a49ff..7091b26d7ff30d772d81b097e2c2c14d442b9d5c 100644 (file)
@@ -1,3 +1,9 @@
+2001-07-28  Bruno Haible  <haible@clisp.cons.org>
+
+       * printf-parse.h: Don't include <ctype.h>.
+       (ISDIGIT): New macro.
+       (read_int, parse_one_spec): Use ISDIGIT instead of isdigit.
+
 2001-08-05  Bruno Haible  <haible@clisp.cons.org>
 
        * stdbool.h.in (_Bool): Define differently in C++ mode.
index 899323a56ac3d0522f1e791f5e177bf5c3d3da0f..d363eada9e345b607a327eb60f989cfd5e734c37 100644 (file)
@@ -1,5 +1,5 @@
 /* Internal header for parsing printf format strings.
-   Copyright (C) 1995, 1996, 1998, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1995-1996, 1998, 2000, 2001 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -18,7 +18,6 @@
 /* We use some extension so define this here.  */
 #define _GNU_SOURCE    1
 
-#include <ctype.h>
 #include <printf.h>
 #if HAVE_STDDEF_H
 # include <stddef.h>
 # endif
 #endif
 
+/* Locale independent test for a decimal digit.
+   Argument can be  'char' or 'unsigned char'.  (Whereas the argument of
+   isdigit must be an 'unsigned char'.)  */
+#define ISDIGIT(c) ((unsigned int) ((c) - '0') < 10)
+
 struct printf_spec
   {
     /* Information parsed from the format spec.  */
@@ -126,7 +130,7 @@ read_int (pstr)
 {
   unsigned int retval = **pstr - '0';
 
-  while (isdigit (*++(*pstr)))
+  while (ISDIGIT (*++(*pstr)))
     {
       retval *= 10;
       retval += **pstr - '0';
@@ -177,7 +181,7 @@ parse_one_spec (format, posn, spec, max_ref_arg)
   spec->info.pad = ' ';
 
   /* Test for positional argument.  */
-  if (isdigit (*format))
+  if (ISDIGIT (*format))
     {
       const char *begin = format;
 
@@ -240,7 +244,7 @@ parse_one_spec (format, posn, spec, max_ref_arg)
         A negative field width indicates left justification.  */
       const char *begin = ++format;
 
-      if (isdigit (*format))
+      if (ISDIGIT (*format))
        {
          /* The width argument might be found in a positional parameter.  */
          n = read_int (&format);
@@ -261,7 +265,7 @@ parse_one_spec (format, posn, spec, max_ref_arg)
          format = begin;       /* Step back and reread.  */
        }
     }
-  else if (isdigit (*format))
+  else if (ISDIGIT (*format))
     /* Constant width specification.  */
     spec->info.width = read_int (&format);
 
@@ -277,7 +281,7 @@ parse_one_spec (format, posn, spec, max_ref_arg)
          /* The precision is given in an argument.  */
          const char *begin = ++format;
 
-         if (isdigit (*format))
+         if (ISDIGIT (*format))
            {
              n = read_int (&format);
 
@@ -297,7 +301,7 @@ parse_one_spec (format, posn, spec, max_ref_arg)
              format = begin;
            }
        }
-      else if (isdigit (*format))
+      else if (ISDIGIT (*format))
        spec->info.prec = read_int (&format);
       else
        /* "%.?" is treated like "%.0?".  */
index 6f4939506b1ea5ea72736a6a828ff6bddcd1106d..ea5dc0cec3a130f04cb091d7dbac3c079c3f2409 100644 (file)
@@ -1,3 +1,9 @@
+2001-07-28  Bruno Haible  <haible@clisp.cons.org>
+
+       * po-lex.c: Include c-ctype.h instead of <ctype.h>.
+       (control_sequence): Use C locale character classifications.
+       * xgettext.c (main): Cast isspace argument to 'unsigned char'.
+
 2001-07-28  Bruno Haible  <haible@clisp.cons.org>
 
        * po-lex.h (lex_start, lex_end): New declarations.
index 7437c11d8b7037455f34b0ee7b670677f42600c8..6d456b0bd786354ab9d7d8e75cbaa838cf4cba8c 100644 (file)
@@ -23,7 +23,6 @@
 # include "config.h"
 #endif
 
-#include <ctype.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdio.h>
@@ -35,6 +34,7 @@
 # include <iconv.h>
 #endif
 
+#include "c-ctype.h"
 #include "linebreak.h"
 #include "libgettext.h"
 #define _(str) gettext(str)
@@ -883,7 +883,8 @@ control_sequence ()
 
       case 'x':
        lex_getc (mbc);
-       if (mb_iseof (mbc) || mb_len (mbc) != 1 || !isxdigit (mb_ptr (mbc) [0]))
+       if (mb_iseof (mbc) || mb_len (mbc) != 1
+           || !c_isxdigit (mb_ptr (mbc) [0]))
          break;
 
        val = 0;
@@ -891,10 +892,10 @@ control_sequence ()
          {
            char c = mb_ptr (mbc) [0];
            val *= 16;
-           if (isdigit (c))
+           if (c_isdigit (c))
              /* Warning: not portable, can't depend on '0'..'9' ordering */
              val += c - '0';
-           else if (isupper (c))
+           else if (c_isupper (c))
              /* Warning: not portable, can't depend on 'A'..'F' ordering */
              val += c - 'A' + 10;
            else
index 415951be6ebd1e9720419f4203227bef9c54bc9c..3dc80036593e02a8a57ddd01c510583bd4815169 100644 (file)
@@ -228,7 +228,7 @@ main (argc, argv)
            add_all_comments = false;
            comment_tag = optarg;
            /* We ignore leading white space.  */
-           while (isspace (*comment_tag))
+           while (isspace ((unsigned char) *comment_tag))
              ++comment_tag;
          }
        break;