mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
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.
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
2008-11-07 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
2008-11-07 Akim Demaille <demaille@gostai.com>
|
2008-11-07 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
Destroy the variants that remain on the stack in case of error.
|
Destroy the variants that remain on the stack in case of error.
|
||||||
|
|||||||
@@ -7,19 +7,27 @@ use strict;
|
|||||||
my %option;
|
my %option;
|
||||||
while (<>)
|
while (<>)
|
||||||
{
|
{
|
||||||
if (/^\s* # Initial spaces.
|
if (/^\s* # Initial spaces.
|
||||||
(?:(-\w),\s+)? # $1: Possible short option.
|
(?:(-\w),\s+)? # $1: $short: Possible short option.
|
||||||
(--[-\w]+) # $2: Long option.
|
(--[-\w]+) # $2: $long: Long option.
|
||||||
(\[?) # $3: '[' iff the argument is optional.
|
(\[?) # $3: $opt: '[' iff the argument is optional.
|
||||||
(?:=([-\w]+))? # $4: Possible argument name.
|
(?:=(\S+))? # $4: $arg: Possible argument name.
|
||||||
|
\s # Spaces.
|
||||||
/x)
|
/x)
|
||||||
{
|
{
|
||||||
my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
|
my ($short, $long, $opt, $arg) = ($1, $2, $3, $4);
|
||||||
$short = defined $short ? '@option{' . $short . '}' : '';
|
$short = defined $short ? '@option{' . $short . '}' : '';
|
||||||
if ($arg)
|
if ($arg)
|
||||||
{
|
{
|
||||||
|
# if $opt, $arg contains the closing ].
|
||||||
|
substr ($arg, -1) = ''
|
||||||
|
if $opt eq '[';
|
||||||
$arg =~ s/^=//;
|
$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 . ']'
|
$arg = '[' . $arg . ']'
|
||||||
if $opt eq '[';
|
if $opt eq '[';
|
||||||
$option{"$long=$arg"} = $short ? "$short $arg" : '';
|
$option{"$long=$arg"} = $short ? "$short $arg" : '';
|
||||||
@@ -33,5 +41,8 @@ while (<>)
|
|||||||
|
|
||||||
foreach my $long (sort keys %option)
|
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}" : "");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user