summaryrefslogtreecommitdiff
path: root/fc-list
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2008-08-22 16:51:33 -0400
committerBehdad Esfahbod <behdad@behdad.org>2009-02-13 16:53:59 -0800
commit1439c8f21af1533a920b54333f79459f456a402e (patch)
treea7898c1fe4dbd026f85a2308a2672c49192dce8a /fc-list
parentdf243f93be4306e788aebf6b2ac4a7c1b97550ae (diff)
Handle -h and --help according to GNU Coding Standards (#17104)
Added -h instead of -?. And upon -h and --help, write usave to stdout instead of stdin, and return 0 instead of 1. -? still works like before as that's what getopt returns upon unknown arguments.
Diffstat (limited to 'fc-list')
-rw-r--r--fc-list/fc-list.c36
-rw-r--r--fc-list/fc-list.sgml4
2 files changed, 22 insertions, 18 deletions
diff --git a/fc-list/fc-list.c b/fc-list/fc-list.c
index 8384f28..97baea4 100644
--- a/fc-list/fc-list.c
+++ b/fc-list/fc-list.c
@@ -49,7 +49,7 @@
const struct option longopts[] = {
{"version", 0, 0, 'V'},
{"verbose", 0, 0, 'v'},
- {"help", 0, 0, '?'},
+ {"help", 0, 0, 'h'},
{NULL,0,0,0},
};
#else
@@ -59,27 +59,29 @@ extern int optind, opterr, optopt;
#endif
#endif
-static void usage (char *program)
+static void
+usage (char *program, int error)
{
+ FILE *file = error ? stderr : stdout;
#if HAVE_GETOPT_LONG
- fprintf (stderr, "usage: %s [-vV?] [--verbose] [--version] [--help] [pattern] {element ...} \n",
+ fprintf (file, "usage: %s [-vVh] [--verbose] [--version] [--help] [pattern] {element ...} \n",
program);
#else
- fprintf (stderr, "usage: %s [-vV?] [pattern] {element ...} \n",
+ fprintf (file, "usage: %s [-vVh] [pattern] {element ...} \n",
program);
#endif
- fprintf (stderr, "List fonts matching [pattern]\n");
- fprintf (stderr, "\n");
+ fprintf (file, "List fonts matching [pattern]\n");
+ fprintf (file, "\n");
#if HAVE_GETOPT_LONG
- fprintf (stderr, " -v, --verbose display entire font pattern\n");
- fprintf (stderr, " -V, --version display font config version and exit\n");
- fprintf (stderr, " -?, --help display this help and exit\n");
+ fprintf (file, " -v, --verbose display entire font pattern\n");
+ fprintf (file, " -V, --version display font config version and exit\n");
+ fprintf (file, " -h, --help display this help and exit\n");
#else
- fprintf (stderr, " -v (verbose) display entire font pattern\n");
- fprintf (stderr, " -V (version) display font config version and exit\n");
- fprintf (stderr, " -? (help) display this help and exit\n");
+ fprintf (file, " -v (verbose) display entire font pattern\n");
+ fprintf (file, " -V (version) display font config version and exit\n");
+ fprintf (file, " -h (help) display this help and exit\n");
#endif
- exit (1);
+ exit (error);
}
int
@@ -94,9 +96,9 @@ main (int argc, char **argv)
int c;
#if HAVE_GETOPT_LONG
- while ((c = getopt_long (argc, argv, "Vv?", longopts, NULL)) != -1)
+ while ((c = getopt_long (argc, argv, "Vvh", longopts, NULL)) != -1)
#else
- while ((c = getopt (argc, argv, "Vv?")) != -1)
+ while ((c = getopt (argc, argv, "Vvh")) != -1)
#endif
{
switch (c) {
@@ -107,8 +109,10 @@ main (int argc, char **argv)
case 'v':
verbose = 1;
break;
+ case 'h':
+ usage (argv[0], 0);
default:
- usage (argv[0]);
+ usage (argv[0], 1);
}
}
i = optind;
diff --git a/fc-list/fc-list.sgml b/fc-list/fc-list.sgml
index f4a3147..35bf899 100644
--- a/fc-list/fc-list.sgml
+++ b/fc-list/fc-list.sgml
@@ -63,7 +63,7 @@ manpage.1: manpage.sgml
<cmdsynopsis>
<command>&dhpackage;</command>
- <arg><option>-vV?</option></arg>
+ <arg><option>-vVh</option></arg>
<arg><option>--verbose</option></arg>
<arg><option>--version</option></arg>
<arg><option>--help</option></arg>
@@ -100,7 +100,7 @@ manpage.1: manpage.sgml
</listitem>
</varlistentry>
<varlistentry>
- <term><option>-?</option>
+ <term><option>-h</option>
<option>--help</option>
</term>
<listitem>