diff options
-rw-r--r-- | usr.bin/locale/locale.1 | 6 | ||||
-rw-r--r-- | usr.bin/locale/locale.c | 31 |
2 files changed, 24 insertions, 13 deletions
diff --git a/usr.bin/locale/locale.1 b/usr.bin/locale/locale.1 index 144f280..6e6bf29 100644 --- a/usr.bin/locale/locale.1 +++ b/usr.bin/locale/locale.1 @@ -40,7 +40,7 @@ .Op Ar prefix .Nm .Op Fl ck -.Ar keyword ... +.Op Ar keyword ... .Sh DESCRIPTION The .Nm @@ -74,8 +74,12 @@ directory. Print names of all available charmaps. .It Fl k Print the names and values of all selected keywords. +If no keywords are selected, print the names and values of all defined +keywords. .It Fl c Print the category name for all selected keywords. +If no keywords are selected, print the category name for all defined +keywords. .El .Sh IMPLEMENTATION NOTES The special diff --git a/usr.bin/locale/locale.c b/usr.bin/locale/locale.c index cad3afe..df45f7f 100644 --- a/usr.bin/locale/locale.c +++ b/usr.bin/locale/locale.c @@ -253,12 +253,10 @@ main(int argc, char *argv[]) /* validate arguments */ if (all_locales && all_charmaps) usage(); - if ((all_locales || all_charmaps) && argc > 0) + if ((all_locales || all_charmaps) && argc > 0) usage(); if ((all_locales || all_charmaps) && (prt_categories || prt_keywords)) usage(); - if ((prt_categories || prt_keywords) && argc <= 0) - usage(); /* process '-a' */ if (all_locales) { @@ -282,13 +280,19 @@ main(int argc, char *argv[]) } /* process '-c' and/or '-k' */ - if (prt_categories || prt_keywords || argc > 0) { - setlocale(LC_ALL, ""); - while (argc > 0) { - showdetails(*argv); - argv++; - argc--; - } + if (prt_categories || prt_keywords) { + if (argc > 0) { + setlocale(LC_ALL, ""); + while (argc > 0) { + showdetails(*argv); + argv++; + argc--; + } + } else { + uint i; + for (i = 0; i < sizeof (kwinfo) / sizeof (struct _kwinfo); i++) + showdetails ((char *)kwinfo [i].name); + } exit(0); } @@ -303,7 +307,7 @@ usage(void) { printf("Usage: locale [ -a | -m ]\n" " locale -k list [prefix]\n" - " locale [ -ck ] keyword ...\n"); + " locale [ -ck ] [keyword ...]\n"); exit(1); } @@ -612,7 +616,10 @@ showdetails(char *kw) } if (prt_categories) { - printf("%s\n", lookup_localecat(cat)); + if (prt_keywords) + printf("%-20s ", lookup_localecat(cat)); + else + printf("%-20s\t%s\n", kw, lookup_localecat(cat)); } if (prt_keywords) { |