]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - locale/programs/ld-telephone.c
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / locale / programs / ld-telephone.c
index d842ea2e0ce3cc943f89736fc6c99b12e00bcb29..ed6a260f084cc5721e02a903e2579d02970e3988 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998,1999,2000,2001,2002,2005 Free Software Foundation, Inc.
+/* Copyright (C) 1998-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
@@ -19,9 +19,9 @@
 # include <config.h>
 #endif
 
-#include <error.h>
 #include <langinfo.h>
 #include <string.h>
+#include <stdint.h>
 #include <sys/uio.h>
 
 #include <assert.h>
@@ -89,9 +89,8 @@ telephone_finish (struct localedef_t *locale, const struct charmap_t *charmap)
         empty one.  */
       if (telephone == NULL)
        {
-         if (! be_quiet)
-           WITH_CUR_LOCALE (error (0, 0, _("\
-No definition for %s category found"), "LC_TELEPHONE"));
+         record_warning (_("\
+No definition for %s category found"), "LC_TELEPHONE");
          telephone_startup (NULL, locale, 0);
          telephone = locale->categories[LC_TELEPHONE].telephone;
          nothing = 1;
@@ -101,10 +100,10 @@ No definition for %s category found"), "LC_TELEPHONE"));
   if (telephone->tel_int_fmt == NULL)
     {
       if (! nothing)
-       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),
-                               "LC_TELEPHONE", "tel_int_fmt"));
+       record_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";
+      telephone->tel_int_fmt = "+%c %a%t%l";
     }
   else
     {
@@ -113,17 +112,17 @@ No definition for %s category found"), "LC_TELEPHONE"));
       const char *cp = telephone->tel_int_fmt;
 
       if (*cp == '\0')
-       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' must not be empty"),
-                               "LC_TELEPHONE", "tel_int_fmt"));
+       record_error (0, 0, _("%s: field `%s' must not be empty"),
+                     "LC_TELEPHONE", "tel_int_fmt");
       else
        while (*cp != '\0')
          {
            if (*cp == '%')
              {
-               if (strchr ("aAlc", *++cp) == NULL)
+               if (strchr ("aAcCelt", *++cp) == NULL)
                  {
-                   WITH_CUR_LOCALE (error (0, 0, _("\
-%s: invalid escape sequence in field `%s'"), "LC_TELEPHONE", "tel_int_fmt"));
+                   record_error (0, 0, _("\
+%s: invalid escape sequence in field `%s'"), "LC_TELEPHONE", "tel_int_fmt");
                    break;
                  }
              }
@@ -143,10 +142,10 @@ No definition for %s category found"), "LC_TELEPHONE"));
        {
          if (*cp == '%')
            {
-             if (strchr ("aAlc", *++cp) == NULL)
+             if (strchr ("aAcCelt", *++cp) == NULL)
                {
-                 WITH_CUR_LOCALE (error (0, 0, _("\
-%s: invalid escape sequence in field `%s'"), "LC_TELEPHONE", "tel_dom_fmt"));
+                 record_error (0, 0, _("\
+%s: invalid escape sequence in field `%s'"), "LC_TELEPHONE", "tel_dom_fmt");
                  break;
                }
            }
@@ -158,8 +157,8 @@ No definition for %s category found"), "LC_TELEPHONE"));
   if (telephone->cat == NULL)                                                \
     {                                                                        \
       if (verbose && ! nothing)                                                      \
-       WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),        \
-                               "LC_TELEPHONE", #cat));                       \
+       record_warning (_("%s: field `%s' not defined"), "LC_TELEPHONE",      \
+                       #cat);                                                \
       telephone->cat = "";                                                   \
     }
 
@@ -174,50 +173,15 @@ telephone_output (struct localedef_t *locale, const struct charmap_t *charmap,
 {
   struct locale_telephone_t *telephone =
     locale->categories[LC_TELEPHONE].telephone;
-  struct iovec iov[2 + _NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE)];
-  struct locale_file data;
-  uint32_t idx[_NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE)];
-  size_t cnt = 0;
-
-  data.magic = LIMAGIC (LC_TELEPHONE);
-  data.n = _NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE);
-  iov[cnt].iov_base = (void *) &data;
-  iov[cnt].iov_len = sizeof (data);
-  ++cnt;
-
-  iov[cnt].iov_base = (void *) idx;
-  iov[cnt].iov_len = sizeof (idx);
-  ++cnt;
-
-  idx[cnt - 2] = iov[0].iov_len + iov[1].iov_len;
-  iov[cnt].iov_base = (void *) telephone->tel_int_fmt;
-  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) telephone->tel_dom_fmt;
-  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) telephone->int_select;
-  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) telephone->int_prefix;
-  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
-  ++cnt;
-
-  idx[cnt - 2] = idx[cnt - 3] + iov[cnt - 1].iov_len;
-  iov[cnt].iov_base = (void *) charmap->code_set_name;;
-  iov[cnt].iov_len = strlen (iov[cnt].iov_base) + 1;
-  ++cnt;
-
-  assert (cnt == 2 + _NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE));
-
-  write_locale_data (output_path, LC_TELEPHONE, "LC_TELEPHONE",
-                    2 + _NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE), iov);
+  struct locale_file file;
+
+  init_locale_data (&file, _NL_ITEM_INDEX (_NL_NUM_LC_TELEPHONE));
+  add_locale_string (&file, telephone->tel_int_fmt);
+  add_locale_string (&file, telephone->tel_dom_fmt);
+  add_locale_string (&file, telephone->int_select);
+  add_locale_string (&file, telephone->int_prefix);
+  add_locale_string (&file, charmap->code_set_name);
+  write_locale_data (output_path, LC_TELEPHONE, "LC_TELEPHONE", &file);
 }