check for multiple @pragma startup directives at the top-level source

This commit is contained in:
hyung-hwan 2020-01-11 16:01:52 +00:00
parent cf741c1525
commit 3e86ce4ab2

View File

@ -1035,11 +1035,13 @@ static int parse_progunit (hawk_t* awk)
if (awk->sio.inp == &awk->sio.arg) if (awk->sio.inp == &awk->sio.arg)
{ {
/* only the top level source */ /* 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_seterrfmt (awk, &awk->tok.loc, HAWK_EEXIST, HAWK_T("@pragma startup already set"));
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)); 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 else