summaryrefslogtreecommitdiff
path: root/build-aux/cross-options.pl
diff options
context:
space:
mode:
authorAkim Demaille <demaille@gostai.com>2008-07-29 12:41:48 +0200
committerJoel E. Denny <jdenny@ces.clemson.edu>2009-04-06 00:50:21 -0400
commit0213d65176bad71e1d33b257b5a6933525fef8a2 (patch)
tree371244f3c7db271a09265c4588f7a83196987793 /build-aux/cross-options.pl
parentc19178bfaf07d8c56af805e310573595ad67cee9 (diff)
downloadbison-0213d65176bad71e1d33b257b5a6933525fef8a2.tar.gz
Handle more general types of option arguments.
* build-aux/cross-options.pl: The argument ends at the first space, not the first non-symbol character. Use @var for each word appearing the argument description. (cherry picked from commit 74eae918c3bf3772d260cb25777d9a998172a401)
Diffstat (limited to 'build-aux/cross-options.pl')
-rwxr-xr-xbuild-aux/cross-options.pl25
1 files changed, 18 insertions, 7 deletions
diff --git a/build-aux/cross-options.pl b/build-aux/cross-options.pl
index 31733e72..2cec3696 100755
--- a/build-aux/cross-options.pl
+++ b/build-aux/cross-options.pl
@@ -7,19 +7,27 @@ use strict;
my %option;
while (<>)
{
- 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.
+ if (/^\s* # Initial spaces.
+ (?:(-\w),\s+)? # $1: $short: Possible short option.
+ (--[-\w]+) # $2: $long: Long option.
+ (\[?) # $3: $opt: '[' iff the argument is optional.
+ (?:=(\S+))? # $4: $arg: Possible argument name.
+ \s # Spaces.
/x)
{
my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
$short = defined $short ? '@option{' . $short . '}' : '';
if ($arg)
{
+ # if $opt, $arg contains the closing ].
+ substr ($arg, -1) = ''
+ if $opt eq '[';
$arg =~ s/^=//;
- $arg = '@var{' . lc ($arg) . '}';
+ $arg = lc ($arg);
+ # If the argument is compite (e.g., for --define[=NAME[=VALUE]]),
+ # put each word in @var, to build @var{name}[=@var{value}], not
+ # @var{name[=value]}].
+ $arg =~ s/(\w+)/\@var{$1}/g;
$arg = '[' . $arg . ']'
if $opt eq '[';
$option{"$long=$arg"} = $short ? "$short $arg" : '';
@@ -33,5 +41,8 @@ while (<>)
foreach my $long (sort keys %option)
{
- printf "\@item %-40s \@tab %s\n", '@option{' . $long . '}', $option{$long};
+ # Avoid trailing spaces.
+ printf ("\@item %-40s \@tab%s\n",
+ '@option{' . $long . '}',
+ $option{$long} ? " $option{$long}" : "");
}