[06/20] Insert parentheses before replacing symbols with values

Message ID 1395664691-60544-6-git-send-email-martin@martin.st
State Committed
Commit 62d6c0947b04825aaa0adf7da358bfda750a8be5
Headers show

Commit Message

Martin Storsjö March 24, 2014, 12:37 p.m.
This fixes cases of evaluating x-y when y is a negative number.
---
 gas-preprocessor.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Janne Grunau March 24, 2014, 2:33 p.m. | #1
On 2014-03-24 14:37:57 +0200, Martin Storsjö wrote:
> This fixes cases of evaluating x-y when y is a negative number.
> ---
>  gas-preprocessor.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
> index 190ef87..5917d2b 100755
> --- a/gas-preprocessor.pl
> +++ b/gas-preprocessor.pl
> @@ -256,7 +256,7 @@ sub eval_expr {
>      my $expr = $_[0];
>      while ($expr =~ /([A-Za-z._][A-Za-z0-9._]*)/g) {
>          my $sym = $1;
> -        $expr =~ s/$sym/$symbols{$sym}/ if defined $symbols{$sym};
> +        $expr =~ s/$sym/($symbols{$sym})/ if defined $symbols{$sym};
>      }
>      eval $expr;
>  }

ok

Janne

Patch

diff --git a/gas-preprocessor.pl b/gas-preprocessor.pl
index 190ef87..5917d2b 100755
--- a/gas-preprocessor.pl
+++ b/gas-preprocessor.pl
@@ -256,7 +256,7 @@  sub eval_expr {
     my $expr = $_[0];
     while ($expr =~ /([A-Za-z._][A-Za-z0-9._]*)/g) {
         my $sym = $1;
-        $expr =~ s/$sym/$symbols{$sym}/ if defined $symbols{$sym};
+        $expr =~ s/$sym/($symbols{$sym})/ if defined $symbols{$sym};
     }
     eval $expr;
 }