From 7020f1e9e255c63d468b5b1591ea2475e40fca28 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 28 Feb 2008 16:01:16 +0000 Subject: [PATCH] * src/getargs.c (short_options): Split and sort for readability. -g and -x take optional arguments, just like their long options. * build-aux/cross-options.pl: Use /x to make the regexp easier to understand. Fix the handling of $opt which resulted in all the argument to be considered as optional. --- ChangeLog | 9 +++++++++ build-aux/cross-options.pl | 9 +++++++-- src/getargs.c | 26 ++++++++++++++++++++++++-- 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6b94a409..caa65b62 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-02-28 Akim Demaille + + * src/getargs.c (short_options): Split and sort for readability. + -g and -x take optional arguments, just like their long options. + * build-aux/cross-options.pl: Use /x to make the regexp easier to + understand. + Fix the handling of $opt which resulted in all the argument to be + considered as optional. + 2008-02-22 Joel E. Denny * NEWS (2.3a+): Don't say %language is experimental. Mention Java and diff --git a/build-aux/cross-options.pl b/build-aux/cross-options.pl index cbd11888..31733e72 100755 --- a/build-aux/cross-options.pl +++ b/build-aux/cross-options.pl @@ -7,7 +7,12 @@ use strict; my %option; while (<>) { - if (/^\s*(?:(-\w), )?(--[-\w]+)(\[?)(=[-\w]+)?\]?/) + if (/^\s* # Initial spaces. + (?:(-\w),\s+)? # $1: Possible short option. + (--[-\w]+) # $2: Long option. + (\[?) # $3: '[' iff the argument is optional. + (?:=([-\w]+))? # $4: Possible argument name. + /x) { my ($short, $long, $opt, $arg) = ($1, $2, $3, $4); $short = defined $short ? '@option{' . $short . '}' : ''; @@ -16,7 +21,7 @@ while (<>) $arg =~ s/^=//; $arg = '@var{' . lc ($arg) . '}'; $arg = '[' . $arg . ']' - if defined $opt; + if $opt eq '['; $option{"$long=$arg"} = $short ? "$short $arg" : ''; } else diff --git a/src/getargs.c b/src/getargs.c index 9661fefe..77f147d3 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -403,8 +403,30 @@ language_argmatch (char const *arg, int prio, location const *loc) | Process the options. | `----------------------*/ -/* Shorts options. */ -static char const short_options[] = "yvegxdhr:L:ltknVo:b:p:S:T::W"; +/* Shorts options. + Should be computed from long_options. */ +static char const short_options[] = + "L:" + "S:" + "T::" + "V" + "W" + "b:" + "d" + "e" + "g::" + "h" + "k" + "l" + "n" + "o:" + "p:" + "r:" + "t" + "v" + "x::" + "y" + ; /* Values for long options that do not have single-letter equivalents. */ enum -- 2.47.2