about summary refs log tree commit diff
path: root/locale
diff options
context:
space:
mode:
Diffstat (limited to 'locale')
-rw-r--r--locale/lc-collate.c12
-rw-r--r--locale/loadlocale.c10
-rw-r--r--locale/localeinfo.h4
-rw-r--r--locale/nl_langinfo.c16
-rw-r--r--locale/setlocale.c13
5 files changed, 25 insertions, 30 deletions
diff --git a/locale/lc-collate.c b/locale/lc-collate.c
index 7052db3062..4376286812 100644
--- a/locale/lc-collate.c
+++ b/locale/lc-collate.c
@@ -1,5 +1,5 @@
 /* Define current locale data for LC_COLLATE category.
-   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -28,12 +28,12 @@ extern const u_int32_t _nl_C_LC_COLLATE_symbol_classes[];
 
 _NL_CURRENT_DEFINE (LC_COLLATE);
 
-const u_int32_t *__collate_table = NULL;
-const u_int32_t *__collate_extra = NULL;
+const u_int32_t *__collate_table;
+const u_int32_t *__collate_extra;
 
-const u_int32_t *__collate_element_hash = NULL;
-const char *__collate_element_strings = NULL;
-const wchar_t *__collate_element_values = NULL;
+const u_int32_t *__collate_element_hash;
+const char *__collate_element_strings;
+const wchar_t *__collate_element_values;
 
 const u_int32_t *__collate_symbol_hash = _nl_C_LC_COLLATE_symbol_hash;
 const char *__collate_symbol_strings = _nl_C_LC_COLLATE_symbol_strings;
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index c762b77ed1..24d0c3a67d 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -97,13 +97,17 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
       /* LOCALE/LC_foo is a directory; open LOCALE/LC_foo/SYS_LC_foo
            instead.  */
       char *newp;
+      size_t filenamelen;
 
       __close (fd);
 
-      newp = (char *) alloca (strlen (file->filename)
+      filenamelen = strlen (file->filename);
+      newp = (char *) alloca (filenamelen
 			      + 5 + _nl_category_name_sizes[category] + 1);
-      __stpcpy (__stpcpy (__stpcpy (newp, file->filename), "/SYS_"),
-		_nl_category_names[category]);
+      __mempcpy (__mempcpy (__mempcpy (newp, file->filename, filenamelen),
+			    "/SYS_", 5),
+		 _nl_category_names[category],
+		 _nl_category_name_sizes[category] + 1);
 
       fd = __open (newp, O_RDONLY);
       if (fd < 0)
diff --git a/locale/localeinfo.h b/locale/localeinfo.h
index f50565c54a..9f58a743c8 100644
--- a/locale/localeinfo.h
+++ b/locale/localeinfo.h
@@ -1,5 +1,5 @@
 /* localeinfo.h -- declarations for internal libc locale interfaces
-   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -104,7 +104,7 @@ extern struct locale_data *_nl_current_##category;
 #include "categories.def"
 #undef	DEFINE_CATEGORY
 
-extern const char *const _nl_category_names[LC_ALL + 1];
+extern const char _nl_category_names[LC_ALL + 1][12];
 extern const size_t _nl_category_name_sizes[LC_ALL + 1];
 extern struct locale_data * *const _nl_current[LC_ALL + 1];
 
diff --git a/locale/nl_langinfo.c b/locale/nl_langinfo.c
index df2b3e9fb9..4c8e6285d3 100644
--- a/locale/nl_langinfo.c
+++ b/locale/nl_langinfo.c
@@ -1,5 +1,5 @@
 /* User interface for extracting locale-dependent parameters.
-   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -22,18 +22,6 @@
 #include <stddef.h>
 #include "localeinfo.h"
 
-/* This array duplicates `_nl_current' defined in setlocale.c; but since
-   the references here are not weak references, this guarantees that the
-   data for all the categories will be linked in.  */
-
-static struct locale_data * *const nldata[] =
-{
-#define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
-  [category] = &_nl_current_##category,
-#include "categories.def"
-#undef	DEFINE_CATEGORY
-};
-
 
 /* Return a string with the data for locale-dependent parameter ITEM.  */
 
@@ -52,7 +40,7 @@ nl_langinfo (item)
       return NULL;
     }
 
-  data = *nldata[category];
+  data = *_nl_current[category];
 
   if (index >= data->nstrings)
     {
diff --git a/locale/setlocale.c b/locale/setlocale.c
index dee83d7fb4..1bcc4d5375 100644
--- a/locale/setlocale.c
+++ b/locale/setlocale.c
@@ -40,9 +40,8 @@ extern struct locale_data _nl_C_##category;
 #include "categories.def"
 #undef	DEFINE_CATEGORY
 
-/* Array indexed by category of pointers to _nl_current_CATEGORY slots.
-   Elements are zero for categories whose data is never used.  */
-static struct locale_data * *const _nl_current[] =
+/* Array indexed by category of pointers to _nl_current_CATEGORY slots.  */
+struct locale_data * *const _nl_current[] =
   {
 #define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
     [category] = &_nl_current_##category,
@@ -65,8 +64,12 @@ struct locale_data *const _nl_C[] =
 
 
 /* Define an array of category names (also the environment variable names),
-   indexed by integral category.  */
-const char *const _nl_category_names[] =
+   indexed by integral category.
+
+   We have entries of fixed width (12 for now) do avoid an array of
+   pointers.  Update the size of the outer array if new, longer locale
+   names are introduced.  */
+const char _nl_category_names[][12] =
   {
 #define DEFINE_CATEGORY(category, category_name, items, a, b, c, d) \
     [category] = category_name,