X-Git-Url: https://ncurses.scripts.mit.edu/?a=blobdiff_plain;f=test%2Fdemo_menus.c;h=7b0bf30316e558f6aa6b88559feb6b3e092b1548;hb=382c1d0c3c8959d2e5ffb69e86469d00937aa4ae;hp=e0e4852ec92f5a25d7eebc4cf295cb2c666ef62a;hpb=1ddfa997c0965852dbdc738aa6d92c0cd0975f3b;p=ncurses.git diff --git a/test/demo_menus.c b/test/demo_menus.c index e0e4852e..7b0bf303 100644 --- a/test/demo_menus.c +++ b/test/demo_menus.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2019-2021,2022 Thomas E. Dickey * + * Copyright 2019-2022,2023 Thomas E. Dickey * * Copyright 2003-2016,2017 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * @@ -27,7 +27,7 @@ * authorization. * ****************************************************************************/ /* - * $Id: demo_menus.c,v 1.76 2022/05/15 13:54:48 tom Exp $ + * $Id: demo_menus.c,v 1.80 2023/05/27 20:13:10 tom Exp $ * * Demonstrate a variety of functions from the menu library. * Thomas Dickey - 2005/4/9 @@ -925,7 +925,6 @@ perform_menus(void) } if (code == E_REQUEST_DENIED) beep(); - continue; } } @@ -977,42 +976,46 @@ call_files(int code) } static void -usage(void) +usage(int ok) { static const char *const tbl[] = { "Usage: demo_menus [options] [menu-file]" ,"" + ,USAGE_COMMON ,"Options:" #if HAVE_RIPOFFLINE - ," -f rip-off footer line (can repeat)" - ," -h rip-off header line (can repeat)" + ," -F rip-off footer line (can repeat)" + ," -H rip-off header line (can repeat)" #endif #ifdef TRACE - ," -t mask specify default trace-level (may toggle with ^T)" + ," -t mask specify default trace-level (may toggle with ^T)" #endif }; size_t 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, char *argv[]) { - int c; + int ch; setlocale(LC_ALL, ""); START_TRACE(); - while ((c = getopt(argc, argv, "fht:")) != -1) { - switch (c) { + while ((ch = getopt(argc, argv, OPTS_COMMON "FHt:")) != -1) { + switch (ch) { #if HAVE_RIPOFFLINE - case 'f': + case 'F': ripoffline(-1, rip_footer); break; - case 'h': + case 'H': ripoffline(1, rip_header); break; #endif /* HAVE_RIPOFFLINE */ @@ -1021,8 +1024,12 @@ main(int argc, char *argv[]) curses_trace((unsigned) strtoul(optarg, 0, 0)); break; #endif + case OPTS_VERSION: + show_version(argv); + ExitProgram(EXIT_SUCCESS); default: - usage(); + usage(ch == OPTS_USAGE); + /* NOTREACHED */ } }