Skip to content

Commit

Permalink
mkmf: replaced escape replacement logic with more permissive substitu…
Browse files Browse the repository at this point in the history
…tions
  • Loading branch information
CodeGat committed Nov 8, 2023
1 parent f996ede commit e983986
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions bin/mkmf
Original file line number Diff line number Diff line change
Expand Up @@ -468,28 +468,18 @@ if( $suffix eq '.a' ) {
}
close MAKEFILE;

sub escapeEqualsSign {
my $val = shift;
$val =~ s/=/\$\(EQUALS\)/g;
return $val;
}

# Make a copy of the completed Makefile, read it back in, escape all `=` signs
# Make a copy of the completed Makefile, read it back in, escape all relevant `=` signs
# and write it back out
rename($mkfile, $mkfile.'.bak');
open(IN, '<' . $mkfile.'.bak') or die $!;
open(OUT, '>' . $mkfile) or die $!;

print OUT "EQUALS= =\n";
print OUT "EQUALS = =";

while(<IN>) {
# Only escape ASSIGN_OP lines after assignment
if (/^(\S+) = (.*)/) {
$_ = "\n$1 = " . escapeEqualsSign($2);
} else {
$_ = escapeEqualsSign($_);
}
print OUT "$_";
# Only escape '=' that aren't assignments (aka anything that spaces either side)
$_ =~ s/(?<! )=(?! )/\$\(EQUALS\)=/g;
print OUT "$_";
}
close(IN);
close(OUT);
Expand Down

0 comments on commit e983986

Please sign in to comment.