diff options
-rw-r--r-- | editors/awk.c | 3 | ||||
-rwxr-xr-x | testsuite/awk.tests | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/editors/awk.c b/editors/awk.c index b6d8cf203..f2b8b13eb 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -1265,7 +1265,7 @@ static node *parse_expr(uint32_t iexp) | |||
1265 | debug_printf_parse("%s(%x)\n", __func__, iexp); | 1265 | debug_printf_parse("%s(%x)\n", __func__, iexp); |
1266 | 1266 | ||
1267 | sn.info = PRIMASK; | 1267 | sn.info = PRIMASK; |
1268 | sn.r.n = glptr = NULL; | 1268 | sn.r.n = sn.a.n = glptr = NULL; |
1269 | xtc = TC_OPERAND | TC_UOPPRE | TC_REGEXP | iexp; | 1269 | xtc = TC_OPERAND | TC_UOPPRE | TC_REGEXP | iexp; |
1270 | 1270 | ||
1271 | while (!((tc = next_token(xtc)) & iexp)) { | 1271 | while (!((tc = next_token(xtc)) & iexp)) { |
@@ -1287,6 +1287,7 @@ static node *parse_expr(uint32_t iexp) | |||
1287 | || ((t_info == vn->info) && ((t_info & OPCLSMASK) == OC_COLON)) | 1287 | || ((t_info == vn->info) && ((t_info & OPCLSMASK) == OC_COLON)) |
1288 | ) { | 1288 | ) { |
1289 | vn = vn->a.n; | 1289 | vn = vn->a.n; |
1290 | if (!vn->a.n) syntax_error(EMSG_UNEXP_TOKEN); | ||
1290 | } | 1291 | } |
1291 | if ((t_info & OPCLSMASK) == OC_TERNARY) | 1292 | if ((t_info & OPCLSMASK) == OC_TERNARY) |
1292 | t_info += P(6); | 1293 | t_info += P(6); |
diff --git a/testsuite/awk.tests b/testsuite/awk.tests index 3933fefc9..9f353fc10 100755 --- a/testsuite/awk.tests +++ b/testsuite/awk.tests | |||
@@ -338,6 +338,9 @@ testing "awk continue" \ | |||
338 | testing "awk handles invalid for loop" \ | 338 | testing "awk handles invalid for loop" \ |
339 | "awk '{ for() }' 2>&1" "awk: cmd. line:1: Unexpected token\n" "" "" | 339 | "awk '{ for() }' 2>&1" "awk: cmd. line:1: Unexpected token\n" "" "" |
340 | 340 | ||
341 | testing "awk handles colon not preceded by ternary" \ | ||
342 | "awk 'foo:bar:' 2>&1" "awk: cmd. line:1: Unexpected token\n" "" "" | ||
343 | |||
341 | # testing "description" "command" "result" "infile" "stdin" | 344 | # testing "description" "command" "result" "infile" "stdin" |
342 | testing 'awk negative field access' \ | 345 | testing 'awk negative field access' \ |
343 | 'awk 2>&1 -- '\''{ $(-1) }'\' \ | 346 | 'awk 2>&1 -- '\''{ $(-1) }'\' \ |