X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=test%2Fechochar.c;h=1d9815744b73f28e53621dc64ba9e62763d05dc3;hb=9e084820c3f396f861b2cb74fbd5fc15aa10b6bc;hp=93a4644213af01d46b96bc54fc50178e00eeb646;hpb=02f1dee48fe8af6ce054388fba739aa4f975004e;p=ncurses.git diff --git a/test/echochar.c b/test/echochar.c index 93a46442..1d981574 100644 --- a/test/echochar.c +++ b/test/echochar.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 2006-2017,2019 Free Software Foundation, Inc. * + * Copyright 2019-2020,2022 Thomas E. Dickey * + * Copyright 2006-2014,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -26,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: echochar.c,v 1.20 2019/12/14 23:25:29 tom Exp $ + * $Id: echochar.c,v 1.25 2022/12/10 22:28:50 tom Exp $ * * Demonstrate the echochar function (compare to dots.c). * Thomas Dickey - 2006/11/4 @@ -77,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; @@ -90,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 */ } }