summary refs log tree commit diff
path: root/locale/programs/ld-telephone.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-09-12 08:28:56 +0000
committerUlrich Drepper <drepper@redhat.com>1999-09-12 08:28:56 +0000
commitb9eb05d6bfd4c42c8ea614b77cbc50d95fee51d1 (patch)
tree7d42913f77a3db0fe5f54807a248578fe747e3d1 /locale/programs/ld-telephone.c
parent0f0e233c0e6a7c3df341566bbbd60917439f9cc9 (diff)
downloadglibc-b9eb05d6bfd4c42c8ea614b77cbc50d95fee51d1.tar.gz
glibc-b9eb05d6bfd4c42c8ea614b77cbc50d95fee51d1.tar.xz
glibc-b9eb05d6bfd4c42c8ea614b77cbc50d95fee51d1.zip
Update.
1999-09-12  Ulrich Drepper  <drepper@cygnus.com>

	* locale/programs/ld-address.c: Fix handling of non-existing
	definitions for this category.  Correctly ignore content of this
	category is this is necessary.
	* locale/programs/ld-collate.c: Likewise.
	* locale/programs/ld-ctype.c: Likewise.
	* locale/programs/ld-identification.c: Likewise.
	* locale/programs/ld-measurement.c: Likewise.
	* locale/programs/ld-messages.c: Likewise.
	* locale/programs/ld-monetary.c: Likewise.
	* locale/programs/ld-name.c: Likewise.
	* locale/programs/ld-numeric.c: Likewise.
	* locale/programs/ld-paper.c: Likewise.
	* locale/programs/ld-telephone.c: Likewise.
	* locale/programs/ld-time.c: Likewise.
	* locale/programs/locfile.h (handle_copy): Take extra parameter
	with result pointer.  Fill in name of locale from which to copy.
	Correctly read token after `END'.

	* locale/programs/localedef.c (main): Correct handling copy.
	(add_to_readlist): Take extra parameter which says whether we
	are supposed to read the file or not.
	(find_locale): Call add_to_readlist with extra parameter set to 0.

	* locale/programs/localedef.h (struct localedef_t): Use __LC_LAST
	instead of wrong number in array definitions.
	(add_to_readlist): Update prototype.

	* locale/programs/locfile.c (locfile_read): Mark categories not
	available in source file as read.
	(write_all_categories): Fix typo.
Diffstat (limited to 'locale/programs/ld-telephone.c')
-rw-r--r--locale/programs/ld-telephone.c60
1 files changed, 53 insertions, 7 deletions
diff --git a/locale/programs/ld-telephone.c b/locale/programs/ld-telephone.c
index 2d75fea6b6..5d2ea490ad 100644
--- a/locale/programs/ld-telephone.c
+++ b/locale/programs/ld-telephone.c
@@ -50,8 +50,11 @@ telephone_startup (struct linereader *lr, struct localedef_t *locale,
     locale->categories[LC_TELEPHONE].telephone = (struct locale_telephone_t *)
       xcalloc (1, sizeof (struct locale_telephone_t));
 
-  lr->translate_strings = 1;
-  lr->return_widestr = 0;
+  if (lr != NULL)
+    {
+      lr->translate_strings = 1;
+      lr->return_widestr = 0;
+    }
 }
 
 
@@ -60,11 +63,46 @@ telephone_finish (struct localedef_t *locale, struct charmap_t *charmap)
 {
   struct locale_telephone_t *telephone =
     locale->categories[LC_TELEPHONE].telephone;
+  int nothing = 0;
+
+  /* Now resolve copying and also handle completely missing definitions.  */
+  if (telephone == NULL)
+    {
+      /* First see whether we were supposed to copy.  If yes, find the
+	 actual definition.  */
+      if (locale->copy_name[LC_TELEPHONE] != NULL)
+	{
+	  /* Find the copying locale.  This has to happen transitively since
+	     the locale we are copying from might also copying another one.  */
+	  struct localedef_t *from = locale;
+
+	  do
+	    from = find_locale (LC_TELEPHONE, from->copy_name[LC_TELEPHONE],
+				from->repertoire_name, charmap);
+	  while (from->categories[LC_TELEPHONE].telephone == NULL
+		 && from->copy_name[LC_TELEPHONE] != NULL);
+
+	  telephone = locale->categories[LC_TELEPHONE].telephone
+	    = from->categories[LC_TELEPHONE].telephone;
+	}
+
+      /* If there is still no definition issue an warning and create an
+	 empty one.  */
+      if (telephone == NULL)
+	{
+	  error (0, 0, _("No definition for %s category found"),
+		 "LC_TELEPHONE");
+	  telephone_startup (NULL, locale, 0);
+	  telephone = locale->categories[LC_TELEPHONE].telephone;
+	  nothing = 1;
+	}
+    }
 
   if (telephone->tel_int_fmt == NULL)
     {
-      error (0, 0, _("%s: field `%s' not defined"),
-	     "LC_TELEPHONE", "tel_int_fmt");
+      if (! nothing)
+	error (0, 0, _("%s: field `%s' not defined"),
+	       "LC_TELEPHONE", "tel_int_fmt");
       /* Use as the default value the value of the i18n locale.  */
       telephone->tel_int_fmt = "+%c %a %l";
     }
@@ -120,7 +158,7 @@ telephone_finish (struct localedef_t *locale, struct charmap_t *charmap)
 #define TEST_ELEM(cat) \
   if (telephone->cat == NULL)						      \
     {									      \
-      if (verbose)							      \
+      if (verbose && ! nothing)						      \
 	error (0, 0, _("%s: field `%s' not defined"), "LC_TELEPHONE", #cat);  \
       telephone->cat = "";						      \
     }
@@ -207,8 +245,8 @@ telephone_read (struct linereader *ldfile, struct localedef_t *result,
   /* If we see `copy' now we are almost done.  */
   if (nowtok == tok_copy)
     {
-      handle_copy (ldfile, charmap, repertoire, tok_lc_telephone, LC_TELEPHONE,
-		   "LC_TELEPHONE", ignore_content);
+      handle_copy (ldfile, charmap, repertoire, result, tok_lc_telephone,
+		   LC_TELEPHONE, "LC_TELEPHONE", ignore_content);
       return;
     }
 
@@ -234,6 +272,14 @@ telephone_read (struct linereader *ldfile, struct localedef_t *result,
 	{
 #define STR_ELEM(cat) \
 	case tok_##cat:							      \
+	  /* Ignore the rest of the line if we don't need the input of	      \
+	     this line.  */						      \
+	  if (ignore_content)						      \
+	    {								      \
+	      lr_ignore_rest (ldfile, 0);				      \
+	      break;							      \
+	    }								      \
+									      \
 	  arg = lr_token (ldfile, charmap, NULL);			      \
 	  if (arg->tok != tok_string)					      \
 	    goto err_label;						      \