diff options
author | schwarze <> | 2018-03-29 16:34:25 +0000 |
---|---|---|
committer | schwarze <> | 2018-03-29 16:34:25 +0000 |
commit | 3fe71f438648cc6282b6b7563331849be9671916 (patch) | |
tree | 561b1a1476449dbe2ac2e2b0dd21d33d3bab9fc7 /src | |
parent | 85b83d75a71cd280d1ffd7aa6bbbbb7154a8ffc4 (diff) | |
download | openbsd-3fe71f438648cc6282b6b7563331849be9671916.tar.gz openbsd-3fe71f438648cc6282b6b7563331849be9671916.tar.bz2 openbsd-3fe71f438648cc6282b6b7563331849be9671916.zip |
Fix three bugs in setlocale(3):
1. setlocale(LC_ALL, "A"); setlocale(LC_CTYPE, "T"); setlocale(LC_ALL, NULL);
must return "A/T/A/A/A/A", not "A". Fix this by always initializing the
LC_ALL entry of newgl to "" in dupgl(). Reported by Karl Williamson
<public at khwilliamson dot com> on bugs@, thanks!
2. Do not leak newgl when strdup(3) fails in setlocale(3).
3. For setlocale(LC_ALL, "C/C/fr_FR.UTF-8/C/C/C"); correctly set
_GlobalRuneLocale; i found 2. and 3. while looking at the code.
Feedback on a buggy earlier version and OK martijn@.
Diffstat (limited to 'src')
-rw-r--r-- | src/regress/lib/libc/locale/setlocale/setlocale.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/regress/lib/libc/locale/setlocale/setlocale.c b/src/regress/lib/libc/locale/setlocale/setlocale.c index f2a8427535..82245df5c5 100644 --- a/src/regress/lib/libc/locale/setlocale/setlocale.c +++ b/src/regress/lib/libc/locale/setlocale/setlocale.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: setlocale.c,v 1.3 2017/02/25 07:28:32 jsg Exp $ */ | 1 | /* $OpenBSD: setlocale.c,v 1.4 2018/03/29 16:34:25 schwarze Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2015 Sebastien Marie <semarie@openbsd.org> | 3 | * Copyright (c) 2015 Sebastien Marie <semarie@openbsd.org> |
4 | * | 4 | * |
@@ -75,7 +75,6 @@ main(int argc, char *argv[]) | |||
75 | 75 | ||
76 | /* load from env */ | 76 | /* load from env */ |
77 | /* NOTE: we don't support non-C locales for some categories */ | 77 | /* NOTE: we don't support non-C locales for some categories */ |
78 | /*test_setlocale("fr_FR.UTF-8", LC_ALL, "");*/ /* set */ | ||
79 | test_setlocale("fr_FR.UTF-8", LC_CTYPE, ""); /* set */ | 78 | test_setlocale("fr_FR.UTF-8", LC_CTYPE, ""); /* set */ |
80 | test_setlocale("fr_FR.UTF-8", LC_MESSAGES, ""); /* set */ | 79 | test_setlocale("fr_FR.UTF-8", LC_MESSAGES, ""); /* set */ |
81 | test_MB_CUR_MAX(4); | 80 | test_MB_CUR_MAX(4); |
@@ -113,6 +112,7 @@ main(int argc, char *argv[]) | |||
113 | test_setlocale("C", LC_ALL, "C"); /* reset */ | 112 | test_setlocale("C", LC_ALL, "C"); /* reset */ |
114 | test_setlocale("invalid.UTF-8", LC_CTYPE, "invalid.UTF-8"); /* set */ | 113 | test_setlocale("invalid.UTF-8", LC_CTYPE, "invalid.UTF-8"); /* set */ |
115 | test_setlocale("invalid.UTF-8", LC_CTYPE, NULL); | 114 | test_setlocale("invalid.UTF-8", LC_CTYPE, NULL); |
115 | test_setlocale("C/invalid.UTF-8/C/C/C/C", LC_ALL, NULL); | ||
116 | test_MB_CUR_MAX(4); | 116 | test_MB_CUR_MAX(4); |
117 | 117 | ||
118 | /* with invalid codeset (is an error) */ | 118 | /* with invalid codeset (is an error) */ |