bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] parsing column title header records


From: Andrew J. Schorr
Subject: Re: [bug-gawk] parsing column title header records
Date: Mon, 17 Dec 2012 17:44:48 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Mon, Dec 17, 2012 at 05:16:57PM -0500, Assaf Gordon wrote:
> That's exactly what I'm working on now (which is how I discovered an 
> extension can't access "NF" and "NR" if they are not defined in the AWK 
> source.
> 
> Combining an AWK include and a C extension is a nice idea. Will keep you 
> posted on progress.
> 

Hmmmm, I tried it myself, and it's strangely not working (using the gawkextlib
"common.h" header file for some defines and adding an optional 3rd argument
to specify if the variable should be constant).  The source code is attached.
Here is what I see:

bash-4.1$ (echo "name age"; echo "John 10") | ./gawk --dump-variables -i 
/tmp/header '{print age, $age}'
 John 10
bash-4.1$ grep ^name awkvars.out 
name: "1"
bash-4.1$ grep ^age awkvars.out 
age: uninitialized scalar

For some reason, accessing the variable causes the value to become
undefined:

bash-4.1$ (echo "name age"; echo "John 10") | ./gawk --dump-variables -i 
/tmp/header '{print age, $age, name}'
 John 10 
bash-4.1$ grep ^age awkvars.out 
age: uninitialized scalar
bash-4.1$ grep ^name awkvars.out 
name: uninitialized scalar

Arnold, is this a bug, or am I doing something wrong?

Regards,
Andy

Attachment: create_variable.c
Description: Text document


reply via email to

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