From fdcfdd1896d013cc9e5523bb342c2af735f56329 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Thu, 29 Mar 2018 16:39:05 +0000 Subject: Resolve some code duplication. Minus eight lines of code, no functional change. OK martijn@. --- lib/libc/locale/setlocale.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'lib/libc/locale') 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 * @@ -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 -- cgit v1.2.3