]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/combine.c
ncurses 6.3 - patch 20221203
[ncurses.git] / test / combine.c
index 7bc909745a2a5c2144b4e003878a6d798aaf8a0f..d2c3caf935369300aafc41c20a7ad752444db4ea 100644 (file)
@@ -26,7 +26,7 @@
  * authorization.                                                           *
  ****************************************************************************/
 /*
- * $Id: combine.c,v 1.19 2022/05/21 23:19:31 tom Exp $
+ * $Id: combine.c,v 1.22 2022/12/04 00:40:11 tom Exp $
  */
 
 #include <test.priv.h>
@@ -181,52 +181,59 @@ show_help(WINDOW *current)
 }
 
 static void
-usage(void)
+usage(int ok)
 {
     static const char *msg[] =
     {
-       "Usage: combine [options]",
-       "",
-       "Demonstrate combining-characters.",
-       "",
-       "Options:",
-       " -c       use cchar_t data rather than wchar_t string",
-       " -l FILE  log window-dumps to this file",
-       " -r       draw even-numbered rows in reverse-video",
+       "Usage: combine [options]"
+       ,""
+       ,USAGE_COMMON
+       ,"Demonstrate combining-characters."
+       ,""
+       ,"Options:"
+       ," -c       use cchar_t data rather than wchar_t string"
+       ," -l FILE  log window-dumps to this file"
+       ," -r       draw even-numbered rows in reverse-video"
     };
     unsigned n;
     for (n = 0; n < SIZEOF(msg); ++n) {
        fprintf(stderr, "%s\n", msg[n]);
     }
-    ExitProgram(EXIT_FAILURE);
+    ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE);
 }
+/* *INDENT-OFF* */
+VERSION_COMMON()
+/* *INDENT-ON* */
 
 int
 main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED)
 {
-    int n;
+    int ch;
     int left_at = ' ';
     int over_it = 0;
     bool done = FALSE;
     bool log_option = FALSE;
     const char *dump_log = "combine.log";
 
-    while ((n = getopt(argc, argv, "cl:r")) != -1) {
-       switch (n) {
+    while ((ch = getopt(argc, argv, OPTS_COMMON "cl:r")) != -1) {
+       switch (ch) {
        case 'c':
            c_opt = TRUE;
            break;
        case 'l':
            log_option = TRUE;
            if (!open_dump(optarg))
-               usage();
+               usage(FALSE);
            break;
        case 'r':
            r_opt = TRUE;
            break;
+       case OPTS_VERSION:
+           show_version(argv);
+           ExitProgram(EXIT_SUCCESS);
        default:
-           usage();
-           break;
+           usage(ch == OPTS_USAGE);
+           /* NOTREACHED */
        }
     }