about summary refs log tree commit diff
path: root/locale
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-10-31 04:38:55 +0000
committerUlrich Drepper <drepper@redhat.com>2000-10-31 04:38:55 +0000
commit02fb3d179ddd3c88f4d4f31d4b27948b48bced2b (patch)
tree21c13678f5ef2e6daf5972fa6defef68abd382d3 /locale
parentcdfb970dd9c20861d7fdac16435d70792b8a027a (diff)
downloadglibc-02fb3d179ddd3c88f4d4f31d4b27948b48bced2b.tar.gz
glibc-02fb3d179ddd3c88f4d4f31d4b27948b48bced2b.tar.xz
glibc-02fb3d179ddd3c88f4d4f31d4b27948b48bced2b.zip
Update.
	* posix/runtests.c (main): Don't use exit() to avoid warning with
	broken compilers.

	* string/bug-strncat1.c: Undefine __USE_STRING_INLINES before
	defining it again to avoid warning.
	* string/bug-strpbrk1.c: Likewise.
	* string/bug-strspn1.c: Likewise.

2000-10-29  Bruno Haible  <haible@clisp.cons.org>

	* locale/C-translit.h.in: Include more rules from translit_neutral.
	Remove a few German and Danish specific rules.
	* locale/gen-translit.pl: Avoid an error when printing a string
	containing a '%' character.
	* locale/C-translit.h: Regenerated.
	* intl/translit.po: Choose different translations.
	* intl/tst-translit.c: Update.

2000-10-29  Bruno Haible  <haible@clisp.cons.org>

	* locale/programs/ld-ctype.c (translit_include_t): New type.
	(locale_ctype_t): Remove translit_copy_locale, translit_copy_repertoire
	fields, add translit_include field.
	(ctype_read): After seeing "translit_start" in ignore_content mode,
	skip the entire translit section, not only one line. Remove dead test
	for tok_translit_end. Enqueue include statements into a list.
	Signal error if tok_eof seen before tok_translit_end.
	(translit_flatten): New function.
	(allocate_arrays): Call translit_flatten.

2000-10-30  Ulrich Drepper  <drepper@redhat.com>
Diffstat (limited to 'locale')
-rw-r--r--locale/programs/ld-ctype.c162
1 files changed, 104 insertions, 58 deletions
diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
index 4f5653af23..f624769b68 100644
--- a/locale/programs/ld-ctype.c
+++ b/locale/programs/ld-ctype.c
@@ -106,6 +106,16 @@ struct translit_ignore_t
 };
 
 
+/* Type to describe a transliteration include statement.  */
+struct translit_include_t 
+{
+  const char *copy_locale;
+  const char *copy_repertoire;
+
+  struct translit_include_t *next;
+};
+
+
 /* The real definition of the struct for the LC_CTYPE locale.  */
 struct locale_ctype_t
 {
@@ -155,8 +165,7 @@ struct locale_ctype_t
   uint32_t map_offset;
 
   /* Transliteration information.  */
-  const char *translit_copy_locale;
-  const char *translit_copy_repertoire;
+  struct translit_include_t *translit_include;
   struct translit_t *translit;
   struct translit_ignore_t *translit_ignore;
   uint32_t ntranslit_ignore;
@@ -2609,11 +2618,22 @@ with character code range values one must use the absolute ellipsis `...'"));
 	  break;
 
 	case tok_translit_start:
-	  /* Ignore the rest of the line if we don't need the input of
-	     this line.  */
+	  /* Ignore the entire translit section with its peculiar syntax
+	     if we don't need the input.  */
 	  if (ignore_content)
 	    {
-	      lr_ignore_rest (ldfile, 0);
+	      do
+		{
+		  lr_ignore_rest (ldfile, 0);
+		  now = lr_token (ldfile, charmap, NULL);
+		}
+	      while (now->tok != tok_translit_end && now->tok != tok_eof);
+
+	      if (now->tok == tok_eof)
+		lr_error (ldfile, _(\
+"%s: `translit_start' section does not end with `translit_end'"),
+			  "LC_CTYPE");
+
 	      break;
 	    }
 
@@ -2635,17 +2655,12 @@ with character code range values one must use the absolute ellipsis `...'"));
 		/* Ignore empty lines.  */
 		continue;
 
-	      if (now->tok == tok_translit_end)
-		{
-		  lr_ignore_rest (ldfile, 0);
-		  break;
-		}
-
 	      if (now->tok == tok_include)
 		{
 		  /* We have to include locale.  */
 		  const char *locale_name;
 		  const char *repertoire_name;
+		  struct translit_include_t *include_stmt, **include_ptr;
 
 		  now = lr_token (ldfile, charmap, NULL);
 		  /* This should be a string or an identifier.  In any
@@ -2671,24 +2686,24 @@ with character code range values one must use the absolute ellipsis `...'"));
 		    goto translit_syntax;
 		  repertoire_name = now->val.str.startmb;
 
-		  /* We must not have more than one `include'.  */
-		  if (ctype->translit_copy_locale != NULL)
-		    {
-		      lr_error (ldfile, _("\
-%s: only one `include' instruction allowed"), "LC_CTYPE");
-		      lr_ignore_rest (ldfile, 0);
-		      continue;
-		    }
+		  /* Save the include statement for later processing.  */
+		  include_stmt = (struct translit_include_t *)
+		    xmalloc (sizeof (struct translit_include_t));
+		  include_stmt->copy_locale = locale_name;
+		  include_stmt->copy_repertoire = repertoire_name;
+		  include_stmt->next = NULL;
 
-		  ctype->translit_copy_locale = locale_name;
-		  ctype->translit_copy_repertoire = repertoire_name;
+		  include_ptr = &ctype->translit_include;
+		  while (*include_ptr != NULL)
+		    include_ptr = &(*include_ptr)->next;
+		  *include_ptr = include_stmt;
 
 		  /* The rest of the line must be empty.  */
 		  lr_ignore_rest (ldfile, 1);
 
 		  /* Make sure the locale is read.  */
-		  add_to_readlist (LC_CTYPE, ctype->translit_copy_locale,
-				   repertoire_name, 1, NULL);
+		  add_to_readlist (LC_CTYPE, locale_name, repertoire_name,
+				   1, NULL);
 		  continue;
 		}
 	      else if (now->tok == tok_default_missing)
@@ -2753,6 +2768,12 @@ previous definition was here"));
 	      read_translit_entry (ldfile, ctype, now, charmap, repertoire);
 	    }
 	  ldfile->return_widestr = 0;
+
+	  if (now->tok == tok_eof)
+	    lr_error (ldfile, _(\
+"%s: `translit_start' section does not end with `translit_end'"),
+		      "LC_CTYPE");
+
 	  break;
 
 	case tok_ident:
@@ -3591,6 +3612,62 @@ wctrans_table_add (struct wctrans_table *t, uint32_t wc, uint32_t mapped_wc)
 }
 
 
+/* Flattens the included transliterations into a translit list.
+   Inserts them in the list at `cursor', and returns the new cursor.  */
+static struct translit_t **
+translit_flatten (struct locale_ctype_t *ctype, struct charmap_t *charmap,
+		  struct translit_t **cursor)
+{
+  while (ctype->translit_include != NULL)
+    {
+      const char *copy_locale = ctype->translit_include->copy_locale;
+      const char *copy_repertoire = ctype->translit_include->copy_repertoire;
+      struct localedef_t *other;
+
+      /* Unchain the include statement.  During the depth-first traversal
+	 we don't want to visit any locale more than once.  */
+      ctype->translit_include = ctype->translit_include->next;
+
+      other = find_locale (LC_CTYPE, copy_locale, copy_repertoire, charmap);
+
+      if (other == NULL)
+	{
+	  error (0, 0, _("\
+%s: transliteration data from locale `%s' not available"),
+		 "LC_CTYPE", copy_locale);
+	}
+      else
+	{
+	  struct locale_ctype_t *other_ctype =
+	    other->categories[LC_CTYPE].ctype;
+
+	  cursor = translit_flatten (other_ctype, charmap, cursor);
+	  assert (other_ctype->translit_include == NULL);
+
+	  if (other_ctype->translit != NULL)
+	    {
+	      /* Insert the other_ctype->translit list at *cursor.  */
+	      struct translit_t *endp = other_ctype->translit;
+	      while (endp->next != NULL)
+		endp = endp->next;
+
+	      endp->next = *cursor;
+	      *cursor = other_ctype->translit;
+
+	      /* Avoid any risk of circular lists.  */
+	      other_ctype->translit = NULL;
+
+	      cursor = &endp->next;
+	    }
+
+	  if (ctype->default_missing == NULL)
+	    ctype->default_missing = other_ctype->default_missing;
+	}
+    }
+
+  return cursor;
+}
+
 static void
 allocate_arrays (struct locale_ctype_t *ctype, struct charmap_t *charmap,
 		 struct repertoire_t *repertoire)
@@ -3867,41 +3944,10 @@ allocate_arrays (struct locale_ctype_t *ctype, struct charmap_t *charmap,
      complicated algorithm which uses a hash table to locate the entries.
      For now I'll use a simple array which can be searching using binary
      search.  */
-  if (ctype->translit_copy_locale != NULL)
-    {
-      /* Fold in the transliteration information from the locale mentioned
-	 in the `include' statement.  */
-      struct locale_ctype_t *here = ctype;
-
-      do
-	{
-	  struct localedef_t *other = find_locale (LC_CTYPE,
-						   here->translit_copy_locale,
-						   repertoire->name, charmap);
-
-	  if (other == NULL)
-	    {
-	      error (0, 0, _("\
-%s: transliteration data from locale `%s' not available"),
-		     "LC_CTYPE", here->translit_copy_locale);
-	      break;
-	    }
-
-	  here = other->categories[LC_CTYPE].ctype;
-
-	  /* Enqueue the information if necessary.  */
-	  if (here->translit != NULL)
-	    {
-	      struct translit_t *endp = here->translit;
-	      while (endp->next != NULL)
-		endp = endp->next;
-
-	      endp->next = ctype->translit;
-	      ctype->translit = here->translit;
-	    }
-	}
-      while (here->translit_copy_locale != NULL);
-    }
+  if (ctype->translit_include != NULL)
+    /* Traverse the locales mentioned in the `include' statements in a
+       depth-first way and fold in their transliteration information.  */
+    translit_flatten (ctype, charmap, &ctype->translit);
 
   if (ctype->translit != NULL)
     {