[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
incorrect error locations for command-line code
From: |
Andrew J. Schorr |
Subject: |
incorrect error locations for command-line code |
Date: |
Tue, 5 Sep 2006 14:57:44 -0400 |
User-agent: |
Mutt/1.4.2.1i |
Hi,
It seems that using a mix of code supplied with '-f' and --source
can lead to errors being reported with the wrong location (using
gawk version 3.1.5). The problem is best understood with some examples:
This is correct:
bash-3.00$ ./gawk 'BEGIN {return junk}'
gawk: BEGIN {return junk}
gawk: ^ `return' used outside function context
This is also correct:
bash-3.00$ ./gawk --source 'BEGIN {return junk}'
gawk: BEGIN {return junk}
gawk: ^ `return' used outside function context
But this is wrong:
bash-3.00$ ./gawk -f /dev/null --source 'BEGIN {return junk}'
gawk: /dev/null:1: BEGIN {return junk}
gawk: /dev/null:1: ^ `return' used outside function context
As you can see, the error is incorrectly reported as occurring inside
/dev/null. It seems that awkgram.y:get_src_buf fails to reset the
source & sourceline global variables correctly when it encounters
the CMDLINE code.
A possible patch is attached. Note that this patch changes current
behavior slightly, in that it causes the original (correct) behavior
above to change slightly to include a "cmd. line:1" label. Here are the
examples with this patch in place:
bash-3.00$ ./gawk 'BEGIN {return junk}'
gawk: cmd. line:1: BEGIN {return junk}
gawk: cmd. line:1: ^ `return' used outside function context
bash-3.00$ ./gawk --source 'BEGIN {return junk}'
gawk: cmd. line:1: BEGIN {return junk}
gawk: cmd. line:1: ^ `return' used outside function context
bash-3.00$ ./gawk -f /dev/null --source 'BEGIN {return junk}'
gawk: cmd. line:1: BEGIN {return junk}
gawk: cmd. line:1: ^ `return' used outside function context
If that behavior is not desirable (to include the "cmd. line:1" location
even when the command-line code does not included an embedded newline),
then the 2nd patch can be used.
Regards,
Andy
errloc1.patch
Description: Text document
errloc2.patch
Description: Text document
- incorrect error locations for command-line code,
Andrew J. Schorr <=