bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Possible regression of SYMTAB


From: Aharon Robbins
Subject: Re: [bug-gawk] Possible regression of SYMTAB
Date: Wed, 07 Nov 2012 21:34:29 +0200
User-agent: Heirloom mailx 12.5 6/20/10

Hi Assaf.

Thanks for the note.

> Date: Tue, 6 Nov 2012 18:30:09 -0500
> From: Assaf Gordon <address@hidden>
> To: <address@hidden>
> Subject: [bug-gawk] Possible regression of SYMTAB
>
> Hello,
>
> Playing around with SYMTAB, I think there's a regression when creating
> a variable directly in SYMTAB in the current version.
>
> Test case:
> ===
> $ printf "1\n2\n" | ./gawk '{SYMTAB["POS"]=1 ; print $POS}'
> 1
> gawk: cmd. line:1: (FILENAME=- FNR=2) fatal: internal error line 175, file: 
> interpret.h
> ===

It's a bug. The fix is below. I will push it into the repo sometime in
the next few days, along with your test case.

> This works with 3.1.8, 4.0.1, and upto revision
> eb2698f49247c94c84e1e2c2304ba94d96c89bc9 , but fails starting with
> revision b9a82851866f84ca306a2802b4ca50089a2fe683 (which is aptly named
> "First cut at SYMTAB and FUNCTAB.").

Actually, it only "works" in the 3.1.x and 4.0.x by accident. In those
versions SYMTAB is not special and has no effect.

If you change the test case to

        echo a b | ./gawk '{SYMTAB["POS"]=2 ; print $POS}'

you should see the difference. :-)

If you don't understand what I mean then I'll explain in more detail.

Thanks,

Arnold
-----------------------------------------------------------------------
diff --git a/interpret.h b/interpret.h
index 0a30684..c5146fb 100644
--- a/interpret.h
+++ b/interpret.h
@@ -232,7 +232,7 @@ top:
                                        warned = true;
                                        lintwarn(_("SYMTAB is a gawk 
extension"));
                                }
-                               if (r->type == Node_var)
+                               if (r->type == Node_var || r->type == 
Node_var_new)
                                        r = r->var_value;
                        }
 
@@ -559,7 +559,9 @@ mod:
 
                        if (t1 == func_table)
                                fatal(_("cannot assign to elements of 
FUNCTAB"));
-                       else if (t1 == symbol_table && (*lhs)->type == Node_var)
+                       else if (t1 == symbol_table
+                               && (   (*lhs)->type == Node_var
+                                   || (*lhs)->type == Node_var_new))
                                lhs = & ((*lhs)->var_value);
 
                        unref(*lhs);



reply via email to

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