summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2018-03-29 16:39:05 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2018-03-29 16:39:05 +0000
commitfdcfdd1896d013cc9e5523bb342c2af735f56329 (patch)
treeb91b8628aa122628e04c6332b8d9769f7cc4cb53
parent60b27984831bf631acbbdba0838df8161809358c (diff)
Resolve some code duplication.
Minus eight lines of code, no functional change. OK martijn@.
-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