bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: documentation fix for gawk manual discussion of unary operators


From: Aharon Robbins
Subject: Re: documentation fix for gawk manual discussion of unary operators
Date: Wed, 06 Sep 2006 20:36:26 +0300

Applied, much thanks.

Arnold

> Date: Sat, 29 Jul 2006 08:39:16 -0400
> From: Paul Eggert <address@hidden>
> Subject: documentation fix for gawk manual discussion of unary operators
> To: address@hidden
>
> I'm following up to an earlier bug report
> <http://lists.gnu.org/archive/html/bug-gnu-utils/2006-01/msg00036.html>
> where I noted a minor incompatibility of Gawk and POSIX with respect
> to unary operators.  On further thought I decided this was a bug in
> POSIX not a bug in Gawk's behavior, so I filed a bug report with the
> Open Group and was recently notified that the bug will be fixed in the
> next POSIX version.
>
> However, the Gawk manual still needs fixing, since it incorrectly claims
> that the precedence of prefix unary operators does not matter as long
> as only unary operators are involved, and this claim is incorrect when
> _postfix_ unary operators are also involved.
>
> Here is a proposed patch, relative to Gawk 3.1.5.
>
> 2006-07-29  Paul Eggert  <address@hidden>
>
>       * gawk.texi: Document that `$$0++--' isn't valid even though it
>       is unambiguous according to the Awk grammar.  This is in response
>       to Open Group XCU ERN 86
>       <http://www.opengroup.org/austin/aardvark/latest/xcubug2.txt>.
>
> --- gawk-3.1.5-orig/doc/gawk.texi     2005-07-25 15:28:03.000000000 -0400
> +++ gawk-3.1.5/doc/gawk.texi  2006-07-29 08:37:35.000000000 -0400
> @@ -9093,14 +9093,20 @@ exponentiation operators, which group in
>  Thus, @samp{a - b + c} groups as @samp{(a - b) + c} and
>  @samp{a = b = c} groups as @samp{a = (b = c)}.
>  
> -The precedence of prefix unary operators does not matter as long as only
> -unary operators are involved, because there is only one way to interpret
> +Normally the precedence of prefix unary operators does not matter,
> +because there is only one way to interpret
>  them: innermost first.  Thus, @samp{$++i} means @samp{$(++i)} and
>  @samp{++$x} means @samp{++($x)}.  However, when another operator follows
>  the operand, then the precedence of the unary operators can matter.
>  @samp{$x^2} means @samp{($x)^2}, but @samp{-x^2} means
>  @samp{-(x^2)}, because @samp{-} has lower precedence than @samp{^},
>  whereas @samp{$} has higher precedence.
> +Also, operators cannot be combined in a way that violates the
> +precedence rules; for example, @samp{$$0++--} is not a valid
> +expression because the first @samp{$} has higher precedence than the
> address@hidden; to avoid the problem the expression can be rewritten as
> address@hidden($0++)--}.
> +
>  This table presents @command{awk}'s operators, in order of highest
>  to lowest precedence:




reply via email to

[Prev in Thread] Current Thread [Next in Thread]