From 1c42c18e9601ee1416d61663f5a91874954c524d Mon Sep 17 00:00:00 2001 From: Brian Foley Date: Sun, 6 Jan 2019 18:32:59 -0800 Subject: awk: Fix overly permissive func arg list parsing It allows things like 'func f(a b)' and 'func f(a,)' which GNU awk forbids. function old new delta parse_program 327 367 +40 chain_expr 40 67 +27 parse_expr 891 915 +24 EMSG_TOO_FEW_ARGS 30 18 -12 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 91/-12) Total: 79 bytes Signed-off-by: Brian Foley Signed-off-by: Denys Vlasenko --- testsuite/awk.tests | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'testsuite/awk.tests') diff --git a/testsuite/awk.tests b/testsuite/awk.tests index 03fedf771..0db6a26e4 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests @@ -280,6 +280,18 @@ testing "awk 'delete a[v--]' evaluates v-- once" \ " \ "" "" +testing "awk func arg parsing 1" \ + "awk 'func f(,) { }' 2>&1" "awk: cmd. line:1: Unexpected token\n" "" "" + +testing "awk func arg parsing 2" \ + "awk 'func f(a,,b) { }' 2>&1" "awk: cmd. line:1: Unexpected token\n" "" "" + +testing "awk func arg parsing 3" \ + "awk 'func f(a,) { }' 2>&1" "awk: cmd. line:1: Unexpected token\n" "" "" + +testing "awk func arg parsing 4" \ + "awk 'func f(a b) { }' 2>&1" "awk: cmd. line:1: Unexpected token\n" "" "" + testing "awk handles empty ()" \ "awk 'BEGIN {print()}' 2>&1" "awk: cmd. line:1: Empty sequence\n" "" "" -- cgit v1.2.3