diff options
author | Miles Bader <miles@gnu.org> | 1997-02-12 02:46:48 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1997-02-12 02:46:48 +0000 |
commit | 07580c01e7a3f6b5b9c4d3a08ef568ed647c7c60 (patch) | |
tree | 4391e40be6d08cbc54b92b58988a4d4913b46d79 /libshouldbeinlibc/argp-test.c | |
parent | 8f33480b595edc3020e0bf793ccdeb2068f4612c (diff) |
(args_doc): Add an alternative args pattern.
(parse_opt): Enforce it.
Diffstat (limited to 'libshouldbeinlibc/argp-test.c')
-rw-r--r-- | libshouldbeinlibc/argp-test.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libshouldbeinlibc/argp-test.c b/libshouldbeinlibc/argp-test.c index 70c7eb58..378aff86 100644 --- a/libshouldbeinlibc/argp-test.c +++ b/libshouldbeinlibc/argp-test.c @@ -52,7 +52,7 @@ the current process)"}, {0} }; -static const char args_doc[] = "STRING..."; +static const char args_doc[] = "STRING...\n-"; static const char doc[] = "Test program for argp."; static error_t @@ -61,9 +61,15 @@ parse_opt (int key, char *arg, struct argp_state *state) switch (key) { case ARGP_KEY_NO_ARGS: - printf ("NO ARGS\n"); break; + printf ("NO ARGS\n"); + break; case ARGP_KEY_ARG: - printf ("ARG: %s\n", arg); break; + if (state->arg_num == 0 && strcmp (arg, "-") == 0 + && state->next < state->argc) + argp_usage (state); + printf ("ARG: %s\n", arg); + break; + case 'p': case 'P': case OPT_PGRP: case 'x': case 'Q': case 'r': case OPT_SESS: { @@ -76,8 +82,9 @@ parse_opt (int key, char *arg, struct argp_state *state) printf ("KEY %s: %s\n", buf, arg); else printf ("KEY %s\n", buf); - break; } + break; + default: return ARGP_ERR_UNKNOWN; } |