bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: gawk bug: delete array


From: Aharon Robbins
Subject: Re: gawk bug: delete array
Date: Wed, 7 Mar 2001 09:33:45 +0200

Greetings.  Re this:

> Date: Mon, 05 Mar 2001 18:31:34 +0900
> From: YAMAGUCHI Takanori <address@hidden>
> Subject: gawk bug: delete array
> To: address@hidden, address@hidden
> Cc: address@hidden
>
> Hi,
>
> The following script is core dumped at delete x[y[i]]
> on gawk 3.0.6. It works normally on gawk 3.0.5 or earlier.
>
> I compiled it by using of gcc 2.95.2 on FreeBSD 4.1R and
> gcc 2.95.1 on Solaris 2.7, and the both have the same results.
>
> I'm sorry for my poor English.
>
> BEGIN{
>     x["a"] = "a"
>     x["b"] = "b"
>     x["c"] = "c"
>     x["d"] = "d"
>     x["e"] = "e"
>     x["f"] = "f"
>     x["g"] = "g"
>     y[1] = "c"
>     y[2] = "d"
>     y[3] = "e"
>     for(i in y) delete x[y[i]]
> }
>
> -- 
> YAMAGUCHI Takanori <address@hidden>

The following patch should fix the problem.

Thanks for the bug report.

Arnold Robbins
---------------------------------------------------------------
*** ../gawk-3.0.6/awk.y Sun Jul 16 18:29:50 2000
--- awk.y       Tue Nov 21 16:20:22 2000
***************
*** 398,405 ****
                 * Check that the body is a `delete a[i]' statement,
                 * and that both the loop var and array names match.
                 */
!               if ($8->type == Node_K_delete
                    && $8->rnode != NULL
                    && strcmp($3, $8->rnode->var_value->vname) == 0
                    && strcmp($5, $8->lnode->vname) == 0) {
                        $8->type = Node_K_delete_loop;
--- 398,406 ----
                 * Check that the body is a `delete a[i]' statement,
                 * and that both the loop var and array names match.
                 */
!               if ($8 != NULL && $8->type == Node_K_delete
                    && $8->rnode != NULL
+                   && $8->rnode->type == Node_var
                    && strcmp($3, $8->rnode->var_value->vname) == 0
                    && strcmp($5, $8->lnode->vname) == 0) {
                        $8->type = Node_K_delete_loop;



reply via email to

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