# HG changeset patch # User mikek # Date 1277304506 -3600 # Node ID d23856282806ec555389171fe7ee5ce20282c498 # Parent 949d0e782de18a9af6e9817f4923baea2653eed8 Fix for Bug 3054 - [GCCE] armasm2as.pl cannot parse parentheses in maco IF conditions. diff -r 949d0e782de1 -r d23856282806 sbsv1_os/e32toolp/e32util/armasm2as.pl --- a/sbsv1_os/e32toolp/e32util/armasm2as.pl Mon Jun 21 18:05:07 2010 +0100 +++ b/sbsv1_os/e32toolp/e32util/armasm2as.pl Wed Jun 23 15:48:26 2010 +0100 @@ -290,12 +290,13 @@ $val =~ s/\{FALSE\}/(0)/g; my @lops = split( /(\s*\:LAND\:\s*|\s*\:LOR\:\s*|\s*\:LNOT\:\s*|\s*\:DEF\:\s*|\s*\(\s*|\s*\)\s*)/, $val ); - my @lops2; foreach (@lops) { s/\s*\:LAND\:\s*/\:LAND\:/go; s/\s*\:LOR\:\s*/\:LOR\:/go; s/\s*\:LNOT\:\s*/\:LNOT\:/go; s/\s*\:DEF\:\s*/\:DEF\:/go; + s/\s*\(\s*/\(/go; + s/\s*\)\s*/\)/go; } my @lops2; while (scalar (@lops)) { @@ -322,12 +323,28 @@ while (scalar (@lops2)) { my $x = shift @lops2; if ($x eq ':LNOT:') { - my $operand; - while (1) { + my $operand = shift @lops2; + while (@lops2 && $operand =~ /^\s*$/) { $operand = shift @lops2; - last if ($operand !~ /^\s*$/); } - push @lops3, "(0==($operand))"; + if ($operand eq '(') { + my $balance = 1; + my $compound = $operand; + while($balance > 0 && @lops2) { + $operand = shift @lops2; + if ($operand eq '(') { + ++$balance; + } + elsif ($operand eq ')') { + --$balance; + } + $compound .= $operand; + } + push @lops3, "(0==$compound)"; + } + else { + push @lops3, "(0==($operand))"; + } } else { push @lops3, $x; }