diff options
author | grog <grog@FreeBSD.org> | 2012-11-08 02:55:30 +0000 |
---|---|---|
committer | grog <grog@FreeBSD.org> | 2012-11-08 02:55:30 +0000 |
commit | ab4526dbe850d9bcf55f30ff75175aeea62da778 (patch) | |
tree | bf002c0bf1d083c6f331d4277e6ea3d0484431e5 /usr.bin | |
parent | 8af663c65db48078492379d8dc6a7d55934ea502 (diff) | |
download | FreeBSD-src-ab4526dbe850d9bcf55f30ff75175aeea62da778.zip FreeBSD-src-ab4526dbe850d9bcf55f30ff75175aeea62da778.tar.gz |
Make parameters to -c and -k options optional. If no parameters are
supplied, print information for all keywords.
Improve output of -c option, in particular in conjunction with -k
option.
MFC after: 14 days
Diffstat (limited to 'usr.bin')
-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) { |