]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - test/testaddch.c
ncurses 6.4 - patch 20240420
[ncurses.git] / test / testaddch.c
index d39109894173ddb95f9749ba81cf9e6cff7b05dd..e393c3cc5190504be93d0f5d49380eabd2403bb8 100644 (file)
@@ -1,5 +1,6 @@
 /****************************************************************************
- * Copyright (c) 1998-2013,2014 Free Software Foundation, Inc.              *
+ * Copyright 2020,2022 Thomas E. Dickey                                     *
+ * Copyright 1998-2013,2014 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,7 +30,7 @@
  * This is an example written by Alexander V. Lukyanov <lav@yars.free.net>,
  * to demonstrate an inconsistency between ncurses and SVr4 curses.
  *
- * $Id: testaddch.c,v 1.10 2014/07/27 00:24:49 tom Exp $
+ * $Id: testaddch.c,v 1.15 2022/12/10 23:44:18 tom Exp $
  */
 #include <test.priv.h>
 
@@ -40,13 +41,45 @@ attr_addstr(const char *s, chtype a)
        addch(((unsigned char) (*s++)) | a);
 }
 
+static void
+usage(int ok)
+{
+    static const char *msg[] =
+    {
+       "Usage: testaddch [options]"
+       ,""
+       ,USAGE_COMMON
+    };
+    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 GCC_UNUSED,
-       char *argv[]GCC_UNUSED)
+main(int argc, char *argv[])
 {
     unsigned i;
     chtype back, set, attr;
+    int ch;
+
+    while ((ch = getopt(argc, argv, OPTS_COMMON)) != -1) {
+       switch (ch) {
+       case OPTS_VERSION:
+           show_version(argv);
+           ExitProgram(EXIT_SUCCESS);
+       default:
+           usage(ch == OPTS_USAGE);
+           /* NOTREACHED */
+       }
+    }
+    if (optind < argc)
+       usage(FALSE);
 
     setlocale(LC_ALL, "");
 
@@ -66,7 +99,7 @@ main(
        attr = (chtype) ((i & 4) ? COLOR_PAIR(4) : 0);
 
        bkgdset(back);
-       (void) attrset(set);
+       (void) attrset(AttrArg(set, 0));
 
        attr_addstr("Test string with spaces ->   <-\n", attr);
     }
@@ -77,7 +110,7 @@ main(
        attr = (chtype) ((i & 4) ? (chtype) COLOR_PAIR(4) : 0);
 
        bkgdset(back);
-       (void) attrset(set);
+       (void) attrset(AttrArg(set, 0));
 
        attr_addstr("Test string with spaces ->   <-\n", attr);
     }