bug-gawk
[Top][All Lists]
Advanced

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

Not real bugs?


From: J Naman
Subject: Not real bugs?
Date: Mon, 8 Jan 2024 01:30:06 -0500

I was looking for a global array in the "awk" namespace. This is arguably a
coding abuse rather than a real bug.
# single quote is used in output to replace \", for readability
# since PROCINFO["identifiers"] is "not updated while the program runs."
# it might be available for (ab)use like any other array ...
PROCINFO['identifiers']['foo']=''
PROCINFO['identifiers']['foo']='untyped'
PROCINFO['identifiers']['foo']='7'
typeof(PROCINFO['identifiers']['foo']='number'

Try using new identifier, "farr" as an array
typeof(PROCINFO['identifiers']['farr']='untyped'
PROCINFO['identifiers']['farr'][0]='1'
PROCINFO['identifiers']['farr'][1]='LIFO string 1'
typeof(PROCINFO['identifiers']['farr']='array'

PROCINFO['#stack'][0]='0'
PROCINFO['#stack'][1]='LIFO string 1'
typeof(PROCINFO['#stack']='array'

# as expected, neither "farr" nor "#stack" are in SYMTAB\

Separate very minor issue: It is not documented that PROCINFO["-",
"NONFATAL"] appears to assume SUBSEP = "\034", which it is before the BEGIN
block executes
BEGIN{
SUBSEP = ";"
PROCINFO["-", "NONFATAL"] = 1
printf "PROCINFO[\"-\", \"NONFATAL\"] = '%s'\n ",PROCINFO["-", "NONFATAL"]
# prints 1
SUBSEP = "\034"
printf "PROCINFO[\"-\", \"NONFATAL\"] = '%s'\n ",PROCINFO["-", "NONFATAL"]
# prints null
Maybe the error handling routines honor SUBSEP or assume  "\034". I have
not looked at the source.
Perfection: add warning in documentation as a footnote: not obvious ...
Dark Korner Xplorer, john naman


reply via email to

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