X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Ftest_arrays.c;h=7ee25eab59bb9fdef991924e09056922c01f79c3;hp=117c249e1d50c107cd9744c22c845a51e31f8571;hb=HEAD;hpb=93ed44d781ca36f55021e0ad55f1ce33de62f7ba diff --git a/test/test_arrays.c b/test/test_arrays.c index 117c249e..f89cb280 100644 --- a/test/test_arrays.c +++ b/test/test_arrays.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 2007-2008,2010 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_arrays.c,v 1.7 2017/09/20 00:21:22 tom Exp $ + * $Id: test_arrays.c,v 1.13 2022/12/10 23:23:27 tom Exp $ * * Author: Thomas E Dickey * @@ -134,37 +135,41 @@ dump_table(void) } static void -usage(void) +usage(int ok) { static const char *msg[] = { - "Usage: test_arrays [options]", - "", - "If no options are given, print all (boolean, numeric, string)", - "capability names showing their index within the tables.", - "", - "Options:", - " -C print termcap names", - " -T print terminfo names", - " -c print termcap names", - " -f print full terminfo names", - " -n print short terminfo names", - " -t print the result as CSV table", + "Usage: test_arrays [options]" + ,"" + ,"If no options are given, print all (boolean, numeric, string)" + ,"capability names showing their index within the tables." + ,"" + ,USAGE_COMMON + ,"Options:" + ," -C print termcap names" + ," -T print terminfo names" + ," -c print termcap names" + ," -f print full terminfo names" + ," -n print short terminfo names" + ," -t print the result as CSV table" }; unsigned n; for (n = 0; n < SIZEOF(msg); ++n) { fprintf(stderr, "%s\n", msg[n]); } - ExitProgram(EXIT_FAILURE); + ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE); } +/* *INDENT-OFF* */ +VERSION_COMMON() +/* *INDENT-ON* */ int main(int argc, char *argv[]) { - int n; + int ch; - while ((n = getopt(argc, argv, "CTcfnt")) != -1) { - switch (n) { + while ((ch = getopt(argc, argv, OPTS_COMMON "CTcfnt")) != -1) { + switch (ch) { case 'C': opt_C = TRUE; break; @@ -183,13 +188,16 @@ main(int argc, char *argv[]) case 't': opt_t = TRUE; break; + case OPTS_VERSION: + show_version(argv); + ExitProgram(EXIT_SUCCESS); default: - usage(); + usage(ch == OPTS_USAGE); /* NOTREACHED */ } } if (optind < argc) - usage(); + usage(FALSE); if (!(opt_T || opt_C)) { opt_T = opt_C = TRUE; @@ -209,7 +217,7 @@ main(int argc, char *argv[]) #else int -main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) +main(void) { printf("This program requires the terminfo arrays\n"); ExitProgram(EXIT_FAILURE); @@ -217,7 +225,7 @@ main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) #endif #else /* !HAVE_TIGETSTR */ int -main(int argc GCC_UNUSED, char *argv[]GCC_UNUSED) +main(void) { printf("This program requires the terminfo functions such as tigetstr\n"); ExitProgram(EXIT_FAILURE);