about summary refs log tree commit diff
path: root/locale
diff options
context:
space:
mode:
Diffstat (limited to 'locale')
-rw-r--r--locale/C-ctype.c19
-rw-r--r--locale/programs/charmap.c10
-rw-r--r--locale/programs/config.h4
-rw-r--r--locale/programs/ld-ctype.c40
4 files changed, 52 insertions, 21 deletions
diff --git a/locale/C-ctype.c b/locale/C-ctype.c
index f9eee1ca94..6e036f6266 100644
--- a/locale/C-ctype.c
+++ b/locale/C-ctype.c
@@ -504,18 +504,27 @@ const struct
 {
   uint32_t header[5];
   uint32_t level1[1];
-  uint32_t level2[1];
-  uint8_t level3[1];
+  uint32_t level2[8];
+  int8_t level3[33];
 }
 _nl_C_LC_CTYPE_width =
 {
-  { 7, 1, 0, 0, 0 },
+  { 7, 1, 4, 7, 15 },
   /* 1st-level table */
   { 6 * sizeof (uint32_t) },
   /* 2nd-level table */
-  { 7 * sizeof (uint32_t) },
+  {
+    14 * sizeof (uint32_t) +  0, 0,
+    14 * sizeof (uint32_t) + 16, 14 * sizeof (uint32_t) + 16,
+    14 * sizeof (uint32_t) + 16, 14 * sizeof (uint32_t) + 16,
+    14 * sizeof (uint32_t) + 16, 14 * sizeof (uint32_t) + 17
+  },
   /* 3rd-level table */
-  { 1 }
+  {
+     0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+     1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,
+     -1
+  }
 };
 
 /* Number of fields with fixed meanings, starting at 0.  */
diff --git a/locale/programs/charmap.c b/locale/programs/charmap.c
index f76bc24709..b8e994fdac 100644
--- a/locale/programs/charmap.c
+++ b/locale/programs/charmap.c
@@ -120,7 +120,7 @@ charmap_read (const char *filename)
 	}
     }
 
-  if (result == NULL)
+  if (result == NULL && filename != NULL)
     {
       /* OK, one more try.  We also accept the names given to the
 	 character sets in the files.  Sometimes they differ from the
@@ -155,12 +155,9 @@ charmap_read (const char *filename)
 			char junk[BUFSIZ];
 
 			if (fscanf (fp, " <code_set_name> %as", &name) == 1
-			    || (fscanf (fp, " <code_set_name> \"%as\"", &name)
-				== 1)
 			    || fscanf (fp, "%% alias %as", &name) == 1)
 			  {
-			    if (filename != NULL
-				&& strcasecmp (name, filename) == 0)
+			    if (strcasecmp (name, filename) == 0)
 			      break;
 
 			    free (name);
@@ -189,9 +186,6 @@ charmap_read (const char *filename)
 			result = (cmfile == NULL
 				  ? NULL : parse_charmap (cmfile));
 
-			if (result)
-			  return result;
-
 			break;
 		      }
 		  }
diff --git a/locale/programs/config.h b/locale/programs/config.h
index a293da3b09..512350449e 100644
--- a/locale/programs/config.h
+++ b/locale/programs/config.h
@@ -1,5 +1,5 @@
 /* Configuration for localedef program.
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1995.
 
@@ -28,7 +28,7 @@
 #include "../../version.h"
 #endif
 
-#define DEFAULT_CHARMAP "POSIX"
+#define DEFAULT_CHARMAP "ANSI_X3.4-1968" /* ASCII */
 
 #ifndef PARAMS
 # if __STDC__
diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
index 1d10cec618..4f5653af23 100644
--- a/locale/programs/ld-ctype.c
+++ b/locale/programs/ld-ctype.c
@@ -1309,6 +1309,10 @@ find_idx (struct locale_ctype_t *ctype, uint32_t **table, size_t *max,
     /* We have done everything we are asked to do.  */
     return NULL;
 
+  if (max == NULL)
+    /* The caller does not want to extend the table.  */
+    return (cnt >= *act ? NULL : &(*table)[cnt]);
+
   if (cnt >= *act)
     {
       if (cnt >= *max)
@@ -3732,8 +3736,13 @@ allocate_arrays (struct locale_ctype_t *ctype, struct charmap_t *charmap,
   ctype->class_offset = _NL_ITEM_INDEX (_NL_CTYPE_EXTRA_MAP_1);
   ctype->map_offset = ctype->class_offset + ctype->nr_charclass;
 
-  /* Array for width information.  Because the expected width are very
-     small we use only one single byte.  This saves space.  */
+  /* Array for width information.  Because the expected widths are very
+     small (never larger than 2) we use only one single byte.  This
+     saves space.
+     We put only printable characters in the table.  wcwidth is specified
+     to return -1 for non-printable characters.  Doing the check here
+     saves a run-time check.
+     But we put L'\0' in the table.  This again saves a run-time check.  */
   {
     struct wcwidth_table t;
 
@@ -3741,7 +3750,8 @@ allocate_arrays (struct locale_ctype_t *ctype, struct charmap_t *charmap,
     t.q = 9;
     wcwidth_table_init (&t);
 
-    /* First set all the characters of the character set to the default width.  */
+    /* First set all the printable characters of the character set to
+       the default width.  */
     curs = NULL;
     while (iterate_table (&charmap->char_table, &curs, &key, &len, &vdata) == 0)
       {
@@ -3752,7 +3762,14 @@ allocate_arrays (struct locale_ctype_t *ctype, struct charmap_t *charmap,
 					      data->name, len);
 
 	if (data->ucs4 != ILLEGAL_CHAR_VALUE)
-	  wcwidth_table_add (&t, data->ucs4, charmap->width_default);
+	  {
+	    uint32_t *class_bits =
+	      find_idx (ctype, &ctype->class_collection, NULL,
+			&ctype->class_collection_act, data->ucs4);
+
+	    if (class_bits != NULL && (*class_bits & BITw (tok_print)))
+	      wcwidth_table_add (&t, data->ucs4, charmap->width_default);
+	  }
       }
 
     /* Now add the explicitly specified widths.  */
@@ -3792,8 +3809,16 @@ allocate_arrays (struct locale_ctype_t *ctype, struct charmap_t *charmap,
 					       strlen (seq->name));
 
 		if (wch != ILLEGAL_CHAR_VALUE)
-		  /* Store the value.  */
-		  wcwidth_table_add (&t, wch, charmap->width_rules[cnt].width);
+		  {
+		    /* Store the value.  */
+		    uint32_t *class_bits =
+		      find_idx (ctype, &ctype->class_collection, NULL,
+				&ctype->class_collection_act, wch);
+
+		    if (class_bits != NULL && (*class_bits & BITw (tok_print)))
+		      wcwidth_table_add (&t, wch,
+					 charmap->width_rules[cnt].width);
+		  }
 
 		/* "Increment" the bytes sequence.  */
 		inner = nbytes - 1;
@@ -3820,6 +3845,9 @@ allocate_arrays (struct locale_ctype_t *ctype, struct charmap_t *charmap,
 	  }
       }
 
+    /* Set the width of L'\0' to 0.  */
+    wcwidth_table_add (&t, 0, 0);
+
     wcwidth_table_finalize (&t);
 
     if (verbose)