]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - intl/l10nflist.c
* intl/dcigettext.c (_nl_find_msg): Unlock the conversions_lock
[thirdparty/glibc.git] / intl / l10nflist.c
index 01e7e74956f65786b544c480c483e81e396f94df..2c06a91113b6015088580b8a4c41189222278937 100644 (file)
@@ -1,20 +1,21 @@
-/* Copyright (C) 1995-1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2002, 2004, 2005 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
 
    The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
    The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
 
 /* Tell glibc's <string.h> to provide a prototype for stpcpy().
    This must come before <config.h> because <config.h> may include
 # include <config.h>
 #endif
 
-
-#if defined HAVE_STRING_H || defined _LIBC
-# include <string.h>
-#else
-# include <strings.h>
-# ifndef memcpy
-#  define memcpy(Dst, Src, Num) bcopy (Src, Dst, Num)
-# endif
-#endif
-#if !HAVE_STRCHR && !defined _LIBC
-# ifndef strchr
-#  define strchr index
-# endif
-#endif
+#include <string.h>
 
 #if defined _LIBC || defined HAVE_ARGZ_H
 # include <argz.h>
 #endif
 #include <ctype.h>
 #include <sys/types.h>
-
-#if defined STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
 
 #include "loadinfo.h"
 
@@ -101,6 +86,10 @@ argz_count__ (argz, len)
 }
 # undef __argz_count
 # define __argz_count(argz, len) argz_count__ (argz, len)
+#else
+# ifdef _LIBC
+#  define __argz_count(argz, len) INTUSE(__argz_count) (argz, len)
+# endif
 #endif /* !_LIBC && !HAVE___ARGZ_COUNT */
 
 #if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY
@@ -125,6 +114,11 @@ argz_stringify__ (argz, len, sep)
 }
 # undef __argz_stringify
 # define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
+#else
+# ifdef _LIBC
+#  define __argz_stringify(argz, len, sep) \
+  INTUSE(__argz_stringify) (argz, len, sep)
+# endif
 #endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */
 
 #if !defined _LIBC && !defined HAVE___ARGZ_NEXT
@@ -174,8 +168,8 @@ pop (x)
 \f
 struct loaded_l10nfile *
 _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
-                   territory, codeset, normalized_codeset, modifier, special,
-                   sponsor, revision, filename, do_allocate)
+                   territory, codeset, normalized_codeset, modifier,
+                   filename, do_allocate)
      struct loaded_l10nfile **l10nfile_list;
      const char *dirlist;
      size_t dirlist_len;
@@ -185,9 +179,6 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
      const char *codeset;
      const char *normalized_codeset;
      const char *modifier;
-     const char *special;
-     const char *sponsor;
-     const char *revision;
      const char *filename;
      int do_allocate;
 {
@@ -201,23 +192,14 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
   /* Allocate room for the full file name.  */
   abs_filename = (char *) malloc (dirlist_len
                                  + strlen (language)
-                                 + ((mask & TERRITORY) != 0
+                                 + ((mask & XPG_TERRITORY) != 0
                                     ? strlen (territory) + 1 : 0)
                                  + ((mask & XPG_CODESET) != 0
                                     ? strlen (codeset) + 1 : 0)
                                  + ((mask & XPG_NORM_CODESET) != 0
                                     ? strlen (normalized_codeset) + 1 : 0)
-                                 + (((mask & XPG_MODIFIER) != 0
-                                     || (mask & CEN_AUDIENCE) != 0)
+                                 + ((mask & XPG_MODIFIER) != 0
                                     ? strlen (modifier) + 1 : 0)
-                                 + ((mask & CEN_SPECIAL) != 0
-                                    ? strlen (special) + 1 : 0)
-                                 + (((mask & CEN_SPONSOR) != 0
-                                     || (mask & CEN_REVISION) != 0)
-                                    ? (1 + ((mask & CEN_SPONSOR) != 0
-                                            ? strlen (sponsor) + 1 : 0)
-                                       + ((mask & CEN_REVISION) != 0
-                                          ? strlen (revision) + 1 : 0)) : 0)
                                  + 1 + strlen (filename) + 1);
 
   if (abs_filename == NULL)
@@ -233,7 +215,7 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
   *cp++ = '/';
   cp = stpcpy (cp, language);
 
-  if ((mask & TERRITORY) != 0)
+  if ((mask & XPG_TERRITORY) != 0)
     {
       *cp++ = '_';
       cp = stpcpy (cp, territory);
@@ -248,29 +230,11 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
       *cp++ = '.';
       cp = stpcpy (cp, normalized_codeset);
     }
-  if ((mask & (XPG_MODIFIER | CEN_AUDIENCE)) != 0)
+  if ((mask & XPG_MODIFIER) != 0)
     {
-      /* This component can be part of both syntaces but has different
-        leading characters.  For CEN we use `+', else `@'.  */
-      *cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@';
+      *cp++ = '@';
       cp = stpcpy (cp, modifier);
     }
-  if ((mask & CEN_SPECIAL) != 0)
-    {
-      *cp++ = '+';
-      cp = stpcpy (cp, special);
-    }
-  if ((mask & (CEN_SPONSOR | CEN_REVISION)) != 0)
-    {
-      *cp++ = ',';
-      if ((mask & CEN_SPONSOR) != 0)
-       cp = stpcpy (cp, sponsor);
-      if ((mask & CEN_REVISION) != 0)
-       {
-         *cp++ = '_';
-         cp = stpcpy (cp, revision);
-       }
-    }
 
   *cp++ = '/';
   stpcpy (cp, filename);
@@ -306,9 +270,15 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
                                * (1 << pop (mask))
                                * sizeof (struct loaded_l10nfile *)));
   if (retval == NULL)
-    return NULL;
+    {
+      free (abs_filename);
+      return NULL;
+    }
 
   retval->filename = abs_filename;
+  /* If more than one directory is in the list this is a pseudo-entry
+     which just references others.  We do not try to load data for it,
+     ever.  */
   retval->decided = (__argz_count (dirlist, dirlist_len) != 1
                     || ((mask & XPG_CODESET) != 0
                         && (mask & XPG_NORM_CODESET) != 0));
@@ -331,9 +301,7 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
      of the inner loop.  */
   cnt = __argz_count (dirlist, dirlist_len) == 1 ? mask - 1 : mask;
   for (; cnt >= 0; --cnt)
-    if ((cnt & ~mask) == 0
-       && ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0)
-       && ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0))
+    if ((cnt & ~mask) == 0)
       {
        /* Iterate over all elements of the DIRLIST.  */
        char *dir = NULL;
@@ -343,8 +311,7 @@ _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
          retval->successor[entries++]
            = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1, cnt,
                                  language, territory, codeset,
-                                 normalized_codeset, modifier, special,
-                                 sponsor, revision, filename, 1);
+                                 normalized_codeset, modifier, filename, 1);
       }
   retval->successor[entries] = NULL;
 
@@ -367,11 +334,11 @@ _nl_normalize_codeset (codeset, name_len)
   size_t cnt;
 
   for (cnt = 0; cnt < name_len; ++cnt)
-    if (isalnum (codeset[cnt]))
+    if (isalnum ((unsigned char) codeset[cnt]))
       {
        ++len;
 
-       if (isalpha (codeset[cnt]))
+       if (isalpha ((unsigned char) codeset[cnt]))
          only_digit = 0;
       }
 
@@ -385,9 +352,9 @@ _nl_normalize_codeset (codeset, name_len)
        wp = retval;
 
       for (cnt = 0; cnt < name_len; ++cnt)
-       if (isalpha (codeset[cnt]))
-         *wp++ = _tolower (codeset[cnt]);
-       else if (isdigit (codeset[cnt]))
+       if (isalpha ((unsigned char) codeset[cnt]))
+         *wp++ = tolower ((unsigned char) codeset[cnt]);
+       else if (isdigit ((unsigned char) codeset[cnt]))
          *wp++ = codeset[cnt];
 
       *wp = '\0';