[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Printing arrays from the debugger, once again
From: |
arnold |
Subject: |
Re: Printing arrays from the debugger, once again |
Date: |
Sat, 23 Dec 2023 21:57:59 -0700 |
User-agent: |
Heirloom mailx 12.5 7/5/10 |
Hi.
Thanks for the report. The problem comes from the fact that
gawk internally has several array implementations and split()
uses one type but regular assignment uses another. The attached
patch fixes the problem with the debugger.
I will eventually push it to Git.
Arnold
Hermann Peifer <peifer@gmx.eu> wrote:
> See below where "walkarray" prints a[0][1], etc. whereas the debugger
> prints a["(null)"]["1"].
>
> The debugger prints a[1] as expected. Maybe because array a[1] already
> existed before calling split(), my best guess.
>
> Hermann
>
>
> a) Using latest gawk code from git/gawk-5.3-stable branch, on my
> MacBook, Machine Type: aarch64-apple-darwin23.1.0
>
> > cat test.awk
> @include "walkarray"
>
> {
> split($0, a[0])
> a[1][1]
> split($0, a[1])
> }
>
> END { walk_array(a, "a") }
> >
> > cat test.dat
> 1 2 3
> >
> > gawk -D -f test.awk test.dat
> gawk> r
> Starting program:
> a[0][1] = 1
> a[0][2] = 2
> a[0][3] = 3
> a[1][1] = 1
> a[1][2] = 2
> a[1][3] = 3
> Program exited normally with exit value: 0
> gawk> p @a
> a["(null)"]["1"] = "1"
> a["(null)"]["2"] = "2"
> a["(null)"]["3"] = "3"
> a["1"]["1"] = "1"
> a["1"]["2"] = "2"
> a["1"]["3"] = "3"
> gawk>
>
>
> b) Using gawk5.3.0 release, installed via Homebrew
>
> (...)
> gawk> p @a
> (null)["1"] = "1"
> (null)["2"] = "2"
> (null)["3"] = "3"
> 1["1"] = "1"
> 1["2"] = "2"
> 1["3"] = "3"
> gawk>
>
dbugfix.diff
Description: Text document