about summary refs log tree commit diff
path: root/locale/programs/ld-collate.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-12-30 18:12:52 +0000
committerUlrich Drepper <drepper@redhat.com>1999-12-30 18:12:52 +0000
commit3ac4f91b92889704d9e89b6098e287d89cb84fad (patch)
tree9f35c20fc190cb5d957a2be542c15d324439591a /locale/programs/ld-collate.c
parentcd7de27bf3958927bdc67ca53aded083970fe4de (diff)
downloadglibc-3ac4f91b92889704d9e89b6098e287d89cb84fad.tar.gz
glibc-3ac4f91b92889704d9e89b6098e287d89cb84fad.tar.xz
glibc-3ac4f91b92889704d9e89b6098e287d89cb84fad.zip
Update.
	* locale/programs/ld-collate.c (collate_finish): Always define
	weight for UNDEFINED if not defined by the user but don't complain
	unless it is needed in the multibyte character table.
	(collate_output): Add extra dummy elements in wide char tables in the
	same way done for multibyte.  Always output undefined entry in
	wide character table.

	Contributed by Richard Henderson, Jakub Jelinek and others.
Diffstat (limited to 'locale/programs/ld-collate.c')
-rw-r--r--locale/programs/ld-collate.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
index 65af8e6b6a..9f4966f2d0 100644
--- a/locale/programs/ld-collate.c
+++ b/locale/programs/ld-collate.c
@@ -1717,17 +1717,24 @@ Computing table size for collation table might take a while..."),
   /* Now determine whether the UNDEFINED entry is needed and if yes,
      whether it was defined.  */
   collate->undefined.used_in_level = need_undefined ? ~0ul : 0;
-  if (need_undefined && collate->undefined.file == NULL)
+  if (collate->undefined.file == NULL)
     {
-      error (0, 0, _("no definition of `UNDEFINED'"));
+      if (need_undefined)
+	{
+	  error (0, 0, _("no definition of `UNDEFINED'"));
 
-      /* Add UNDEFINED at the end.  */
-      collate->undefined.mborder =
-	(int *) obstack_alloc (&collate->mempool, nrules * sizeof (int));
+	  /* Add UNDEFINED at the end.  */
+	  collate->undefined.mborder =
+	    (int *) obstack_alloc (&collate->mempool, nrules * sizeof (int));
 
-      for (i = 0; i < nrules; ++i)
-	collate->undefined.mborder[i] = mbact[i]++;
+	  for (i = 0; i < nrules; ++i)
+	    collate->undefined.mborder[i] = mbact[i]++;
+	}
 
+      /* In any case we will need the definition for the wide character
+	 case.  But we will not complain that it is missing since the
+	 specification strangely enough does not seem to account for
+	 this.  */
       collate->undefined.wcorder = wcact++;
     }
 
@@ -2179,6 +2186,26 @@ collate_output (struct localedef_t *locale, struct charmap_t *charmap,
   idx[1 + cnt] = idx[cnt] + iov[2 + cnt].iov_len;
   ++cnt;
 
+  /* Since we are using the sign of an integer to mark indirection the
+     offsets in the arrays we are indirectly referring to must not be
+     zero since -0 == 0.  Therefore we add a bit of dummy content.  */
+  if (sizeof (int) == sizeof (int32_t))
+    {
+      obstack_int_grow (&extrapool, 0);
+      obstack_int_grow (&indirectpool, 0);
+    }
+  else
+    {
+      int32_t zero = 0;
+      obstack_grow (&extrapool, &zero, sizeof (zero));
+      obstack_grow (&indirectpool, &zero, sizeof (zero));
+    }
+
+  /* Now insert the `UNDEFINED' value if it is used.  Since this value
+     will probably be used more than once it is good to store the
+     weights only once.  */
+  output_weightwc (&weightpool, collate, &collate->undefined);
+
   /* Generate the table.  Walk through the lists of sequences
      starting with the same byte and add them one after the other to
      the table.  In case we have more than one sequence starting with