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

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

Re: gawk misparses $expr++ if expr ends in ++


From: Aharon Robbins
Subject: Re: gawk misparses $expr++ if expr ends in ++
Date: Tue, 06 Feb 2007 22:13:39 +0200

Greetings. Re this:

> Date: Fri, 06 Jan 2006 14:02:17 -0800
> From: Paul Eggert <address@hidden>
> Subject: gawk misparses $expr++ if expr ends in ++
> To: address@hidden
>
>
> Here's an example of the problem:
>
> $ gawk 'BEGIN{a=3}{print $$a++++}'
> gawk: {print $$a++++}
> gawk:               ^ syntax error
>
> But it's not a syntax error, as the expression conforms to the POSIX
> spec: it should be treated like '$($a++)++'.
>
> Mawk, Solaris awk (old awk), and Solaris nawk all accept the
> expression.  For example:
>
> $ echo '3 4 5 6 7 8 9' | nawk 'BEGIN{a=3}{print $$a++++}'
> 7
>
> This is with gawk 3.1.5 on Solaris 8 (sparc).

I have fixed this; see the gawk CVS archive on Savannah. If you
need a separate patch, let me know.

Thanks for the bug report.  Hacking the grammar is always a
thrill. (Not! :-)

Arnold

P.S. The proof is in the pudding:

$ echo 3 4 5 6 7 8 9 | ./gawk --profile=/dev/stdout 'BEGIN{a=3}{print $$a++++}'
7
        # gawk profile, created Tue Feb  6 22:12:36 2007

        # BEGIN block(s)

        BEGIN {
                a = 3
        }

        # Rule(s)

        {
                print $($a++)++
        }





reply via email to

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