aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/0002-fix-nl_langinfo_l-CODESET-loc-reporting-wrong-locale.patch
blob: 2023daf26a2600a78aa93fbb5818b1032bdf449b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
From 0cf50581ec5f04feeaa77f2eb8b734a4b69ca8ed Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Wed, 7 Mar 2018 11:22:38 -0500
Subject: [PATCH] fix nl_langinfo_l(CODESET, loc) reporting wrong locale's
 value

use of MB_CUR_MAX encoded a hidden dependency on the currently active
locale for the calling thread, whereas nl_langinfo_l is supposed to
report for the locale passed as an argument.
---
 src/locale/langinfo.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/locale/langinfo.c b/src/locale/langinfo.c
index b16caf44..83be6433 100644
--- a/src/locale/langinfo.c
+++ b/src/locale/langinfo.c
@@ -33,7 +33,7 @@ char *__nl_langinfo_l(nl_item item, locale_t loc)
 	int idx = item & 65535;
 	const char *str;
 
-	if (item == CODESET) return MB_CUR_MAX==1 ? "ASCII" : "UTF-8";
+	if (item == CODESET) return loc->cat[LC_CTYPE] ? "UTF-8" : "ASCII";
 
 	/* _NL_LOCALE_NAME extension */
 	if (idx == 65535 && cat < LC_ALL)
-- 
2.16.2