mirror of
https://https.git.savannah.gnu.org/git/gnulib.git
synced 2026-10-04 16:18:26 +00:00
Argp: fix recognition of short alias options.
* lib/argp-parse.c (convert_options): Fix improper use of `|' between character values. * tests/test-argp.c (group1_option): New alias option --read (-r). (group1_parser): Special handling for 'r'. (test15): New test case. (test_fun): Add test15. * tests/test-argp-2.sh: Update expected --help and --usage outputs.
This commit is contained in:
@@ -1,3 +1,17 @@
|
||||
2010-02-05 Sergey Poznyakoff <gray@gnu.org.ua>
|
||||
|
||||
Argp: fix recognition of short alias options.
|
||||
|
||||
* lib/argp-parse.c (convert_options): Fix improper use of
|
||||
`|' between character values.
|
||||
* tests/test-argp.c (group1_option): New alias option
|
||||
--read (-r).
|
||||
(group1_parser): Special handling for 'r'.
|
||||
(test15): New test case.
|
||||
(test_fun): Add test15.
|
||||
* tests/test-argp-2.sh: Update expected --help and --usage
|
||||
outputs.
|
||||
|
||||
2010-02-05 Sergey Poznyakoff <gray@gnu.org.ua>
|
||||
|
||||
* tests/test-argp.c: Fix indentation.
|
||||
@@ -1062,7 +1076,7 @@
|
||||
* tests/test-xalloc-die.sh: Use $EXEEXT.
|
||||
|
||||
2010-01-12 Simon Josefsson <simon@josefsson.org>
|
||||
Bruno Haible <bruno@clisp.org>
|
||||
Bruno Haible <bruno@clisp.org>
|
||||
|
||||
getlogin, getlogin_r: Avoid test failure.
|
||||
* tests/test-getlogin.c: Include <stdio.h>.
|
||||
|
||||
+1
-1
@@ -339,7 +339,7 @@ convert_options (const struct argp *argp,
|
||||
values (the sign of the lower bits is preserved
|
||||
however)... */
|
||||
cvt->long_end->val =
|
||||
((opt->key | real->key) & USER_MASK)
|
||||
((opt->key ? opt->key : real->key) & USER_MASK)
|
||||
+ (((group - cvt->parser->groups) + 1) << USER_BITS);
|
||||
|
||||
/* Keep the LONG_OPTS list terminated. */
|
||||
|
||||
+10
-8
@@ -33,10 +33,10 @@ func_compare() {
|
||||
####
|
||||
# Test --usage output
|
||||
cat > $TMP <<EOT
|
||||
Usage: test-argp [-tvCSOlp?V] [-f FILE] [-o[ARG]] [--test] [--file=FILE]
|
||||
[--input=FILE] [--verbose] [--cantiga] [--sonet] [--option]
|
||||
[--optional[=ARG]] [--limerick] [--poem] [--help] [--usage]
|
||||
[--version] ARGS...
|
||||
Usage: test-argp [-tvCSOlp?V] [-f FILE] [-r FILE] [-o[ARG]] [--test]
|
||||
[--file=FILE] [--input=FILE] [--read=FILE] [--verbose] [--cantiga]
|
||||
[--sonet] [--option] [--optional[=ARG]] [--limerick] [--poem]
|
||||
[--help] [--usage] [--version] ARGS...
|
||||
EOT
|
||||
|
||||
./test-argp$EXEEXT --usage | func_compare || ERR=1
|
||||
@@ -45,9 +45,10 @@ EOT
|
||||
# Test working usage-indent format
|
||||
|
||||
cat > $TMP <<EOT
|
||||
Usage: test-argp [-tvCSOlp?V] [-f FILE] [-o[ARG]] [--test] [--file=FILE]
|
||||
[--input=FILE] [--verbose] [--cantiga] [--sonet] [--option] [--optional[=ARG]]
|
||||
[--limerick] [--poem] [--help] [--usage] [--version] ARGS...
|
||||
Usage: test-argp [-tvCSOlp?V] [-f FILE] [-r FILE] [-o[ARG]] [--test]
|
||||
[--file=FILE] [--input=FILE] [--read=FILE] [--verbose] [--cantiga] [--sonet]
|
||||
[--option] [--optional[=ARG]] [--limerick] [--poem] [--help] [--usage]
|
||||
[--version] ARGS...
|
||||
EOT
|
||||
|
||||
ARGP_HELP_FMT='usage-indent=0' ./test-argp$EXEEXT --usage | func_compare || ERR=1
|
||||
@@ -62,7 +63,8 @@ documentation string
|
||||
-t, --test
|
||||
|
||||
Option Group 1
|
||||
-f, --file=FILE, --input=FILE Option with a mandatory argument
|
||||
-f, -r, --file=FILE, --input=FILE, --read=FILE
|
||||
Option with a mandatory argument
|
||||
-v, --verbose Simple option without arguments
|
||||
|
||||
Option Group 1.1
|
||||
|
||||
+14
-1
@@ -34,6 +34,7 @@ struct test_args
|
||||
int test;
|
||||
int verbose;
|
||||
char *file;
|
||||
int read;
|
||||
char *hidden;
|
||||
int opt;
|
||||
char *optional;
|
||||
@@ -47,6 +48,7 @@ static struct argp_option group1_option[] = {
|
||||
{ "verbose", 'v', NULL, 0, "Simple option without arguments", 1 },
|
||||
{ "file", 'f', "FILE", 0, "Option with a mandatory argument", 1 },
|
||||
{ "input", 0, NULL, OPTION_ALIAS, NULL, 1 },
|
||||
{ "read", 'r', NULL, OPTION_ALIAS, NULL, 1 },
|
||||
{ "hidden", 'H', "FILE", OPTION_HIDDEN, "Hidden option", 1 },
|
||||
{ NULL, 0, NULL, 0, NULL, 0 }
|
||||
};
|
||||
@@ -62,6 +64,9 @@ group1_parser (int key, char *arg, struct argp_state *state)
|
||||
args->verbose++;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
args->read = 1;
|
||||
/* fall through */
|
||||
case 'f':
|
||||
args->file = arg;
|
||||
break;
|
||||
@@ -430,6 +435,14 @@ test14 (struct argp *argp)
|
||||
fail ("option not processed");
|
||||
}
|
||||
|
||||
void
|
||||
test15 (struct argp *argp)
|
||||
{
|
||||
INIT_TEST2 (1, "-r", "FILE");
|
||||
test_file (argp, argc, argv, &test_args);
|
||||
if (!test_args.read)
|
||||
fail ("short alias not recognized properly");
|
||||
}
|
||||
|
||||
|
||||
typedef void (*test_fp) (struct argp *argp);
|
||||
@@ -438,7 +451,7 @@ test_fp test_fun[] = {
|
||||
test1, test2, test3, test4,
|
||||
test5, test6, test7, test8,
|
||||
test9, test10, test11, test12,
|
||||
test13, test14,
|
||||
test13, test14, test15,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user