X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=test%2Fpair_content.c;h=07651807b845add718adcef34b20c7f47f2c49d3;hb=6641601a9dd7f34deeaa978899b3730b27635afb;hp=c0e0e71d62e15b3b999bc1b67430cc797aff85bd;hpb=205ea499dbbceba5201d997fbd8b6b1f7f29bd50;p=ncurses.git diff --git a/test/pair_content.c b/test/pair_content.c index c0e0e71d..07651807 100644 --- a/test/pair_content.c +++ b/test/pair_content.c @@ -26,7 +26,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: pair_content.c,v 1.17 2022/05/28 20:15:06 tom Exp $ + * $Id: pair_content.c,v 1.20 2022/12/04 00:40:11 tom Exp $ */ #define NEED_TIME_H @@ -217,12 +217,13 @@ seconds(struct timeval *mark) #endif static void -usage(void) +usage(int ok) { static const char *msg[] = { "Usage: pair_content [options]" ,"" + ,USAGE_COMMON ,"Options:" ," -f PAIR first color pair to test (default: 1)" ," -i interactive, showing test-progress" @@ -238,26 +239,29 @@ usage(void) size_t n; for (n = 0; n < SIZEOF(msg); n++) fprintf(stderr, "%s\n", msg[n]); - finish(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 i; + int ch; - while ((i = getopt(argc, argv, "f:il:npr:sx")) != -1) { - switch (i) { + while ((ch = getopt(argc, argv, OPTS_COMMON "f:il:npr:sx")) != -1) { + switch (ch) { case 'f': if ((f_opt = atoi(optarg)) <= 0) - usage(); + usage(FALSE); break; case 'i': i_opt = 1; break; case 'l': if ((l_opt = atoi(optarg)) <= 0) - usage(); + usage(FALSE); break; case 'n': n_opt = 1; @@ -267,7 +271,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) break; case 'r': if ((r_opt = atoi(optarg)) <= 0) - usage(); + usage(FALSE); break; case 's': s_opt = 1; @@ -277,17 +281,22 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) x_opt = 1; break; #endif + case OPTS_VERSION: + show_version(argv); + ExitProgram(EXIT_SUCCESS); default: - usage(); + usage(ch == OPTS_USAGE); + /* NOTREACHED */ } } if (optind < argc) - usage(); + usage(FALSE); if (r_opt <= 0) r_opt = 1; setup_test(); if (p_opt) { + int i; endwin(); for (i = f_opt; i < l_opt; ++i) { my_color_t fg, bg;