summaryrefslogtreecommitdiff
path: root/usr.bin/locale
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2004-08-02 12:28:28 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2004-08-02 12:28:28 +0000
commit7cf18ceb88384e0d01be3da5c7fe35fdc0806415 (patch)
tree41c7927648318aa63bccda158075ce74832853a9 /usr.bin/locale
parent9b60f79d2a35287b447a18ea50b1619cac524072 (diff)
downloadsrc-test-7cf18ceb88384e0d01be3da5c7fe35fdc0806415.tar.gz
src-test-7cf18ceb88384e0d01be3da5c7fe35fdc0806415.zip
Exclude bogus la_LN.* and UTF-8 locales from the output of locale -a
to discourage people from using them.
Notes
Notes: svn path=/head/; revision=133013
Diffstat (limited to 'usr.bin/locale')
-rw-r--r--usr.bin/locale/locale.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/usr.bin/locale/locale.c b/usr.bin/locale/locale.c
index 9a1e437e0789b..c07d7ca9b1cc0 100644
--- a/usr.bin/locale/locale.c
+++ b/usr.bin/locale/locale.c
@@ -208,6 +208,9 @@ struct _kwinfo {
};
#define NKWINFO (sizeof(kwinfo)/sizeof(kwinfo[0]))
+const char *boguslocales[] = { "UTF-8", "la_LN." };
+#define NBOGUS (sizeof(boguslocales)/sizeof(boguslocales[0]))
+
int
main(int argc, char *argv[])
{
@@ -373,6 +376,8 @@ init_locales_list(void)
{
DIR *dirp;
struct dirent *dp;
+ size_t i;
+ int bogus;
/* why call this function twice ? */
if (locales != NULL)
@@ -396,7 +401,12 @@ init_locales_list(void)
while ((dp = readdir(dirp)) != NULL) {
if (*(dp->d_name) == '.')
continue; /* exclude "." and ".." */
- sl_add(locales, strdup(dp->d_name));
+ for (bogus = i = 0; i < NBOGUS; i++)
+ if (strncmp(dp->d_name, boguslocales[i],
+ strlen(boguslocales[i])) == 0)
+ bogus = 1;
+ if (!bogus)
+ sl_add(locales, strdup(dp->d_name));
}
closedir(dirp);