mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
-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.
38 lines
823 B
Perl
Executable File
38 lines
823 B
Perl
Executable File
#! /usr/bin/env perl
|
|
|
|
use warnings;
|
|
use 5.005;
|
|
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.
|
|
/x)
|
|
{
|
|
my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
|
|
$short = defined $short ? '@option{' . $short . '}' : '';
|
|
if ($arg)
|
|
{
|
|
$arg =~ s/^=//;
|
|
$arg = '@var{' . lc ($arg) . '}';
|
|
$arg = '[' . $arg . ']'
|
|
if $opt eq '[';
|
|
$option{"$long=$arg"} = $short ? "$short $arg" : '';
|
|
}
|
|
else
|
|
{
|
|
$option{"$long"} = "$short";
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach my $long (sort keys %option)
|
|
{
|
|
printf "\@item %-40s \@tab %s\n", '@option{' . $long . '}', $option{$long};
|
|
}
|