X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Ftest_inwstr.c;h=81ebda776a3820f295355b496df9dfce215eda4e;hp=5bd46c9a310fc5832cff185a5181398f67b99bd1;hb=HEAD;hpb=5e1e572b71ae31a6071daa24e2460a68a6f1003c diff --git a/test/test_inwstr.c b/test/test_inwstr.c index 5bd46c9a..c22add7b 100644 --- a/test/test_inwstr.c +++ b/test/test_inwstr.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 2007-2010,2017 Free Software Foundation, Inc. * + * Copyright 2020,2022 Thomas E. Dickey * + * Copyright 2007-2010,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_inwstr.c,v 1.5 2017/04/15 14:14:48 tom Exp $ + * $Id: test_inwstr.c,v 1.8 2022/12/10 23:56:39 tom Exp $ * * Author: Thomas E Dickey * @@ -231,19 +232,49 @@ recursive_test(int level, char **argv, WINDOW *chrwin, WINDOW *strwin) return TRUE; } +static void +usage(int ok) +{ + static const char *msg[] = + { + "Usage: test_inwstr [options] [file1 [...]]" + ,"" + ,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, char *argv[]) { WINDOW *chrbox; WINDOW *chrwin; WINDOW *strwin; + 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 */ + } + } setlocale(LC_ALL, ""); - if (argc < 2) { - fprintf(stderr, "usage: %s file\n", argv[0]); - return EXIT_FAILURE; - } + if (optind + 1 > argc) + usage(FALSE); initscr(); @@ -254,7 +285,7 @@ main(int argc, char *argv[]) chrwin = derwin(chrbox, 2, COLS - 2, 1, 1); strwin = derwin(chrbox, 2, COLS - 2, 3, 1); - recursive_test(1, argv, chrwin, strwin); + recursive_test(optind, argv, chrwin, strwin); endwin(); ExitProgram(EXIT_SUCCESS);