aboutsummaryrefslogtreecommitdiff
path: root/test/testaddch.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/testaddch.c')
-rw-r--r--test/testaddch.c42
1 files changed, 37 insertions, 5 deletions
diff --git a/test/testaddch.c b/test/testaddch.c
index 875c8be7129c..e393c3cc5190 100644
--- a/test/testaddch.c
+++ b/test/testaddch.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * 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 *
@@ -30,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.13 2020/02/02 23:34:34 tom Exp $
+ * $Id: testaddch.c,v 1.15 2022/12/10 23:44:18 tom Exp $
*/
#include <test.priv.h>
@@ -41,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, "");