From 7cf18ceb88384e0d01be3da5c7fe35fdc0806415 Mon Sep 17 00:00:00 2001 From: "Tim J. Robbins" Date: Mon, 2 Aug 2004 12:28:28 +0000 Subject: [PATCH] Exclude bogus la_LN.* and UTF-8 locales from the output of locale -a to discourage people from using them. --- usr.bin/locale/locale.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/usr.bin/locale/locale.c b/usr.bin/locale/locale.c index 9a1e437e078..c07d7ca9b1c 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);