summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2014-07-11 17:31:02 +0200
committerMichael Schroeder <mls@suse.de>2014-07-11 17:31:02 +0200
commiteb92c75f89d9b9f71068ff97e11a9a7481df3632 (patch)
treef20c26a963c68c53a9a8bcdcb9fae504676cb85a /Build
parent5c893c88897a2e5a14373cd0610f2dbf1decbc23 (diff)
Fix macro expansion corner cases
Behave like rpm in regard of macro borders
Diffstat (limited to 'Build')
-rw-r--r--Build/Rpm.pm25
1 files changed, 19 insertions, 6 deletions
diff --git a/Build/Rpm.pm b/Build/Rpm.pm
index 542ff5e..2d8cf08 100644
--- a/Build/Rpm.pm
+++ b/Build/Rpm.pm
@@ -348,10 +348,20 @@ reexpand:
}
$macalt = $macros{$macname} unless defined $macalt;
$macalt = '' if $mactest == -1;
- $line = "$macalt$line";
+ if ($macalt =~ /%/) {
+ push @expandstack, ('', $line, 1) if $line ne '';
+ $line = $macalt;
+ } else {
+ $expandedline .= $macalt;
+ }
} elsif ($mactest) {
$macalt = '' if !defined($macalt) || $mactest == 1;
- $line = "$macalt$line";
+ if ($macalt =~ /%/) {
+ push @expandstack, ('', $line, 1) if $line ne '';
+ $line = $macalt;
+ } else {
+ $expandedline .= $macalt;
+ }
} else {
$expandedline .= "%$macorig" unless $macname =~ /^-/;
}
@@ -360,12 +370,15 @@ reexpand:
if (@expandstack) {
my $m = pop(@expandstack);
if ($m) {
- $optmacros = adaptmacros(\%macros, $optmacros, $m);
+ $optmacros = adaptmacros(\%macros, $optmacros, $m) if ref $m;
$expandstack[-2] .= $line;
- $line = '';
+ $line = pop(@expandstack);
+ $expandedline = pop(@expandstack);
+ } else {
+ my $todo = pop(@expandstack);
+ $expandedline = pop(@expandstack);
+ push @expandstack, ('', $todo, 1) if $todo ne '';
}
- $line = $line . pop(@expandstack);
- $expandedline = pop(@expandstack);
goto reexpand;
}
}