X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fcardfile.c;fp=test%2Fcardfile.c;h=092483b02c00fed29a0b7c797893dab5c9fcbef0;hp=78b659b3ab127b93842c459bca7a47c1739e8c27;hb=6641601a9dd7f34deeaa978899b3730b27635afb;hpb=205ea499dbbceba5201d997fbd8b6b1f7f29bd50 diff --git a/test/cardfile.c b/test/cardfile.c index 78b659b3..092483b0 100644 --- a/test/cardfile.c +++ b/test/cardfile.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2020,2021 Thomas E. Dickey * + * Copyright 2019-2021,2022 Thomas E. Dickey * * Copyright 1999-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -30,7 +30,7 @@ /* * Author: Thomas E. Dickey * - * $Id: cardfile.c,v 1.48 2021/03/20 18:23:14 tom Exp $ + * $Id: cardfile.c,v 1.51 2022/12/04 00:40:11 tom Exp $ * * File format: text beginning in column 1 is a title; other text is content. */ @@ -550,37 +550,45 @@ cardfile(char *fname) } static void -usage(void) +usage(int ok) { static const char *msg[] = { "Usage: cardfile [options] file" ,"" + ,USAGE_COMMON ,"Options:" ," -c use color if terminal supports it" }; size_t 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; setlocale(LC_ALL, ""); - while ((n = getopt(argc, argv, "c")) != -1) { - switch (n) { + while ((ch = getopt(argc, argv, OPTS_COMMON "c")) != -1) { + switch (ch) { case 'c': try_color = TRUE; break; + case OPTS_VERSION: + show_version(argv); + ExitProgram(EXIT_SUCCESS); default: - usage(); + usage(ch == OPTS_USAGE); + /* NOTREACHED */ } } @@ -600,6 +608,7 @@ main(int argc, char *argv[]) } if (optind + 1 == argc) { + int n; for (n = 1; n < argc; n++) read_data(argv[n]); if (count_cards() == 0)