This commit is contained in:
hyung-hwan 2007-12-06 08:10:34 +00:00
parent d066edf575
commit 6a50833e9b
2 changed files with 15 additions and 10 deletions

View File

@ -1380,7 +1380,7 @@ static int run_main (
/* stack set up properly. ready to exeucte statement blocks */
for (nde = run->awk->tree.begin;
n == 0 && nde != ASE_NULL && run->exit_level != EXIT_ABORT;
n == 0 && nde != ASE_NULL && run->exit_level < EXIT_GLOBAL;
nde = nde->next)
{
ase_awk_nde_blk_t* blk;
@ -1396,13 +1396,15 @@ static int run_main (
if (n == 0 &&
(run->awk->tree.chain != ASE_NULL ||
run->awk->tree.end != ASE_NULL) &&
run->exit_level != EXIT_ABORT)
run->exit_level < EXIT_GLOBAL)
{
if (run_pattern_blocks (run) == -1) n = -1;
}
/* the first END block is executed if the program is not
* explicitly aborted with ase_awk_stop */
for (nde = run->awk->tree.end;
n == 0 && nde != ASE_NULL && run->exit_level != EXIT_ABORT;
n == 0 && nde != ASE_NULL && run->exit_level < EXIT_ABORT;
nde = nde->next)
{
ase_awk_nde_blk_t* blk;
@ -1413,6 +1415,12 @@ static int run_main (
run->active_block = blk;
run->exit_level = EXIT_NONE;
if (run_block (run, blk) == -1) n = -1;
else if (run->exit_level >= EXIT_GLOBAL)
{
/* once exit is called inside one of END blocks,
* subsequent END blocks must not be executed */
break;
}
}
/* restore stack */
@ -1477,8 +1485,7 @@ static int run_pattern_blocks (ase_awk_run_t* run)
run->inrec.eof = ase_false;
/* run each pattern block */
while (run->exit_level != EXIT_GLOBAL &&
run->exit_level != EXIT_ABORT)
while (run->exit_level < EXIT_GLOBAL)
{
run->exit_level = EXIT_NONE;
@ -1511,8 +1518,7 @@ static int run_pattern_block_chain (ase_awk_run_t* run, ase_awk_chain_t* chain)
{
ase_size_t block_no = 0;
while (run->exit_level != EXIT_GLOBAL &&
run->exit_level != EXIT_ABORT && chain != ASE_NULL)
while (run->exit_level < EXIT_GLOBAL && chain != ASE_NULL)
{
if (run->exit_level == EXIT_NEXT)
{

View File

@ -10,7 +10,6 @@
#include <ase/utl/stdio.h>
#endif
static ase_char_t* str_to_str (
ase_awk_run_t* run, const ase_char_t* str, ase_size_t str_len,
int opt, ase_str_t* buf, ase_size_t* len);
@ -90,7 +89,7 @@ ase_awk_val_t* ase_awk_makeintval (ase_awk_run_t* run, ase_long_t v)
val->nde = ASE_NULL;
#ifdef DEBUG_VAL
ase_dprintf (ASE_T("makeintval => %p\n"), val);
ase_dprintf (ASE_T("makeintval => %ld [%p]\n"), (long)v, val);
#endif
return (ase_awk_val_t*)val;
}
@ -120,7 +119,7 @@ ase_awk_val_t* ase_awk_makerealval (ase_awk_run_t* run, ase_real_t v)
val->nde = ASE_NULL;
#ifdef DEBUG_VAL
ase_dprintf (ASE_T("makerealval => %p\n"), val);
ase_dprintf (ASE_T("makerealval => %Lf [%p]\n"), (double)v, val);
#endif
return (ase_awk_val_t*)val;
}