summaryrefslogtreecommitdiffstats
path: root/usr.bin/locale
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2004-08-02 12:28:28 +0000
committertjr <tjr@FreeBSD.org>2004-08-02 12:28:28 +0000
commit25f68ff9e7c0b5fc234e98abe83b06f2c53bd9cd (patch)
tree41c7927648318aa63bccda158075ce74832853a9 /usr.bin/locale
parent53db7b6142aa2256da46552e18b2be386a1cfc10 (diff)
downloadFreeBSD-src-25f68ff9e7c0b5fc234e98abe83b06f2c53bd9cd.zip
FreeBSD-src-25f68ff9e7c0b5fc234e98abe83b06f2c53bd9cd.tar.gz
Exclude bogus la_LN.* and UTF-8 locales from the output of locale -a
to discourage people from using them.
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 9a1e437..c07d7ca 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);
OpenPOWER on IntegriCloud