bug-gawk
[Top][All Lists]
Advanced

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

two separate issues related to readall() in Gawk ver. 5.2.0


From: J Naman
Subject: two separate issues related to readall() in Gawk ver. 5.2.0
Date: Sun, 11 Sep 2022 16:05:34 -0400

This is a report about two separate issues related to readall() in ver.
5.2.0
# Gawk ver 5.2.0 (mingw) api3.2 GNU MP 6.1.2 GNU MPFR 4.0.2

1) minor conflict in the documentation:
(Section 7.5.2): "Prior to version 5.0 of gawk, you could use an index for
SYMTAB
 that was not a predefined identifier: SYMTAB["xxx"] = 5; print
SYMTAB["xxx"];
 This no longer works, instead producing a fatal error, as it led to rampant
confusion."
NOT TRUE NOW IF the following procedure is followed: (error checking not
shown)
tempfile="temp.binawk";
writea(tempfile, SYMTAB)
# copy-clone-dup by reading back in to a new user variable
reada(tempfile, acopySYMTAB)
# FYI: ^^^ just did clone(a,b) without walking the array:
# function clone(a,b){t="tempfile.bin"; writea(t,a), reada(t,b)}

print "Attempt to use an index for SYMTAB that was not a predefined
identifier: (Section 7.5.2)"
acopySYMTAB["xxx"] = 5;
writea(tempfile, acopySYMTAB); # update temp file

print "Attempt to update SYMTAB using new readall(file) function"
readall(tempfile);
print "Testing xxx in SYMTAB now ..."
print "SYMTAB[\"xxx\"]= " SYMTAB["xxx"]

> SYMTAB["xxx"]= 5
# obviously not recommended, but can be done now
#=================
2) minor bug revealed:
SYMTAB contained entries for: dBug::_ foo::arr foo::test_namespace pgm::run
#stderr> warning: readall: unable to set foo::arr
#stderr> warning: readall: unable to set pgm::run
#stderr> warning: readall: unable to set dBug::_
#stderr> warning: readall: unable to set foo::test_namespace

Note: the namespace variables had a variety of data types:
foo::test_namespace="test"
split("",foo::arr); foo::arr[2]=foo::test_namespace;
foo::arr["xyz"]=3;
dBug::_["flag"]=1;
#=================
3) Good news: Time Travel paradoxes are still prohibited using the method
in 1) above:
"fatal: reference to uninitialized element `SYMTAB["SYMTAB"] is not allowed'
- 'Best, john naman


reply via email to

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