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

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

Re: Unexpected result while constructing strings


From: Andreas Schwab
Subject: Re: Unexpected result while constructing strings
Date: Sat, 30 Oct 2010 17:01:58 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Davide Brini <address@hidden> writes:

> It surely seems that FS and " " are treated differently, at least in some
> cases:
>
> $ gawk 'BEGIN{print " " ++c}'
>  1

This is parsed as `(" ") (++c)' (a string cannot be operand of ++).

> $ gawk 'BEGIN{print FS ++c}'
> 0

This is parsed as `(FS++) c' (increment/decrement has highest
precedence).  (FS++) evaluates to 0 which is then concatenated with the
empty string (c).

> Back to the example, I may be wrong but the only way I see for FS ++c to
> evaluate to plain 0 is that for some reason they are grouped as
>
> FS + +c

This would violate the longest token rule ("awk shall recognize the
longest possible token or delimiter beginning at a given point").

Andreas.

-- 
Andreas Schwab, address@hidden
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."



reply via email to

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