|
From: | Manuel Collado |
Subject: | Re: [bug-gawk] pretty-print eats parentheses |
Date: | Thu, 30 Oct 2014 17:36:21 +0100 |
User-agent: | Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
El 30/10/2014 15:09, Andrew J. Schorr escribió:
... The correct fixes are not obvious to me. The code is trying to be clever about not including unnecessary parentheses. If those checks are removed, there may be lots of extra parentheses. For example, if that "is_binary" test is removed, one gets: bash-4.2$ ./gawk -o/dev/stdout "BEGIN{ x=3; print -(-x) }" BEGIN { x = 3 print -(-(x)) } Similarly, making pp_concat dumber gives: bash-4.2$ gawk -o/dev/stdout 'BEGIN{FS="|"; str = -8 FS (-9) ; print str}' BEGIN { FS = "|" str = (-8) (FS) -9 print str }
Well, these extra parenthesis can be seen as a help for code inspection/debugging. They clearly show how the awk processor understand, and hence evaluate, the code.
Regards. -- Manuel Collado - http://lml.ls.fi.upm.es/~mcollado
[Prev in Thread] | Current Thread | [Next in Thread] |