summary refs log tree commit diff
path: root/locale
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-10-19 13:33:29 +0000
committerUlrich Drepper <drepper@redhat.com>1998-10-19 13:33:29 +0000
commit816e6eb5a786594223586976c08e337bc08b6f4e (patch)
treef40c1af0b36c777b5987dc6c888e9492518d14da /locale
parent685c167680a6d1040abc5ff33bd25e5f423f9405 (diff)
downloadglibc-816e6eb5a786594223586976c08e337bc08b6f4e.tar.gz
glibc-816e6eb5a786594223586976c08e337bc08b6f4e.tar.xz
glibc-816e6eb5a786594223586976c08e337bc08b6f4e.zip
Update.
1998-10-19 13:24  Ulrich Drepper  <drepper@cygnus.com>

	* locale/programs/ld-collate.c (collate_startup): Clear bit for this
	category in copy_posix.
	(collate_finish): Don't warn about UNDEFINED not being defined.
	* locale/programs/ld-ctype.c (ctype_startup): Clear bit for this
	category in copy_posix.
	* locale/programs/ld-messages.c (messages_startup): Likewise.
	* locale/programs/ld-monetary.c (monetary_startup): Likewise.
	* locale/programs/ld-numeric.c (numeric_startup): Likewise.
	* locale/programs/ld-time.c (time_startup): Likewise.
	* locale/programs/localedef.c: Move copy_def_list_t definition into
	locales.h.  Define copy_posix variable.
	(main): Before processing copy list add &copy_posix to copy_list.
	* locale/programs/locales.h: Add definition of copy_def_list_t.
	* locale/programs/locfile.c: Clear bit for appropriate category in
	case of an copy instruction.
Diffstat (limited to 'locale')
-rw-r--r--locale/programs/ld-collate.c5
-rw-r--r--locale/programs/ld-ctype.c3
-rw-r--r--locale/programs/ld-messages.c3
-rw-r--r--locale/programs/ld-monetary.c15
-rw-r--r--locale/programs/ld-numeric.c5
-rw-r--r--locale/programs/ld-time.c3
-rw-r--r--locale/programs/localedef.c37
-rw-r--r--locale/programs/locales.h22
-rw-r--r--locale/programs/locfile.c1
9 files changed, 70 insertions, 24 deletions
diff --git a/locale/programs/ld-collate.c b/locale/programs/ld-collate.c
index a92ff1154a..b9734c36dd 100644
--- a/locale/programs/ld-collate.c
+++ b/locale/programs/ld-collate.c
@@ -155,6 +155,9 @@ collate_startup (struct linereader *lr, struct localedef_t *locale,
 {
   struct locale_collate_t *collate;
 
+  /* We have a definition for LC_COLLATE.  */
+  copy_posix.mask &= ~(1 << LC_COLLATE);
+
   /* It is important that we always use UCS4 encoding for strings now.  */
   encoding_method = ENC_UCS4;
 
@@ -260,7 +263,7 @@ collate_finish (struct localedef_t *locale, struct charset_t *charset)
       \**************************************************************/
       u_int32_t weight;
 
-      if (!be_quiet)
+      if (/* XXX Remove the 0 & */ 0 && !be_quiet)
 	error (0, 0, _("no definition of `UNDEFINED'"));
 
       collate->undefined.ordering_len = collate->nrules;
diff --git a/locale/programs/ld-ctype.c b/locale/programs/ld-ctype.c
index 01d37e3fc4..a4dcd76807 100644
--- a/locale/programs/ld-ctype.c
+++ b/locale/programs/ld-ctype.c
@@ -135,6 +135,9 @@ ctype_startup (struct linereader *lr, struct localedef_t *locale,
   unsigned int cnt;
   struct locale_ctype_t *ctype;
 
+  /* We have a definition for LC_CTYPE.  */
+  copy_posix.mask &= ~(1 << LC_CTYPE);
+
   /* It is important that we always use UCS1 encoding for strings now.  */
   encoding_method = ENC_UCS1;
 
diff --git a/locale/programs/ld-messages.c b/locale/programs/ld-messages.c
index 9353e1e49e..e52f5413e2 100644
--- a/locale/programs/ld-messages.c
+++ b/locale/programs/ld-messages.c
@@ -60,6 +60,9 @@ messages_startup (struct linereader *lr, struct localedef_t *locale,
 {
   struct locale_messages_t *messages;
 
+  /* We have a definition for LC_MESSAGES.  */
+  copy_posix.mask &= ~(1 << LC_MESSAGES);
+
   /* It is important that we always use UCS1 encoding for strings now.  */
   encoding_method = ENC_UCS1;
 
diff --git a/locale/programs/ld-monetary.c b/locale/programs/ld-monetary.c
index d202d76399..4aede4691f 100644
--- a/locale/programs/ld-monetary.c
+++ b/locale/programs/ld-monetary.c
@@ -84,6 +84,9 @@ monetary_startup (struct linereader *lr, struct localedef_t *locale,
 {
   struct locale_monetary_t *monetary;
 
+  /* We have a definition for LC_MONETARY.  */
+  copy_posix.mask &= ~(1 << LC_MONETARY);
+
   /* It is important that we always use UCS1 encoding for strings now.  */
   encoding_method = ENC_UCS1;
 
@@ -129,15 +132,17 @@ monetary_finish (struct localedef_t *locale)
   /* The international currency symbol must come from ISO 4217.  */
   if (monetary->int_curr_symbol != NULL)
     {
-      if (strlen (monetary->int_curr_symbol) != 4)
+      if (strlen (monetary->int_curr_symbol) != 4
+	  && monetary->int_curr_symbol[0] != '\0')
 	{
 	  if (!be_quiet)
 	    error (0, 0, _("\
 value of field `int_curr_symbol' in category `LC_MONETARY' has wrong length"));
 	}
-      else if (bsearch (monetary->int_curr_symbol, valid_int_curr,
-			NR_VALID_INT_CURR, sizeof (const char *),
-			(comparison_fn_t) curr_strcmp) == NULL
+      else if (monetary->int_curr_symbol[0] != '\0'
+	       && bsearch (monetary->int_curr_symbol, valid_int_curr,
+			   NR_VALID_INT_CURR, sizeof (const char *),
+			   (comparison_fn_t) curr_strcmp) == NULL
 	       && !be_quiet)
 	error (0, 0, _("\
 value of field `int_curr_symbol' in category `LC_MONETARY' does \
@@ -336,6 +341,8 @@ field `%s' in category `%s' declared more than once"),			      \
 	lr_error (lr, _("\
 field `%s' in category `%s' declared more than once"),			      \
 		  #cat, "LC_MONETARY");					      \
+      else if (code->tok == tok_minus1)					      \
+	monetary->cat = -1;						      \
       else								      \
 	monetary->cat = code->val.num;					      \
       break
diff --git a/locale/programs/ld-numeric.c b/locale/programs/ld-numeric.c
index 2454281a4d..bbc575852d 100644
--- a/locale/programs/ld-numeric.c
+++ b/locale/programs/ld-numeric.c
@@ -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>, 1995.
 
@@ -54,6 +54,9 @@ numeric_startup (struct linereader *lr, struct localedef_t *locale,
 {
   struct locale_numeric_t *numeric;
 
+  /* We have a definition for LC_NUMERIC.  */
+  copy_posix.mask &= ~(1 << LC_NUMERIC);
+
   /* It is important that we always use UCS1 encoding for strings now.  */
   encoding_method = ENC_UCS1;
 
diff --git a/locale/programs/ld-time.c b/locale/programs/ld-time.c
index e16a247430..aa401627f2 100644
--- a/locale/programs/ld-time.c
+++ b/locale/programs/ld-time.c
@@ -90,6 +90,9 @@ time_startup (struct linereader *lr, struct localedef_t *locale,
 {
   struct locale_time_t *time;
 
+  /* We have a definition for LC_TIME.  */
+  copy_posix.mask &= ~(1 << LC_TIME);
+
   /* It is important that we always use UCS1 encoding for strings now.  */
   encoding_method = ENC_UCS1;
 
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
index 94d6255378..f208d8b874 100644
--- a/locale/programs/localedef.c
+++ b/locale/programs/localedef.c
@@ -38,27 +38,21 @@
 #include "error.h"
 #include "charset.h"
 #include "locfile.h"
+#include "locales.h"
 
 /* Undefine the following line in the production version.  */
 /* #define NDEBUG 1 */
 #include <assert.h>
 
 
-/* List of locale definition files which are used in `copy' instructions.  */
-struct copy_def_list_t
+/* This is a special entry of the copylist.  For all categories we don't
+   have a definition we use the data for the POSIX locale.  */
+struct copy_def_list_t copy_posix =
 {
-  struct copy_def_list_t *next;
-
-  const char *name;
-  int mask;
-
-  struct localedef_t *locale;
-
-  struct
-  {
-    void *data;
-    size_t len;
-  } binary[6];
+  next: NULL,
+  name: "POSIX",
+  mask: (1 << LC_ALL) - 1,
+  locale: NULL
 };
 
 
@@ -153,7 +147,6 @@ main (int argc, char *argv[])
   int remaining;
 
   /* Set initial values for global variables.  */
-  copy_list = NULL;
   posix_conformance = getenv ("POSIXLY_CORRECT") != NULL;
   error_print_progname = error_print;
 
@@ -204,6 +197,10 @@ main (int argc, char *argv[])
   if (localedef->failed != 0)
     error (4, errno, _("cannot open locale definition file `%s'"), input_file);
 
+  /* Make sure all categories are defined.  */
+  copy_posix.next = copy_list;
+  copy_list = &copy_posix;
+
   /* Perhaps we saw some `copy' instructions.  Process the given list.
      We use a very simple algorithm: we look up the list from the
      beginning every time.  */
@@ -229,8 +226,14 @@ main (int argc, char *argv[])
 	  int avail = 0;
 
 	  if (act_add_locdef->locale == NULL)
-	    act_add_locdef->locale = locfile_read (act_add_locdef->name,
-						   charset);
+	    {
+	      /* Saving the mask is an ugly trick to prevent the reader
+		 from modifying `copy_posix' if we currently process it.  */
+	      int save_mask = act_add_locdef->mask;
+	      act_add_locdef->locale = locfile_read (act_add_locdef->name,
+						     charset);
+	      act_add_locdef->mask = save_mask;
+	    }
 
 	  if (! act_add_locdef->locale->failed)
 	    {
diff --git a/locale/programs/locales.h b/locale/programs/locales.h
index eab909e7c8..1cd3a3f92e 100644
--- a/locale/programs/locales.h
+++ b/locale/programs/locales.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 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>, 1996.
 
@@ -33,6 +33,26 @@
 #include "localeinfo.h"
 
 
+/* List of locale definition files which are used in `copy' instructions.  */
+struct copy_def_list_t
+{
+  struct copy_def_list_t *next;
+
+  const char *name;
+  int mask;
+
+  struct localedef_t *locale;
+
+  struct
+  {
+    void *data;
+    size_t len;
+  } binary[6];
+};
+
+extern struct copy_def_list_t copy_posix;
+
+
 /* Header of the locale data files.  */
 struct locale_file
 {
diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c
index 5a3fc25e3d..0485b61645 100644
--- a/locale/programs/locfile.c
+++ b/locale/programs/locfile.c
@@ -116,6 +116,7 @@ locfile_read (const char *filename, struct charset_t *charset)
 #define HANDLE_COPY(category, token, string)				      \
   if (nowtok == tok_copy)						      \
     {									      \
+      copy_posix.mask &= ~(1 << category);				      \
       copy_category = category;						      \
       expected_tok = token;						      \
       expected_str = string;						      \