Fix indirect field specification with non-numeric string eg. $("foo").
authorozan yigit <[email protected]>
Tue, 7 Jan 2025 18:53:14 +0000 (7 13:53 -0500)
committerozan yigit <[email protected]>
Tue, 7 Jan 2025 18:53:14 +0000 (7 13:53 -0500)
This is not illegal.

run.c
testdir/T.errmsg

diff --git a/run.c b/run.c
index 0cb75c3..2586f7c 100644 (file)
--- a/run.c
+++ b/run.c
@@ -958,16 +958,12 @@ Cell *indirect(Node **a, int n)   /* $( a[0] ) */
        Awkfloat val;
        Cell *x;
        int m;
-       char *s;
 
        x = execute(a[0]);
        val = getfval(x);       /* freebsd: defend against super large field numbers */
        if ((Awkfloat)INT_MAX < val)
                FATAL("trying to access out of range field %s", x->nval);
        m = (int) val;
-       if (m == 0 && !is_number(s = getsval(x), NULL)) /* suspicion! */
-               FATAL("illegal field $(%s), name \"%s\"", s, x->nval);
-               /* BUG: can x->nval ever be null??? */
        tempfree(x);
        x = fieldadr(m);
        x->ctype = OCELL;       /* BUG?  why are these needed? */
index ee2450a..6609223 100755 (executable)
@@ -100,9 +100,6 @@ non-terminated string
 { print "abc
 }
 
-illegal field $(foo)
-BEGIN { print $"foo" }
-
 next is illegal inside a function
 BEGIN { f() }
 function f() { next }