From 3e86ce4ab2c3e3eb53d2a47bc079e16200ab60ef Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Sat, 11 Jan 2020 16:01:52 +0000 Subject: [PATCH] check for multiple @pragma startup directives at the top-level source --- hawk/lib/parse.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hawk/lib/parse.c b/hawk/lib/parse.c index f30b9f8c..9cd26d48 100644 --- a/hawk/lib/parse.c +++ b/hawk/lib/parse.c @@ -1035,11 +1035,13 @@ static int parse_progunit (hawk_t* awk) if (awk->sio.inp == &awk->sio.arg) { /* only the top level source */ - if (awk->parse.pragma.startup[0] == '\0') + if (awk->parse.pragma.startup[0] != '\0') { - /* honor the first encounter only */ - hawk_copy_oochars_to_oocstr (awk->parse.pragma.startup, HAWK_COUNTOF(awk->parse.pragma.startup), HAWK_OOECS_PTR(awk->tok.name), HAWK_OOECS_LEN(awk->tok.name)); + hawk_seterrfmt (awk, &awk->tok.loc, HAWK_EEXIST, HAWK_T("@pragma startup already set")); + return -1; } + + hawk_copy_oochars_to_oocstr (awk->parse.pragma.startup, HAWK_COUNTOF(awk->parse.pragma.startup), HAWK_OOECS_PTR(awk->tok.name), HAWK_OOECS_LEN(awk->tok.name)); } } else