]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/key_names.c
ncurses 6.3 - patch 20221203
[ncurses.git] / test / key_names.c
index 69c95d638db04b8712d0e45e280438399465cf55..fa7fdba631a4b6de0c308f7e4a1f3474b22e7868 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2020 Thomas E. Dickey                                          *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
  * Copyright 2007-2014,2017 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -27,7 +27,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: key_names.c,v 1.8 2020/02/02 23:34:34 tom Exp $
+ * $Id: key_names.c,v 1.11 2022/12/04 00:40:11 tom Exp $
  */
 
 #include <test.priv.h>
 #if USE_WIDEC_SUPPORT
 
 static void
-usage(void)
+usage(int ok)
 {
-    fprintf(stderr, "Usage: key_names [-m] [-s]\n");
-    ExitProgram(EXIT_FAILURE);
+    static const char *msg[] =
+    {
+       "Usage: key_names"
+       ,""
+       ,USAGE_COMMON
+       ,"Options:"
+       ," -m       call meta(TRUE) in initialization"
+       ," -s       call newterm, etc., to complete initialization"
+    };
+    size_t n;
+
+    for (n = 0; n < SIZEOF(msg); n++)
+       fprintf(stderr, "%s\n", msg[n]);
+
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc, char *argv[])
 {
+    int ch;
     int n;
 
     bool do_setup = FALSE;
@@ -51,16 +68,19 @@ main(int argc, char *argv[])
 
     setlocale(LC_ALL, "");
 
-    while ((n = getopt(argc, argv, "ms")) != -1) {
-       switch (n) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "ms")) != -1) {
+       switch (ch) {
        case 'm':
            do_meta = TRUE;
            break;
        case 's':
            do_setup = TRUE;
            break;
+       case OPTS_VERSION:
+           show_version(argv);
+           ExitProgram(EXIT_SUCCESS);
        default:
-           usage();
+           usage(ch == OPTS_USAGE);
            /* NOTREACHED */
        }
     }