327 |
} |
} |
328 |
} |
} |
329 |
return main::substitute_line($string, $state) unless (defined($arguments) or !keys(%$arguments)); |
return main::substitute_line($string, $state) unless (defined($arguments) or !keys(%$arguments)); |
330 |
|
# if there are arguments, we must protect the %{arg} constructs before |
331 |
|
# doing substitute_line. So there is a first pass here to change %{arg} |
332 |
|
# to %@{arg@} |
333 |
my $result = ''; |
my $result = ''; |
334 |
while ($string) |
if (!$state->{'keep_texi'}) |
335 |
{ |
{ |
336 |
if ($string =~ s/^([^%]*)%//) |
while ($string) |
337 |
{ |
{ |
338 |
$result .= $1 if (defined($1)); |
if ($string =~ s/^([^%]*)%//) |
|
$result .= '%'; |
|
|
if ($string =~ s/^%//) |
|
|
{ |
|
|
$result .= '%'; |
|
|
} |
|
|
elsif ($string =~ /^\{(\w+)\}/ and exists($arguments->{$1})) |
|
339 |
{ |
{ |
340 |
$string =~ s/^\{(\w+)\}//; |
$result .= $1 if (defined($1)); |
341 |
if (!$state->{'keep_texi'}) |
$result .= '%'; |
342 |
{ |
if ($string =~ s/^%//) |
343 |
$result .= "\@\{$1\@\}"; |
{ |
344 |
} |
$result .= '%'; |
345 |
else |
} |
346 |
{ |
elsif ($string =~ /^\{(\w+)\}/ and exists($arguments->{$1})) |
347 |
$result .= "\{$1\}"; |
{ |
348 |
} |
$string =~ s/^\{(\w+)\}//; |
349 |
|
$result .= "\@\{$1\@\}"; |
350 |
|
} |
351 |
|
else |
352 |
|
{ |
353 |
|
$result .= '%'; |
354 |
|
} |
355 |
|
next; |
356 |
} |
} |
357 |
else |
else |
358 |
{ |
{ |
359 |
$result .= '%'; |
$result .= $string; |
360 |
|
last; |
361 |
} |
} |
|
next; |
|
|
} |
|
|
else |
|
|
{ |
|
|
$result .= $string; |
|
|
last; |
|
362 |
} |
} |
363 |
|
$string = main::substitute_line($result, $state); |
364 |
} |
} |
365 |
if (!$state->{'keep_texi'}) |
# now we substitute the arguments |
|
{ |
|
|
$string = main::substitute_line($result, $state); |
|
|
} |
|
|
else |
|
|
{ |
|
|
$string = $result; |
|
|
} |
|
366 |
$result = ''; |
$result = ''; |
367 |
while ($string) |
while ($string) |
368 |
{ |
{ |