From ae75a883f2eb312165d1e1f423cea320f3c92ef5 Mon Sep 17 00:00:00 2001 From: Aurelien Jarno Date: Fri, 16 May 2014 00:06:54 +0200 Subject: fix nl_langinfo with static linking (BZ #16915) For static linking the locale code avoids linking code and data for unused categories. However for nl_langinfo we know only at runtime which categories are used, so direct reference to every nl_current_CATEGORY symbol should be done. This was broken by commit bc3e1c127392da88d0c8bf2ae728147982a3d1bc where nl_langinfo_l and nl_langinfo have been merged and some code has been lost in the process. In order to detect locales issues with static linking, compile a version of tst-langinfo with static linking. Note: this is Debian bug#747103 reported by Raphael --- locale/nl_langinfo_l.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'locale') diff --git a/locale/nl_langinfo_l.c b/locale/nl_langinfo_l.c index b9d02aa8b8..2490af4f4e 100644 --- a/locale/nl_langinfo_l.c +++ b/locale/nl_langinfo_l.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "localeinfo.h" @@ -43,7 +44,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. */ -- cgit v1.2.3