]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Merge with glibc/intl.
authorBruno Haible <bruno@clisp.org>
Mon, 16 Dec 2002 15:15:24 +0000 (15:15 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:08:52 +0000 (12:08 +0200)
intl/ChangeLog
intl/bindtextdom.c
intl/dcigettext.c
intl/dcngettext.c
intl/dngettext.c
intl/finddomain.c
intl/loadmsgcat.c
intl/localealias.c
intl/ngettext.c

index d08872accc224a45d3770842ac6608f581aae0e4..233f72b667eebd6c4f9a4e3e183ab8d3441db188 100644 (file)
@@ -1,3 +1,65 @@
+2002-12-12  Bruno Haible  <bruno@clisp.org>
+
+       * dcigettext.c (INTVARDEF): Correct fallback definition.
+
+2002-11-19  Ulrich Drepper  <drepper@redhat.com>
+
+       * localealias.c (read_alias_file): Use only about 400 bytes of stack
+       space instead of 16k.
+
+2002-10-30  Jakub Jelinek  <jakub@redhat.com>
+
+       * finddomain.c (free_mem): Use libc_freeres_fn macro, remove
+       text_set_element.
+       * dcigettext.c (free_mem): Likewise.
+
+2002-10-25  Jakub Jelinek  <jakub@redhat.com>
+
+       * localealias.c (libc_freeres_ptr): Define if !_LIBC.
+       (string_space, map): Add libc_freeres_ptr.
+       (free_mem): Remove.
+
+2002-09-19  Bruno Haible  <bruno@clisp.org>
+
+       * dcigettext.c (DCIGETTEXT): Restore errno only right before
+       returning.
+
+2002-09-01  Roland McGrath  <roland@redhat.com>
+
+       * localealias.c [__GNUC__]: #undef alloca before #define.
+
+2002-08-30  Roland McGrath  <roland@redhat.com>
+
+       * dcigettext.c (DCIGETTEXT) [_LIBC]: Check for bogus CATEGORY.
+       [_LIBC] (category_to_name): Don't define the function.  Instead define
+       a macro using _nl_category_names.
+
+2002-08-04  Ulrich Drepper  <drepper@redhat.com>
+
+       * dcigettext.c: Define _nl_default_dirname_internal as hidden alias
+       and use it.
+       * bindtextdom.c: Use _nl_default_dirname_internal.
+
+2002-08-03  Roland McGrath  <roland@redhat.com>
+
+       * dcigettext.c (guess_category_value): Use __current_locale_name
+       instead of calling setlocale.
+
+2002-08-02  Roland McGrath  <roland@redhat.com>
+
+       * loadmsgcat.c (_nl_init_domain_conv): Use _NL_CURRENT.
+
+2002-07-30  Roland McGrath  <roland@redhat.com>
+
+       * loadmsgcat.c [__GNUC__]: #undef alloca before defining it.
+
+2002-05-01  Ulrich Drepper  <drepper@redhat.com>
+
+       Revert 2002-04-09 change.
+       * dcngettext.c (__dcngettext_internal): Remove alias.
+       * dngettext.c: Use __dcngettext instead of __dcngettext_internal.
+       * ngettext.c: Likewise.
+
 2002-11-07  Bruno Haible  <bruno@clisp.org>
 
        * Makefile.in (mostlyclean): Remove object files on OS/2 as well.
        __argz_stringify.
 
 2002-04-08  Ulrich Drepper  <drepper@redhat.com>
+
        * dcgettext.c (__dcgettext): Use INTDEF to define alias.
        * dgettext.c: Call __dcgettext_internal instead of __dcgettext.
        * gettext.c: Likewise.
index d582ce11d51f4044f1d5198d998046f96a99b1ef..250f5e863b19491cd558804c19fa0e41a5d381ba 100644 (file)
 
 /* Contains the default location of the message catalogs.  */
 extern const char _nl_default_dirname[];
+#ifdef _LIBC
+extern const char _nl_default_dirname_internal[] attribute_hidden;
+#else
+# define INTUSE(name) name
+#endif
 
 /* List with bindings of specific domains.  */
 extern struct binding *_nl_domain_bindings;
@@ -146,8 +151,8 @@ set_binding_values (domainname, dirnamep, codesetp)
              char *result = binding->dirname;
              if (strcmp (dirname, result) != 0)
                {
-                 if (strcmp (dirname, _nl_default_dirname) == 0)
-                   result = (char *) _nl_default_dirname;
+                 if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0)
+                   result = (char *) INTUSE(_nl_default_dirname);
                  else
                    {
 #if defined _LIBC || defined HAVE_STRDUP
@@ -162,7 +167,7 @@ set_binding_values (domainname, dirnamep, codesetp)
 
                  if (__builtin_expect (result != NULL, 1))
                    {
-                     if (binding->dirname != _nl_default_dirname)
+                     if (binding->dirname != INTUSE(_nl_default_dirname))
                        free (binding->dirname);
 
                      binding->dirname = result;
@@ -216,7 +221,7 @@ set_binding_values (domainname, dirnamep, codesetp)
     {
       /* Simply return the default values.  */
       if (dirnamep)
-       *dirnamep = _nl_default_dirname;
+       *dirnamep = INTUSE(_nl_default_dirname);
       if (codesetp)
        *codesetp = NULL;
     }
@@ -238,11 +243,11 @@ set_binding_values (domainname, dirnamep, codesetp)
 
          if (dirname == NULL)
            /* The default value.  */
-           dirname = _nl_default_dirname;
+           dirname = INTUSE(_nl_default_dirname);
          else
            {
-             if (strcmp (dirname, _nl_default_dirname) == 0)
-               dirname = _nl_default_dirname;
+             if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0)
+               dirname = INTUSE(_nl_default_dirname);
              else
                {
                  char *result;
@@ -265,7 +270,7 @@ set_binding_values (domainname, dirnamep, codesetp)
        }
       else
        /* The default value.  */
-       new_binding->dirname = (char *) _nl_default_dirname;
+       new_binding->dirname = (char *) INTUSE(_nl_default_dirname);
 
       new_binding->codeset_cntr = 0;
 
@@ -321,7 +326,7 @@ set_binding_values (domainname, dirnamep, codesetp)
       if (0)
        {
        failed_codeset:
-         if (new_binding->dirname != _nl_default_dirname)
+         if (new_binding->dirname != INTUSE(_nl_default_dirname))
            free (new_binding->dirname);
        failed_dirname:
          free (new_binding);
index f2f01524c03c667818cb752380a7122b470f124d..55aaa060f1c2030d95e541d2ac6ad63af763299c 100644 (file)
@@ -271,6 +271,13 @@ transcmp (p1, p2)
 }
 #endif
 
+#ifndef INTVARDEF
+# define INTVARDEF(name)
+#endif
+#ifndef INTUSE
+# define INTUSE(name) name
+#endif
+
 /* Name of the default domain used for gettext(3) prior any call to
    textdomain(3).  The default value for this is "messages".  */
 const char _nl_default_default_domain[] attribute_hidden = "messages";
@@ -284,6 +291,7 @@ const char *_nl_current_default_domain attribute_hidden
 extern const char _nl_default_dirname[];
 #else
 const char _nl_default_dirname[] = LOCALEDIR;
+INTVARDEF (_nl_default_dirname)
 #endif
 
 /* List with bindings of specific domains created by bindtextdomain()
@@ -296,10 +304,15 @@ static char *plural_lookup PARAMS ((struct loaded_l10nfile *domain,
                                    const char *translation,
                                    size_t translation_len))
      internal_function;
-static const char *category_to_name PARAMS ((int category)) internal_function;
 static const char *guess_category_value PARAMS ((int category,
                                                 const char *categoryname))
      internal_function;
+#ifdef _LIBC
+# include "../locale/localeinfo.h"
+# define category_to_name(category)    _nl_category_names[category]
+#else
+static const char *category_to_name PARAMS ((int category)) internal_function;
+#endif
 
 
 /* For those loosing systems which don't have `alloca' we have to add
@@ -437,6 +450,15 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
   if (msgid1 == NULL)
     return NULL;
 
+#ifdef _LIBC
+  if (category < 0 || category >= __LC_LAST || category == LC_ALL)
+    /* Bogus.  */
+    return (plural == 0
+           ? (char *) msgid1
+           /* Use the Germanic plural rule.  */
+           : n == 1 ? (char *) msgid1 : (char *) msgid2);
+#endif
+
   __libc_rwlock_rdlock (_nl_state_lock);
 
   /* If DOMAINNAME is NULL, we are interested in the default domain.  If
@@ -500,7 +522,7 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
     }
 
   if (binding == NULL)
-    dirname = (char *) _nl_default_dirname;
+    dirname = (char *) INTUSE(_nl_default_dirname);
   else if (IS_ABSOLUTE_PATH (binding->dirname))
     dirname = binding->dirname;
   else
@@ -636,7 +658,6 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
              /* Found the translation of MSGID1 in domain DOMAIN:
                 starting at RETVAL, RETLEN bytes.  */
              FREE_BLOCKS (block_list);
-             __set_errno (saved_errno);
 #if defined HAVE_TSEARCH || defined _LIBC
              if (foundp == NULL)
                {
@@ -675,6 +696,8 @@ DCIGETTEXT (domainname, msgid1, msgid2, plural, n, category)
                  (*foundp)->translation_length = retlen;
                }
 #endif
+             __set_errno (saved_errno);
+
              /* Now deal with plural.  */
              if (plural)
                retval = plural_lookup (domain, n, retval, retlen);
@@ -1038,7 +1061,7 @@ plural_lookup (domain, n, translation, translation_len)
   return (char *) p;
 }
 
-
+#ifndef _LIBC
 /* Return string representation of locale CATEGORY.  */
 static const char *
 internal_function
@@ -1098,6 +1121,7 @@ category_to_name (category)
 
   return retval;
 }
+#endif
 
 /* Guess value of current locale from value of the environment variables.  */
 static const char *
@@ -1120,7 +1144,7 @@ guess_category_value (category, categoryname)
      `LC_xxx', and `LANG'.  On some systems this can be done by the
      `setlocale' function itself.  */
 #ifdef _LIBC
-  retval = setlocale (category, NULL);
+  retval = __current_locale_name (category);
 #else
   retval = _nl_locale_name (category, categoryname);
 #endif
@@ -1170,8 +1194,7 @@ mempcpy (dest, src, n)
 #ifdef _LIBC
 /* If we want to free all resources we have to do some work at
    program's end.  */
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   void *old;
 
@@ -1179,7 +1202,7 @@ free_mem (void)
     {
       struct binding *oldp = _nl_domain_bindings;
       _nl_domain_bindings = _nl_domain_bindings->next;
-      if (oldp->dirname != _nl_default_dirname)
+      if (oldp->dirname != INTUSE(_nl_default_dirname))
        /* Yes, this is a pointer comparison.  */
        free (oldp->dirname);
       free (oldp->codeset);
@@ -1201,6 +1224,4 @@ free_mem (void)
       free (old);
     }
 }
-
-text_set_element (__libc_subfreeres, free_mem);
 #endif
index 17d9ce3e29abf757c8b175382d395b0247fad8c9..3a3404e2cc244af4047791d50b207816e8f8315d 100644 (file)
@@ -56,6 +56,5 @@ DCNGETTEXT (domainname, msgid1, msgid2, n, category)
 
 #ifdef _LIBC
 /* Alias for function name in GNU C Library.  */
-INTDEF(__dcngettext)
 weak_alias (__dcngettext, dcngettext);
 #endif
index 0afbd2e10402221c0c880f8978920952527388be..67fd030f255fc9efc322b5e3db5c050cab46b180 100644 (file)
@@ -37,7 +37,7 @@
    prefix.  So we have to make a difference here.  */
 #ifdef _LIBC
 # define DNGETTEXT __dngettext
-# define DCNGETTEXT INTUSE(__dcngettext)
+# define DCNGETTEXT __dcngettext
 #else
 # define DNGETTEXT libintl_dngettext
 # define DCNGETTEXT libintl_dcngettext
index 2f103d5563659d399ecd330403a794eb7a9826de..d24276442cb19c0038fe48b224744da953abe7de 100644 (file)
@@ -178,8 +178,7 @@ _nl_find_domain (dirname, locale, domainname, domainbinding)
 
 
 #ifdef _LIBC
-static void __attribute__ ((unused))
-free_mem (void)
+libc_freeres_fn (free_mem)
 {
   struct loaded_l10nfile *runp = _nl_loaded_domains;
 
@@ -193,6 +192,4 @@ free_mem (void)
       free (here);
     }
 }
-
-text_set_element (__libc_subfreeres, free_mem);
 #endif
index 516f5211b6405d21af367a86657a4990b2cf231c..a07d9de8a081d9717d2db5fd63bd52d903683e30 100644 (file)
@@ -34,6 +34,7 @@
 #include <sys/stat.h>
 
 #ifdef __GNUC__
+# undef  alloca
 # define alloca __builtin_alloca
 # define HAVE_ALLOCA 1
 #else
@@ -820,7 +821,7 @@ _nl_init_domain_conv (domain_file, domain, domainbinding)
              if (outcharset == NULL || outcharset[0] == '\0')
                {
 # ifdef _LIBC
-                 outcharset = (*_nl_current[LC_CTYPE])->values[_NL_ITEM_INDEX (CODESET)].string;
+                 outcharset = _NL_CURRENT (LC_CTYPE, CODESET);
 # else
 #  if HAVE_ICONV
                  extern const char *locale_charset PARAMS ((void));
index 456e41e37d7b06049ba7cca36b421a28a93736b0..785540307c7824dc8a424d1a9c662355f5337dc4 100644 (file)
@@ -35,6 +35,7 @@
 #include <sys/types.h>
 
 #ifdef __GNUC__
+# undef alloca
 # define alloca __builtin_alloca
 # define HAVE_ALLOCA 1
 #else
@@ -115,10 +116,14 @@ struct alias_map
 };
 
 
-static char *string_space;
+#ifndef _LIBC
+# define libc_freeres_ptr(decl) decl
+#endif
+
+libc_freeres_ptr (static char *string_space);
 static size_t string_space_act;
 static size_t string_space_max;
-static struct alias_map *map;
+libc_freeres_ptr (static struct alias_map *map);
 static size_t nmap;
 static size_t maxmap;
 
@@ -234,8 +239,10 @@ read_alias_file (fname, fname_len)
         a) we are only interested in the first two fields
         b) these fields must be usable as file names and so must not
            be that long
-       */
-      char buf[BUFSIZ];
+        We avoid a multi-kilobyte buffer here since this would use up
+        stack space which we might not have if the program ran out of
+        memory.  */
+      char buf[400];
       char *alias;
       char *value;
       char *cp;
@@ -244,19 +251,6 @@ read_alias_file (fname, fname_len)
        /* EOF reached.  */
        break;
 
-      /* Possibly not the whole line fits into the buffer.  Ignore
-        the rest of the line.  */
-      if (strchr (buf, '\n') == NULL)
-       {
-         char altbuf[BUFSIZ];
-         do
-           if (FGETS (altbuf, sizeof altbuf, fp) == NULL)
-             /* Make sure the inner loop will be left.  The outer loop
-                will exit at the `feof' test.  */
-             break;
-         while (strchr (altbuf, '\n') == NULL);
-       }
-
       cp = buf;
       /* Ignore leading white space.  */
       while (isspace ((unsigned char) cp[0]))
@@ -340,6 +334,14 @@ read_alias_file (fname, fname_len)
              ++added;
            }
        }
+
+      /* Possibly not the whole line fits into the buffer.  Ignore
+        the rest of the line.  */
+      while (strchr (buf, '\n') == NULL)
+       if (FGETS (buf, sizeof buf, fp) == NULL)
+         /* Make sure the inner loop will be left.  The outer loop
+            will exit at the `feof' test.  */
+         break;
     }
 
   /* Should we test for ferror()?  I think we have to silently ignore
@@ -373,19 +375,6 @@ extend_alias_table ()
 }
 
 
-#ifdef _LIBC
-static void __attribute__ ((unused))
-free_mem (void)
-{
-  if (string_space != NULL)
-    free (string_space);
-  if (map != NULL)
-    free (map);
-}
-text_set_element (__libc_subfreeres, free_mem);
-#endif
-
-
 static int
 alias_compare (map1, map2)
      const struct alias_map *map1;
index 69fe1f7479c80faddd098ca86dc987ed419ffc64..17a27f4aa138d1d1b65fbef9c4f4c46c9844a421 100644 (file)
@@ -44,7 +44,7 @@
    prefix.  So we have to make a difference here.  */
 #ifdef _LIBC
 # define NGETTEXT __ngettext
-# define DCNGETTEXT INTUSE(__dcngettext)
+# define DCNGETTEXT __dcngettext
 #else
 # define NGETTEXT libintl_ngettext
 # define DCNGETTEXT libintl_dcngettext