aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/editors/awk.c b/editors/awk.c
index f2b8b13eb..90edec82c 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -275,18 +275,21 @@ typedef struct tsplitter_s {
275 | TC_STRING | TC_NUMBER | TC_UOPPOST) 275 | TC_STRING | TC_NUMBER | TC_UOPPOST)
276#define TC_CONCAT2 (TC_OPERAND | TC_UOPPRE) 276#define TC_CONCAT2 (TC_OPERAND | TC_UOPPRE)
277 277
278#define OF_RES1 0x010000 278#define OF_RES1 0x010000
279#define OF_RES2 0x020000 279#define OF_RES2 0x020000
280#define OF_STR1 0x040000 280#define OF_STR1 0x040000
281#define OF_STR2 0x080000 281#define OF_STR2 0x080000
282#define OF_NUM1 0x100000 282#define OF_NUM1 0x100000
283#define OF_CHECKED 0x200000 283#define OF_CHECKED 0x200000
284#define OF_REQUIRED 0x400000
285
284 286
285/* combined operator flags */ 287/* combined operator flags */
286#define xx 0 288#define xx 0
287#define xV OF_RES2 289#define xV OF_RES2
288#define xS (OF_RES2 | OF_STR2) 290#define xS (OF_RES2 | OF_STR2)
289#define Vx OF_RES1 291#define Vx OF_RES1
292#define Rx (OF_RES1 | OF_NUM1 | OF_REQUIRED)
290#define VV (OF_RES1 | OF_RES2) 293#define VV (OF_RES1 | OF_RES2)
291#define Nx (OF_RES1 | OF_NUM1) 294#define Nx (OF_RES1 | OF_NUM1)
292#define NV (OF_RES1 | OF_NUM1 | OF_RES2) 295#define NV (OF_RES1 | OF_NUM1 | OF_RES2)
@@ -425,7 +428,7 @@ static const uint32_t tokeninfo[] = {
425 0, 428 0,
426 0, /* \n */ 429 0, /* \n */
427 ST_IF, ST_DO, ST_FOR, OC_BREAK, 430 ST_IF, ST_DO, ST_FOR, OC_BREAK,
428 OC_CONTINUE, OC_DELETE|Vx, OC_PRINT, 431 OC_CONTINUE, OC_DELETE|Rx, OC_PRINT,
429 OC_PRINTF, OC_NEXT, OC_NEXTFILE, 432 OC_PRINTF, OC_NEXT, OC_NEXTFILE,
430 OC_RETURN|Vx, OC_EXIT|Nx, 433 OC_RETURN|Vx, OC_EXIT|Nx,
431 ST_WHILE, 434 ST_WHILE,
@@ -593,7 +596,7 @@ static const char EMSG_UNEXP_EOS[] ALIGN1 = "Unexpected end of string";
593static const char EMSG_UNEXP_TOKEN[] ALIGN1 = "Unexpected token"; 596static const char EMSG_UNEXP_TOKEN[] ALIGN1 = "Unexpected token";
594static const char EMSG_DIV_BY_ZERO[] ALIGN1 = "Division by zero"; 597static const char EMSG_DIV_BY_ZERO[] ALIGN1 = "Division by zero";
595static const char EMSG_INV_FMT[] ALIGN1 = "Invalid format specifier"; 598static const char EMSG_INV_FMT[] ALIGN1 = "Invalid format specifier";
596static const char EMSG_TOO_FEW_ARGS[] ALIGN1 = "Too few arguments for builtin"; 599static const char EMSG_TOO_FEW_ARGS[] ALIGN1 = "Too few arguments";
597static const char EMSG_NOT_ARRAY[] ALIGN1 = "Not an array"; 600static const char EMSG_NOT_ARRAY[] ALIGN1 = "Not an array";
598static const char EMSG_POSSIBLE_ERROR[] ALIGN1 = "Possible syntax error"; 601static const char EMSG_POSSIBLE_ERROR[] ALIGN1 = "Possible syntax error";
599static const char EMSG_UNDEF_FUNC[] ALIGN1 = "Call to undefined function"; 602static const char EMSG_UNDEF_FUNC[] ALIGN1 = "Call to undefined function";
@@ -1426,7 +1429,11 @@ static void chain_expr(uint32_t info)
1426 node *n; 1429 node *n;
1427 1430
1428 n = chain_node(info); 1431 n = chain_node(info);
1432
1429 n->l.n = parse_expr(TC_OPTERM | TC_GRPTERM); 1433 n->l.n = parse_expr(TC_OPTERM | TC_GRPTERM);
1434 if ((info & OF_REQUIRED) && !n->l.n)
1435 syntax_error(EMSG_TOO_FEW_ARGS);
1436
1430 if (t_tclass & TC_GRPTERM) 1437 if (t_tclass & TC_GRPTERM)
1431 rollback_token(); 1438 rollback_token();
1432} 1439}