diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2017-09-20 09:30:25 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2017-09-20 09:30:25 +0000 |
commit | 752eb06ec4f0fbfdbc0673d727ccf50a03a52b3d (patch) | |
tree | d5c80de3bbf13bc149731abe9a65e30b90113a99 /main/musl/0001-add-_NL_LOCALE_NAME-extension-to-nl_langinfo.patch | |
parent | c414927dc363f6d84ee20d51242c615aaf7b74d2 (diff) | |
download | aports-752eb06ec4f0fbfdbc0673d727ccf50a03a52b3d.tar.bz2 aports-752eb06ec4f0fbfdbc0673d727ccf50a03a52b3d.tar.xz |
main/musl: backport patch for _NL_LOCALE_NAME
needed by libidn testsuite
https://github.com/alpinelinux/aports/pull/2320#issuecomment-330380719
Diffstat (limited to 'main/musl/0001-add-_NL_LOCALE_NAME-extension-to-nl_langinfo.patch')
-rw-r--r-- | main/musl/0001-add-_NL_LOCALE_NAME-extension-to-nl_langinfo.patch | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/main/musl/0001-add-_NL_LOCALE_NAME-extension-to-nl_langinfo.patch b/main/musl/0001-add-_NL_LOCALE_NAME-extension-to-nl_langinfo.patch new file mode 100644 index 0000000000..68b941a3aa --- /dev/null +++ b/main/musl/0001-add-_NL_LOCALE_NAME-extension-to-nl_langinfo.patch @@ -0,0 +1,59 @@ +From 947d330f68c49680dcc54439f56da2a297228962 Mon Sep 17 00:00:00 2001 +From: Rich Felker <dalias@aerifal.cx> +Date: Mon, 31 Jul 2017 23:08:27 -0400 +Subject: [PATCH] add _NL_LOCALE_NAME extension to nl_langinfo + +since setlocale(cat, NULL) is required to return the setting for the +global locale, there is no standard mechanism to obtain the name of +the currently active thread-local locale set by uselocale. this makes +it impossible for application/library software to load appropriate +translations, etc. unless using the gettext implementation provided by +libc, which has privileged access to libc internals. + +to fill this gap, glibc introduced the _NL_LOCALE_NAME macro which can +be used with nl_langinfo to obtain the name. GNU gettext/gnulib code +already use this functionality on glibc, and can easily be adapted to +make use of it on non-glibc systems if it's available; for other +systems they poke at locale implementation internals, which we want to +avoid. this patch provides a compatible interface to the one glibc +introduced. +--- + include/langinfo.h | 6 ++++++ + src/locale/langinfo.c | 4 ++++ + 2 files changed, 10 insertions(+) + +diff --git a/include/langinfo.h b/include/langinfo.h +index 2153c42e..519c0612 100644 +--- a/include/langinfo.h ++++ b/include/langinfo.h +@@ -77,6 +77,12 @@ extern "C" { + #define YESEXPR 0x50000 + #define NOEXPR 0x50001 + ++#define _NL_LOCALE_NAME(cat) (((cat)<<16) | 0xffff) ++ ++#if defined(_GNU_SOURCE) ++#define NL_LOCALE_NAME(cat) _NL_LOCALE_NAME(cat) ++#endif ++ + #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) + #define YESSTR 0x50002 + #define NOSTR 0x50003 +diff --git a/src/locale/langinfo.c b/src/locale/langinfo.c +index b2c8569e..b16caf44 100644 +--- a/src/locale/langinfo.c ++++ b/src/locale/langinfo.c +@@ -34,6 +34,10 @@ char *__nl_langinfo_l(nl_item item, locale_t loc) + const char *str; + + if (item == CODESET) return MB_CUR_MAX==1 ? "ASCII" : "UTF-8"; ++ ++ /* _NL_LOCALE_NAME extension */ ++ if (idx == 65535 && cat < LC_ALL) ++ return loc->cat[cat] ? (char *)loc->cat[cat]->name : "C"; + + switch (cat) { + case LC_NUMERIC: +-- +2.14.1 + |