]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - locale/nl_langinfo_l.c
Add mnw language code [BZ #25139]
[thirdparty/glibc.git] / locale / nl_langinfo_l.c
index 573fed0c4efbaf9e3da3766f3fa5e71c371ca920..61ab5ed45080e6d511c8b532bd8d3b05fddd1471 100644 (file)
@@ -1,5 +1,5 @@
 /* User interface for extracting locale-dependent parameters.
-   Copyright (C) 1995-1997,1999-2002,2005,2007,2010 Free Software Foundation, Inc.
+   Copyright (C) 1995-2019 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
    Lesser General Public License for more details.
 
    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.  */
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
 
 #include <langinfo.h>
 #include <locale.h>
 #include <errno.h>
 #include <stddef.h>
+#include <stdlib.h>
 #include "localeinfo.h"
 
 
 /* Return a string with the data for locale-dependent parameter ITEM.  */
 
 char *
-__nl_langinfo_l (item, l)
-     nl_item item;
-     __locale_t l;
+__nl_langinfo_l (nl_item item, locale_t l)
 {
   int category = _NL_ITEM_CATEGORY (item);
   unsigned int index = _NL_ITEM_INDEX (item);
@@ -44,7 +42,21 @@ __nl_langinfo_l (item, l)
   if (index == _NL_ITEM_INDEX (_NL_LOCALE_NAME (category)))
     return (char *) l->__names[category];
 
+#if defined NL_CURRENT_INDIRECT
+  /* Make direct reference to every _nl_current_CATEGORY symbol,
+     since we know only at runtime which categories are used.  */
+  switch (category)
+    {
+# define DEFINE_CATEGORY(category, category_name, items, a) \
+      case category: data = *_nl_current_##category; break;
+# include "categories.def"
+# undef DEFINE_CATEGORY
+    default:                   /* Should be impossible.  */
+      abort();
+    }
+#else
   data = l->__locales[category];
+#endif
 
   if (index >= data->nstrings)
     /* Bogus index for this category: bogus item.  */