bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] 'watch' in gawk debugger gives wrong NR


From: Joep van Delft
Subject: [bug-gawk] 'watch' in gawk debugger gives wrong NR
Date: Fri, 20 Nov 2015 12:27:06 +0100
User-agent: XS4ALL Webmail

Dear all,


I've been playing with gawk's debugger, and ran into an issues that might qualify as bug. When `watch`-ing a variable, the `NR` builtin variable is
displayed wrong.

gawk> list
1       #!/usr/bin/gawk -f
2       BEGIN {
3           c = 0
4       }
5
6       /apple/ {
7           nr = NR
8           c++
9           # printf "[c, NR] = [%s, %s]\n", c, NR
10      }
11
12      END {
13          print c
14      }


I would expect that nr alway equals NR after this assignment. When using
`break` on line 8, it works as expected.  Also, when uncommenting
the printf line, all works as I would expect.


The following file is being processed (notice the apple lines are on even line
numbers):

      1 1 pear
      2 1 apple 4
      3 2 pear
      4 3 apple 9
      5 8 pear
      6 9 apple
      7 10 pear
      8 12 apple


gawk> info watch
Watch variables:

1:      c

gawk> info display
Auto-display variables:

1:      nr
2:      NR
3:      c

gawk> run

Restarting ...
Starting program:
Stopping in Rule ...
Watchpoint 1: c
  Old value: untyped variable
  New value: 0
main() at `script.awk':6
6       /apple/ {
1: nr = untyped variable
2: NR = 1
3: c = 0

gawk> c
Watchpoint 1: c
  Old value: 0
  New value: 1
main() at `script.awk':6
6       /apple/ {
1: nr = 2
2: NR = 3
3: c = 1

gawk> c
Watchpoint 1: c
  Old value: 1
  New value: 2
main() at `script.awk':6
6       /apple/ {
1: nr = 4
2: NR = 5
3: c = 2

...

Thanks,

Joep van Delft





reply via email to

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