]> git.wh0rd.org - fontconfig.git/blobdiff - fc-list/fc-list.c
Handle -h and --help according to GNU Coding Standards (#17104)
[fontconfig.git] / fc-list / fc-list.c
index 8384f28a1b6a0c1da4f6ab99222aba90aed6c3b7..97baea4ca1a10ebb734ccbd2c515db1a6bdb8469 100644 (file)
@@ -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;