X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=test%2Ftest_addstr.c;h=ba8a90e5cd82e4e295b75202f5b9bf50af7824ba;hb=f4a8d7509dab16e7abdfb9d484c51116317b159d;hp=2bb1d02f6b18e69c9e7f5cf061d82505e12a2730;hpb=5d8dbcdd9423bf9821db414fd9ec792ccf1f1027;p=ncurses.git diff --git a/test/test_addstr.c b/test/test_addstr.c index 2bb1d02f..ba8a90e5 100644 --- a/test/test_addstr.c +++ b/test/test_addstr.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 2009-2016,2017 Free Software Foundation, Inc. * + * Copyright 2020,2022 Thomas E. Dickey * + * Copyright 2009-2016,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: test_addstr.c,v 1.15 2017/09/06 09:27:34 tom Exp $ + * $Id: test_addstr.c,v 1.20 2022/12/10 22:28:50 tom Exp $ * * Demonstrate the waddstr() and waddch functions. * Thomas Dickey - 2009/9/12 @@ -374,32 +375,36 @@ recursive_test(int level) } static void -usage(void) +usage(int ok) { static const char *tbl[] = { "Usage: test_addstr [options]" ,"" + ,USAGE_COMMON ,"Options:" - ," -f FILE read data from given file" - ," -n NUM limit string-adds to NUM bytes on ^N replay" - ," -m perform wmove/move separately from add-functions" - ," -w use window-parameter even when stdscr would be implied" + ," -f FILE read data from given file" + ," -n NUM limit string-adds to NUM bytes on ^N replay" + ," -m perform wmove/move separately from add-functions" + ," -w use window-parameter even when stdscr would be implied" }; unsigned n; for (n = 0; n < SIZEOF(tbl); ++n) fprintf(stderr, "%s\n", tbl[n]); - ExitProgram(EXIT_FAILURE); + 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; setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "f:mn:w")) != -1) { + while ((ch = getopt(argc, argv, OPTS_COMMON "f:mn:w")) != -1) { switch (ch) { case 'f': init_linedata(optarg); @@ -415,13 +420,16 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) case 'w': w_opt = TRUE; break; + case OPTS_VERSION: + show_version(argv); + ExitProgram(EXIT_SUCCESS); default: - usage(); - break; + usage(ch == OPTS_USAGE); + /* NOTREACHED */ } } if (optind < argc) - usage(); + usage(FALSE); recursive_test(0); endwin();