diff options
author | phantom <phantom@FreeBSD.org> | 2003-06-25 23:05:11 +0000 |
---|---|---|
committer | phantom <phantom@FreeBSD.org> | 2003-06-25 23:05:11 +0000 |
commit | 3a0952afbd82dda0c03d4f658194fd1503720a44 (patch) | |
tree | c684057a98949a7c28c9b874c69366f41eb14cf7 /usr.bin/locale/locale.c | |
parent | 445694f17f3a6b2909ca0f9fdd8b2d91663feae3 (diff) | |
download | FreeBSD-src-3a0952afbd82dda0c03d4f658194fd1503720a44.zip FreeBSD-src-3a0952afbd82dda0c03d4f658194fd1503720a44.tar.gz |
locale.c:
Use newly added __detect_path_locale() helper to lookup _PathLocale value.
It adds boundary checking for PATH_LOCALE environment variable value and
check for super-user fallback.
Makefile:
Add lib/libc/locale to compiler's include path (for setlocale.h)
Diffstat (limited to 'usr.bin/locale/locale.c')
-rw-r--r-- | usr.bin/locale/locale.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/usr.bin/locale/locale.c b/usr.bin/locale/locale.c index 3a53ff8..c7ebdeb 100644 --- a/usr.bin/locale/locale.c +++ b/usr.bin/locale/locale.c @@ -40,12 +40,12 @@ #include <err.h> #include <locale.h> #include <langinfo.h> -#include <paths.h> /* for _PATH_LOCALE */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stringlist.h> #include <unistd.h> +#include "setlocale.h" /* Local prototypes */ void init_locales_list(void); @@ -320,7 +320,6 @@ init_locales_list(void) { DIR *dirp; struct dirent *dp; - const char *dirname; /* why call this function twice ? */ if (locales != NULL) @@ -332,14 +331,13 @@ init_locales_list(void) err(1, "could not allocate memory"); /* get actual locales directory name */ - dirname = getenv("PATH_LOCALE"); - if (dirname == NULL) - dirname = _PATH_LOCALE; + if (__detect_path_locale() != 0) + err(1, "unable to find locales storage"); /* open locales directory */ - dirp = opendir(dirname); + dirp = opendir(_PathLocale); if (dirp == NULL) - err(1, "could not open directory '%s'", dirname); + err(1, "could not open directory '%s'", _PathLocale); /* scan directory and store its contents except "." and ".." */ while ((dp = readdir(dirp)) != NULL) { |