summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorschwarze <schwarze@openbsd.org>2018-03-29 16:39:04 +0000
committerschwarze <schwarze@openbsd.org>2018-03-29 16:39:04 +0000
commit4ec3b33e3d42312c64be7986ee1fa890e4df9743 (patch)
treeb30ba20198d2990b9b235f08b28fab049ee339d4 /lib/libc
parentFix three bugs in setlocale(3): (diff)
downloadwireguard-openbsd-4ec3b33e3d42312c64be7986ee1fa890e4df9743.tar.xz
wireguard-openbsd-4ec3b33e3d42312c64be7986ee1fa890e4df9743.zip
Resolve some code duplication.
Minus eight lines of code, no functional change. OK martijn@.
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/locale/setlocale.c14
1 files changed, 3 insertions, 11 deletions
diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c
index 78e5f0a5388..531f654fd0f 100644
--- a/lib/libc/locale/setlocale.c
+++ b/lib/libc/locale/setlocale.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: setlocale.c,v 1.28 2018/03/29 16:34:25 schwarze Exp $ */
+/* $OpenBSD: setlocale.c,v 1.29 2018/03/29 16:39:04 schwarze Exp $ */
/*
* Copyright (c) 2017 Ingo Schwarze <schwarze@openbsd.org>
*
@@ -138,22 +138,14 @@ setlocale(int category, const char *locname)
goto done;
}
- /* Individual category. */
- if (category > LC_ALL) {
+ /* Individual category, or LC_ALL uniformly set. */
+ if (category > LC_ALL || newgl[LC_ALL][0] != '\0') {
if (strlcpy(global_locname, newgl[category],
sizeof(global_locname)) >= sizeof(global_locname))
global_locname[0] = '\0';
goto done;
}
- /* LC_ALL overrides everything else. */
- if (newgl[LC_ALL][0] != '\0') {
- if (strlcpy(global_locname, newgl[LC_ALL],
- sizeof(global_locname)) >= sizeof(global_locname))
- global_locname[0] = '\0';
- goto done;
- }
-
/*
* Check whether all categories agree and return either
* the single common name for all categories or a string