diff options
author | Alexander Shishkin | 2010-02-25 17:55:40 +0200 |
---|---|---|
committer | Denys Vlasenko | 2010-02-26 08:48:56 +0100 |
commit | d03cd3be241d38e6edbe5329a53b276eeaa7528e (patch) | |
tree | 6e5c60bdbb0a655c7ac3a691a9ebef9bcd2b4494 | |
parent | 2e73d84c02c6dd4945838665ce0167bddbb7f1c8 (diff) | |
download | busybox-d03cd3be241d38e6edbe5329a53b276eeaa7528e.zip busybox-d03cd3be241d38e6edbe5329a53b276eeaa7528e.tar.gz |
awk: skip whitespace between array name and subscript
It is supported in both mawk and gawk and there are actually scripts
out there that use this "flexibility".
function old new delta
next_token 1144 1152 +8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 8/0) Total: 8 bytes
Signed-off-by: Alexander Shishkin <virtuoso@slind.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/awk.c | 2 | ||||
-rwxr-xr-x | testsuite/awk.tests | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/editors/awk.c b/editors/awk.c index bc8b0da..b9bc01f 100644 --- a/editors/awk.c +++ b/editors/awk.c @@ -1046,7 +1046,7 @@ static uint32_t next_token(uint32_t expected) *(p-1) = '\0'; tc = TC_VARIABLE; /* also consume whitespace between functionname and bracket */ - if (!(expected & TC_VARIABLE)) + if (!(expected & TC_VARIABLE) || (expected & TC_ARRAY)) skip_spaces(&p); if (*p == '(') { tc = TC_FUNCTION; diff --git a/testsuite/awk.tests b/testsuite/awk.tests index 7910c88..03d4649 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests @@ -64,4 +64,7 @@ testing "awk string cast (bug 725)" \ "0\nnumber\n" \ "" "" +testing "awk handles whitespace before array subscript" \ + "awk 'BEGIN { arr [3] = 1; print arr [3] }'" "1\n" "" "" + exit $FAILCOUNT |