aboutsummaryrefslogtreecommitdiff
path: root/test/test_get_wstr.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_get_wstr.c')
-rw-r--r--test/test_get_wstr.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/test/test_get_wstr.c b/test/test_get_wstr.c
index bc86030c12c4..2a788fce8dfa 100644
--- a/test/test_get_wstr.c
+++ b/test/test_get_wstr.c
@@ -1,5 +1,5 @@
/****************************************************************************
- * Copyright 2020 Thomas E. Dickey *
+ * Copyright 2020,2022 Thomas E. Dickey *
* Copyright 2007-2011,2017 Free Software Foundation, Inc. *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
@@ -27,7 +27,7 @@
* authorization. *
****************************************************************************/
/*
- * $Id: test_get_wstr.c,v 1.12 2020/02/02 23:34:34 tom Exp $
+ * $Id: test_get_wstr.c,v 1.14 2022/12/10 23:59:13 tom Exp $
*
* Author: Thomas E Dickey
*
@@ -355,18 +355,48 @@ recursive_test(int level, char **argv, WINDOW *strwin)
return TRUE;
}
+static void
+usage(int ok)
+{
+ static const char *msg[] =
+ {
+ "Usage: test_get_wstr [options] [file1 [...]]"
+ ,""
+ ,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, char *argv[])
{
WINDOW *chrbox;
WINDOW *strwin;
+ 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 */
+ }
+ }
setlocale(LC_ALL, "");
- if (argc < 2) {
- fprintf(stderr, "usage: %s file\n", argv[0]);
- return EXIT_FAILURE;
- }
+ if (optind + 1 > argc)
+ usage(FALSE);
initscr();
@@ -376,7 +406,7 @@ main(int argc, char *argv[])
strwin = derwin(chrbox, 4, COLS - 2, 1, 1);
- recursive_test(1, argv, strwin);
+ recursive_test(optind, argv, strwin);
endwin();
ExitProgram(EXIT_SUCCESS);