From 435d55b34422c74af8050da4152fd9dd79bc5848 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 19 Jun 2008 16:17:41 -0700 Subject: [PATCH] macros.pl: need to use $' to get proper left-to-right behaviour Using ^(.*) means we do right-to-left search, since (.*) is a greedy expression; instead use $' to get the lead-in part of the string. --- macros.pl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/macros.pl b/macros.pl index 2c6c1d10..b3084fcb 100755 --- a/macros.pl +++ b/macros.pl @@ -63,11 +63,11 @@ foreach $fname ( @ARGV ) { $s1 =~ s/\\/\\\\/g; $s1 =~ s/"/\\"/g; $s2 = ''; - while ($s1 =~ /^(.*)(\%[a-zA-Z_][a-zA-Z0-9_]*)((\s+)(.*)|)$/) { - $s2 .= $1; - $pd = $2; - $ws = $4; - $s1 = $5; + while ($s1 =~ /(\%[a-zA-Z_][a-zA-Z0-9_]*)((\s+)(.*)|)$/) { + $s2 .= "$'"; + $pd = $1; + $ws = $3; + $s1 = $4; if (defined($pptok_hash{$pd}) && $pptok_hash{$pd} <= 127) { $s2 .= sprintf("\\x%02x\"\"", $pptok_hash{$pd}+128); -- 2.11.4.GIT