aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/locale/setrunelocale.c
diff options
context:
space:
mode:
authorAlexey Zelkin <phantom@FreeBSD.org>2003-06-25 22:42:33 +0000
committerAlexey Zelkin <phantom@FreeBSD.org>2003-06-25 22:42:33 +0000
commitfca2738d67e713599384b8a3faa49ae674d5801c (patch)
tree74ee561a7f7202eb14362249dc2a3ac92f0de6d4 /lib/libc/locale/setrunelocale.c
parent93c847344b3ed2121bfa8b2e630df2699025ce44 (diff)
Reduce code duplication by separating _PathLocle detection code into
internal helper function.
Notes
Notes: svn path=/head/; revision=116847
Diffstat (limited to 'lib/libc/locale/setrunelocale.c')
-rw-r--r--lib/libc/locale/setrunelocale.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/lib/libc/locale/setrunelocale.c b/lib/libc/locale/setrunelocale.c
index cd5384b1c09b..4b1ace4fe186 100644
--- a/lib/libc/locale/setrunelocale.c
+++ b/lib/libc/locale/setrunelocale.c
@@ -95,23 +95,10 @@ setrunelocale(char *encoding)
/*
* Slurp the locale file into the cache.
*/
- if (_PathLocale == NULL) {
- char *p = getenv("PATH_LOCALE");
+ ret = __detect_path_locale();
+ if (ret != 0)
+ return (ret);
- if (p != NULL
-#ifndef __NETBSD_SYSCALLS
- && !issetugid()
-#endif
- ) {
- if (strlen(p) + 1/*"/"*/ + ENCODING_LEN +
- 1/*"/"*/ + CATEGORY_LEN >= PATH_MAX)
- return (ENAMETOOLONG);
- _PathLocale = strdup(p);
- if (_PathLocale == NULL)
- return (errno == 0 ? ENOMEM : errno);
- } else
- _PathLocale = _PATH_LOCALE;
- }
/* Range checking not needed, encoding length already checked above */
(void) strcpy(name, _PathLocale);
(void) strcat(name, "/");