summaryrefslogtreecommitdiff
path: root/fc-query
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-query
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-query')
-rw-r--r--fc-query/fc-query.c40
-rw-r--r--fc-query/fc-query.sgml4
2 files changed, 24 insertions, 20 deletions
diff --git a/fc-query/fc-query.c b/fc-query/fc-query.c
index 2a36bf04..6ea45ea5 100644
--- a/fc-query/fc-query.c
+++ b/fc-query/fc-query.c
@@ -54,7 +54,7 @@
static const struct option longopts[] = {
{"index", 1, 0, 'i'},
{"version", 0, 0, 'V'},
- {"help", 0, 0, '?'},
+ {"help", 0, 0, 'h'},
{NULL,0,0,0},
};
#else
@@ -64,28 +64,30 @@ 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 [-V?] [-i index] [--index index] [--version] [--help] font-file...\n",
+ fprintf (file, "usage: %s [-Vh] [-i index] [--index index] [--version] [--help] font-file...\n",
program);
#else
- fprintf (stderr, "usage: %s [-V?] [-i index] font-file...\n",
+ fprintf (file, "usage: %s [-Vh] [-i index] font-file...\n",
program);
#endif
- fprintf (stderr, "Query font files and print resulting pattern(s)\n");
- fprintf (stderr, "\n");
+ fprintf (file, "Query font files and print resulting pattern(s)\n");
+ fprintf (file, "\n");
#if HAVE_GETOPT_LONG
- fprintf (stderr, " -i, --index INDEX display the INDEX face of each font file only\n");
- fprintf (stderr, " -V, --version display font config version and exit\n");
- fprintf (stderr, " -?, --help display this help and exit\n");
+ fprintf (file, " -i, --index INDEX display the INDEX face of each font file only\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, " -i INDEX (index) display the INDEX face of each font file only\n");
- fprintf (stderr, " -a (all) display unpruned sorted list of matches\n");
- fprintf (stderr, " -V (version) display font config version and exit\n");
- fprintf (stderr, " -? (help) display this help and exit\n");
+ fprintf (file, " -i INDEX (index) display the INDEX face of each font file only\n");
+ fprintf (file, " -a (all) display unpruned sorted list of matches\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
@@ -100,9 +102,9 @@ main (int argc, char **argv)
int c;
#if HAVE_GETOPT_LONG
- while ((c = getopt_long (argc, argv, "i:sVv?", longopts, NULL)) != -1)
+ while ((c = getopt_long (argc, argv, "i:sVvh", longopts, NULL)) != -1)
#else
- while ((c = getopt (argc, argv, "i:asVv?")) != -1)
+ while ((c = getopt (argc, argv, "i:asVvh")) != -1)
#endif
{
switch (c) {
@@ -114,8 +116,10 @@ main (int argc, char **argv)
fprintf (stderr, "fontconfig version %d.%d.%d\n",
FC_MAJOR, FC_MINOR, FC_REVISION);
exit (0);
+ case 'h':
+ usage (argv[0], 0);
default:
- usage (argv[0]);
+ usage (argv[0], 1);
}
}
i = optind;
@@ -124,7 +128,7 @@ main (int argc, char **argv)
#endif
if (i == argc)
- usage (argv[0]);
+ usage (argv[0], 1);
if (!FcInit ())
{
diff --git a/fc-query/fc-query.sgml b/fc-query/fc-query.sgml
index 4a1a5e6a..2c731291 100644
--- a/fc-query/fc-query.sgml
+++ b/fc-query/fc-query.sgml
@@ -62,7 +62,7 @@ manpage.1: manpage.sgml
<cmdsynopsis>
<command>&dhpackage;</command>
- <arg><option>-V?</option></arg>
+ <arg><option>-Vh</option></arg>
<arg><option>--version</option></arg>
<arg><option>--help</option></arg>
<sbr>
@@ -93,7 +93,7 @@ manpage.1: manpage.sgml
<variablelist>
<varlistentry>
- <term><option>-?</option>
+ <term><option>-h</option>
<option>--help</option>
</term>
<listitem>