diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2011-03-29 21:30:11 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2011-03-29 21:30:11 +0200 |
commit | 86d89c929013e64bf4e4b28af2facd549c3bfaba (patch) | |
tree | c3647d3c41cf3f363288d878269073aff4124cca /awkgram.y | |
parent | 2400cc5143383a881356a9f55e93b60037d851e5 (diff) | |
download | egawk-86d89c929013e64bf4e4b28af2facd549c3bfaba.tar.gz egawk-86d89c929013e64bf4e4b28af2facd549c3bfaba.tar.bz2 egawk-86d89c929013e64bf4e4b28af2facd549c3bfaba.zip |
Fix next and exit from functions.
Diffstat (limited to 'awkgram.y')
-rw-r--r-- | awkgram.y | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -824,7 +824,8 @@ non_compound_stmt } | LEX_NEXT statement_term { - if (rule != Rule) + /* if inside function (rule = 0), resolve context at run-time */ + if (rule && rule != Rule) error_ln($1->source_line, _("`next' used in %s action"), ruletab[rule]); $1->target_jmp = ip_rec; @@ -835,6 +836,8 @@ non_compound_stmt if (do_traditional) error_ln($1->source_line, _("`nextfile' is a gawk extension")); + + /* if inside function (rule = 0), resolve context at run-time */ if (rule == BEGIN || rule == END || rule == ENDFILE) error_ln($1->source_line, _("`nextfile' used in %s action"), ruletab[rule]); @@ -845,10 +848,11 @@ non_compound_stmt } | LEX_EXIT opt_exp statement_term { - if (rule == END) - $1->target_jmp = ip_atexit; - else - $1->target_jmp = ip_end; /* first instruction (no-op) in end block */ + /* Initialize the two possible jump targets, the actual target + * is resolved at run-time. + */ + $1->target_end = ip_end; /* first instruction in end_block */ + $1->target_atexit = ip_atexit; /* cleanup and go home */ if ($2 == NULL) { $$ = list_create($1); |