diff options
Diffstat (limited to 'test/demo_forms.c')
-rw-r--r-- | test/demo_forms.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/test/demo_forms.c b/test/demo_forms.c index ea0426d0fa00..62e8c644e23b 100644 --- a/test/demo_forms.c +++ b/test/demo_forms.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright 2018-2019,2020 Thomas E. Dickey * + * Copyright 2018-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_forms.c,v 1.58 2020/03/21 15:57:59 tom Exp $ + * $Id: demo_forms.c,v 1.63 2023/11/11 00:29:53 tom Exp $ * * Demonstrate a variety of functions from the form library. * Thomas Dickey - 2003/4/26 @@ -154,7 +154,7 @@ make_label(const char *label, int frow, int fcol) if (f) { set_field_buffer(f, 0, label); - set_field_opts(f, (int) ((unsigned) field_opts(f) & ~O_ACTIVE)); + set_field_opts(f, (int) ((unsigned) field_opts(f) & (unsigned) ~O_ACTIVE)); } return (f); } @@ -242,7 +242,7 @@ show_insert_mode(bool insert_mode) #define O_SELECTABLE (O_ACTIVE | O_VISIBLE) static FIELD * -another_field(FORM *form, FIELD *field) +another_field(FORM *form, const FIELD *const field) { FIELD **f = form_fields(form); FIELD *result = 0; @@ -556,23 +556,28 @@ demo_forms(void) } static void -usage(void) +usage(int ok) { static const char *tbl[] = { "Usage: demo_forms [options] [data file]" ,"" - ," -d make fields dynamic" - ," -j value justify (1=left, 2=center, 3=right)" - ," -m value set maximum size of dynamic fields" - ," -o value specify number of offscreen rows in new_field()" - ," -t value specify text to fill fields initially" + ,USAGE_COMMON + ,"Options:" + ," -d make fields dynamic" + ," -j NUM justify (1=left, 2=center, 3=right)" + ," -m NUM set maximum size of dynamic fields" + ," -o NUM specify number of offscreen rows in new_field()" + ," -t NUM specify text to fill fields initially" }; unsigned int j; for (j = 0; j < SIZEOF(tbl); ++j) fprintf(stderr, "%s\n", tbl[j]); - exit(EXIT_FAILURE); + ExitProgram(ok ? EXIT_SUCCESS : EXIT_FAILURE); } +/* *INDENT-OFF* */ +VERSION_COMMON() +/* *INDENT-ON* */ int main(int argc, char *argv[]) @@ -581,7 +586,7 @@ main(int argc, char *argv[]) setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "dj:m:o:t:")) != -1) { + while ((ch = getopt(argc, argv, OPTS_COMMON "dj:m:o:t:")) != -1) { switch (ch) { case 'd': d_option = TRUE; @@ -590,7 +595,7 @@ main(int argc, char *argv[]) j_value = atoi(optarg); if (j_value < NO_JUSTIFICATION || j_value > JUSTIFY_RIGHT) - usage(); + usage(FALSE); break; case 'm': m_value = atoi(optarg); @@ -601,9 +606,12 @@ main(int argc, char *argv[]) case 't': t_value = optarg; break; + case OPTS_VERSION: + show_version(argv); + ExitProgram(EXIT_SUCCESS); default: - usage(); - + usage(ch == OPTS_USAGE); + /* NOTREACHED */ } } while (optind < argc) { |