]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
(parse_charmap): Don't skip error checking when being quiet.
authorUlrich Drepper <drepper@redhat.com>
Mon, 2 Mar 1998 13:34:35 +0000 (13:34 +0000)
committerUlrich Drepper <drepper@redhat.com>
Mon, 2 Mar 1998 13:34:35 +0000 (13:34 +0000)
(ctype_class_to): Silently ignore unknown characters and empty ranges.

locale/programs/ld-ctype.c

index ae36dc58afbf249238eaa3aa8f3854df2a94f898..9adb4b486221b4f30308265295766b7eb9813d5f 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
 This file is part of the GNU C Library.
 Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
 
@@ -56,9 +56,6 @@ void *xrealloc (void *__ptr, size_t __n);
 #define SWAPU16(w) \
   ((((w)  >> 8) & 0xff) | (((w) & 0xff) << 8))
 
-#define XSWAPU32(w) \
-  ((((w) & 0xff00ff00) >> 8) | (((w) & 0xff00ff) << 8))
-
 
 /* To be compatible with former implementations we for now restrict
    the number of bits for character classes to 16.  When compatibility
@@ -66,7 +63,7 @@ void *xrealloc (void *__ptr, size_t __n);
 #define char_class_t u_int16_t
 #define CHAR_CLASS_TRANS SWAPU16
 #define char_class32_t u_int32_t
-#define CHAR_CLASS32_TRANS XSWAPU32
+#define CHAR_CLASS32_TRANS SWAPU32
 
 
 /* The real definition of the struct for the LC_CTYPE locale.  */
@@ -312,27 +309,34 @@ character %s'%s' in class `%s' must not be in class `%s'"),
 
   /* ... and now test <SP> as a special case.  */
   space_value = charset_find_value (charset, "SP", 2);
-  if ((wchar_t) space_value == ILLEGAL_CHAR_VALUE && !be_quiet)
-    error (0, 0, _("character <SP> not defined in character map"));
+  if ((wchar_t) space_value == ILLEGAL_CHAR_VALUE)
+    {
+      if (!be_quiet)
+       error (0, 0, _("character <SP> not defined in character map"));
+    }
   else if (((cnt = BITPOS (tok_space),
             (ELEM (ctype, class_collection, , space_value)
              & BIT (tok_space)) == 0)
            || (cnt = BITPOS (tok_blank),
                (ELEM (ctype, class_collection, , space_value)
-                & BIT (tok_blank)) == 0))
-           && !be_quiet)
-    error (0, 0, _("<SP> character not in class `%s'"),
-           valid_table[cnt].name);
+                & BIT (tok_blank)) == 0)))
+    {
+      if (!be_quiet)
+       error (0, 0, _("<SP> character not in class `%s'"),
+              valid_table[cnt].name);
+    }
   else if (((cnt = BITPOS (tok_punct),
             (ELEM (ctype, class_collection, , space_value)
              & BIT (tok_punct)) != 0)
            || (cnt = BITPOS (tok_graph),
                (ELEM (ctype, class_collection, , space_value)
                 & BIT (tok_graph))
-               != 0))
-           && !be_quiet)
-    error (0, 0, _("<SP> character must not be in class `%s'"),
-           valid_table[cnt].name);
+               != 0)))
+    {
+      if (!be_quiet)
+       error (0, 0, _("<SP> character must not be in class `%s'"),
+              valid_table[cnt].name);
+    }
   else
     ELEM (ctype, class_collection, , space_value) |= BIT (tok_print);
 
@@ -653,7 +657,14 @@ ctype_class_to (struct linereader *lr, struct localedef_t *locale,
 
   value = charset_find_value (charset, code->val.str.start, code->val.str.len);
 
-  assert (value >= ctype->last_class_char);
+  if ((wchar_t) ctype->last_class_char == ILLEGAL_CHAR_VALUE
+      || (wchar_t) value == ILLEGAL_CHAR_VALUE)
+    {
+      /* In the LC_CTYPE category it is no error when a character is
+        not found.  This has to be ignored silently.  */
+      ctype->last_class_char = ILLEGAL_CHAR_VALUE;
+      return;
+    }
 
   for (cnt = ctype->last_class_char + 1; cnt <= value; ++cnt)
     *find_idx (ctype, &ctype->class_collection, &ctype->class_collection_max,
@@ -942,11 +953,12 @@ set_class_defaults (struct locale_ctype_t *ctype, struct charset_t *charset)
          tmp[0] = ch;
 
          value = charset_find_value (charset, tmp, 1);
-         if ((wchar_t) value == ILLEGAL_CHAR_VALUE && !be_quiet)
+         if ((wchar_t) value == ILLEGAL_CHAR_VALUE)
            {
-             error (0, 0, _("\
+             if (!be_quiet)
+               error (0, 0, _("\
 character `%s' not defined while needed as default value"),
-                    tmp);
+                      tmp);
              continue;
            }
          else
@@ -1006,50 +1018,68 @@ character `%s' not defined while needed as default value"),
       unsigned int value;
 
       value = charset_find_value (charset, "space", 5);
-      if ((wchar_t) value == ILLEGAL_CHAR_VALUE && !be_quiet)
-       error (0, 0, _("\
+      if ((wchar_t) value == ILLEGAL_CHAR_VALUE)
+       {
+         if (!be_quiet)
+           error (0, 0, _("\
 character `%s' not defined while needed as default value"),
-              "<space>");
+                  "<space>");
+       }
       else
        ELEM (ctype, class_collection, , value) |= BIT (tok_space);
 
       value = charset_find_value (charset, "form-feed", 9);
-      if ((wchar_t) value == ILLEGAL_CHAR_VALUE && !be_quiet)
-       error (0, 0, _("\
+      if ((wchar_t) value == ILLEGAL_CHAR_VALUE)
+       {
+         if (!be_quiet)
+           error (0, 0, _("\
 character `%s' not defined while needed as default value"),
-              "<form-feed>");
+                  "<form-feed>");
+       }
       else
        ELEM (ctype, class_collection, , value) |= BIT (tok_space);
 
       value = charset_find_value (charset, "newline", 7);
-      if ((wchar_t) value == ILLEGAL_CHAR_VALUE && !be_quiet)
-       error (0, 0, _("\
+      if ((wchar_t) value == ILLEGAL_CHAR_VALUE)
+       {
+         if (!be_quiet)
+           error (0, 0, _("\
 character `%s' not defined while needed as default value"),
-              "<newline>");
+                  "<newline>");
+       }
       else
        ELEM (ctype, class_collection, , value) |= BIT (tok_space);
 
       value = charset_find_value (charset, "carriage-return", 15);
-      if ((wchar_t) value == ILLEGAL_CHAR_VALUE && !be_quiet)
-       error (0, 0, _("\
+      if ((wchar_t) value == ILLEGAL_CHAR_VALUE)
+       {
+         if (!be_quiet)
+           error (0, 0, _("\
 character `%s' not defined while needed as default value"),
-              "<carriage-return>");
+                  "<carriage-return>");
+       }
       else
        ELEM (ctype, class_collection, , value) |= BIT (tok_space);
 
       value = charset_find_value (charset, "tab", 3);
-      if ((wchar_t) value == ILLEGAL_CHAR_VALUE && !be_quiet)
-       error (0, 0, _("\
+      if ((wchar_t) value == ILLEGAL_CHAR_VALUE)
+       {
+         if (!be_quiet)
+           error (0, 0, _("\
 character `%s' not defined while needed as default value"),
-              "<tab>");
+                  "<tab>");
+       }
       else
        ELEM (ctype, class_collection, , value) |= BIT (tok_space);
 
       value = charset_find_value (charset, "vertical-tab", 12);
-      if ((wchar_t) value == ILLEGAL_CHAR_VALUE && !be_quiet)
-       error (0, 0, _("\
+      if ((wchar_t) value == ILLEGAL_CHAR_VALUE)
+       {
+         if (!be_quiet)
+           error (0, 0, _("\
 character `%s' not defined while needed as default value"),
-              "<vertical-tab>");
+                  "<vertical-tab>");
+       }
       else
        ELEM (ctype, class_collection, , value) |= BIT (tok_space);
     }
@@ -1072,18 +1102,24 @@ character `%s' not defined while needed as default value"),
       unsigned int value;
 
       value = charset_find_value (charset, "space", 5);
-      if ((wchar_t) value == ILLEGAL_CHAR_VALUE && !be_quiet)
-       error (0, 0, _("\
+      if ((wchar_t) value == ILLEGAL_CHAR_VALUE)
+       {
+         if (!be_quiet)
+           error (0, 0, _("\
 character `%s' not defined while needed as default value"),
-              "<space>");
+                  "<space>");
+       }
       else
        ELEM (ctype, class_collection, , value) |= BIT (tok_blank);
 
       value = charset_find_value (charset, "tab", 3);
-      if ((wchar_t) value == ILLEGAL_CHAR_VALUE && !be_quiet)
-       error (0, 0, _("\
+      if ((wchar_t) value == ILLEGAL_CHAR_VALUE)
+       {
+         if (!be_quiet)
+           error (0, 0, _("\
 character `%s' not defined while needed as default value"),
-              "<tab>");
+                  "<tab>");
+       }
       else
        ELEM (ctype, class_collection, , value) |= BIT (tok_blank);
     }
@@ -1118,10 +1154,13 @@ character `%s' not defined while needed as default value"),
          ctype->class_collection[cnt] |= BIT (tok_print);
 
       space = charset_find_value (charset, "space", 5);
-      if (space == ILLEGAL_CHAR_VALUE && !be_quiet)
-       error (0, 0, _("\
+      if (space == ILLEGAL_CHAR_VALUE)
+       {
+         if (!be_quiet)
+           error (0, 0, _("\
 character `%s' not defined while needed as default value"),
-              "<space>");
+                  "<space>");
+       }
       else
        ELEM (ctype, class_collection, , space) |= BIT (tok_print);
     }
@@ -1144,22 +1183,24 @@ character `%s' not defined while needed as default value"),
          tmp[1] = (char) ch;
 
          value_from = charset_find_value (charset, &tmp[1], 1);
-         if ((wchar_t) value_from == ILLEGAL_CHAR_VALUE && !be_quiet)
+         if ((wchar_t) value_from == ILLEGAL_CHAR_VALUE)
            {
-             error (0, 0, _("\
+             if (!be_quiet)
+               error (0, 0, _("\
 character `%s' not defined while needed as default value"),
-                    tmp);
+                      tmp);
              continue;
            }
 
          /* This conversion is implementation defined.  */
          tmp[1] = (char) (ch + ('A' - 'a'));
          value_to = charset_find_value (charset, &tmp[1], 1);
-         if ((wchar_t) value_to == ILLEGAL_CHAR_VALUE && !be_quiet)
+         if ((wchar_t) value_to == ILLEGAL_CHAR_VALUE)
            {
-             error (0, 0, _("\
+             if (!be_quiet)
+               error (0, 0, _("\
 character `%s' not defined while needed as default value"),
-                    tmp);
+                      tmp);
              continue;
            }