X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=test%2Ftestcurs.c;h=a1dc51acc912be4d57d1742b53eac39de441a8ac;hb=88595a127ec2e56af0875eb04e0f2396d6d121c5;hp=2e01415933e5fee4f51b486c6c6685fd974a1588;hpb=b661daf1160a873609d70843999cd46eff25d1f0;p=ncurses.git diff --git a/test/testcurs.c b/test/testcurs.c index 2e014159..a1dc51ac 100644 --- a/test/testcurs.c +++ b/test/testcurs.c @@ -6,7 +6,7 @@ * wrs(5/28/93) -- modified to be consistent (perform identically) with either * PDCurses or under Unix System V, R4 * - * $Id: testcurs.c,v 1.56 2021/03/27 22:39:50 tom Exp $ + * $Id: testcurs.c,v 1.57 2022/12/10 23:35:36 tom Exp $ */ #include @@ -676,16 +676,48 @@ display_menu(int old_option, int new_option) refresh(); } +static void +usage(int ok) +{ + static const char *msg[] = + { + "Usage: testcurs [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[]) { WINDOW *win; int old_option = (-1); int new_option = 0; bool quit = FALSE; int n; + 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, "");