bug-gawk
[Top][All Lists]
Advanced

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

Re: inconsistent output for field reference for a number stored as a str


From: arnold
Subject: Re: inconsistent output for field reference for a number stored as a string
Date: Mon, 08 Jun 2020 01:13:51 -0600
User-agent: Heirloom mailx 12.5 7/5/10

Hi.

Ed Morton <mortoneccc@comcast.net> wrote:

>     $ echo 'a b c' | awk '{print $"2"}'
>     a b c

This is definitely a bug.  Here is the fix. Thanks for the report.

Arnold
------------------------
diff --git a/awkgram.y b/awkgram.y
index c427a5b7..2a141d35 100644
--- a/awkgram.y
+++ b/awkgram.y
@@ -1154,7 +1154,7 @@ simple_stmt
                        if ($3 != NULL) {
                                NODE *n = $3->nexti->nexti->memory;
 
-                               if (! iszero(n))
+                               if ((n->flags & (STRING|STRCUR)) != 0 || ! 
iszero(n))
                                        goto regular_print;
 
                                bcfree($3->lasti);                      /* 
Op_field_spec */



reply via email to

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