diff options
Diffstat (limited to 'test/echochar.c')
-rw-r--r-- | test/echochar.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/test/echochar.c b/test/echochar.c index ce7f03d385fe..08497069419a 100644 --- a/test/echochar.c +++ b/test/echochar.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019,2020 Thomas E. Dickey * + * Copyright 2019-2022,2023 Thomas E. Dickey * * Copyright 2006-2014,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -27,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: echochar.c,v 1.21 2020/02/02 23:34:34 tom Exp $ + * $Id: echochar.c,v 1.26 2023/05/27 20:13:10 tom Exp $ * * Demonstrate the echochar function (compare to dots.c). * Thomas Dickey - 2006/11/4 @@ -65,7 +65,7 @@ ranf(void) } static void -set_color(char *my_pairs, int fg, int bg) +set_color(const char *const my_pairs, int fg, int bg) { int pair = (fg * COLORS) + bg; if (pair < COLOR_PAIRS) { @@ -78,9 +78,30 @@ set_color(char *my_pairs, int fg, int bg) } } +static void +usage(int ok) +{ + static const char *msg[] = + { + "Usage: echochar" + ,"" + ,USAGE_COMMON + ,"Options:" + ," -r use addch/refresh rather than echochar()" + }; + 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[]) { int ch; double r; @@ -91,14 +112,17 @@ main(int argc GCC_UNUSED, int last_fg = 0; int last_bg = 0; - while ((ch = getopt(argc, argv, "r")) != -1) { + while ((ch = getopt(argc, argv, OPTS_COMMON "r")) != -1) { switch (ch) { case 'r': opt_r = TRUE; break; + case OPTS_VERSION: + show_version(argv); + ExitProgram(EXIT_SUCCESS); default: - fprintf(stderr, "Usage: echochar [-r]\n"); - ExitProgram(EXIT_FAILURE); + usage(ch == OPTS_USAGE); + /* NOTREACHED */ } } |