This commit is contained in:
hyung-hwan 2007-12-07 20:48:09 +00:00
parent 240f95de4a
commit da5982c8d3
3 changed files with 46 additions and 13 deletions

View File

@ -660,6 +660,18 @@ int ase_awk_run (ase_awk_t* awk,
/* enter the main run loop */ /* enter the main run loop */
n = run_main (run, main, runarg); n = run_main (run, main, runarg);
if (n == -1) if (n == -1)
{
if (awk->errnum == ASE_AWK_ENOERR)
{
/* an error is returned with no error number set.
* this feature is used by eval_expression to
* abort the evaluation when exit() is executed
* during function evaluation */
n = 0;
run->errlin = 0;
run->errmsg[0] = ASE_T('\0');
}
else
{ {
/* if no callback is specified, awk's error number /* if no callback is specified, awk's error number
* is updated with the run's error number */ * is updated with the run's error number */
@ -677,6 +689,7 @@ int ase_awk_run (ase_awk_t* awk,
ase_awk_seterrnum (awk, ASE_AWK_ERUNTIME); ase_awk_seterrnum (awk, ASE_AWK_ERUNTIME);
} }
} }
}
/* the run loop ended. execute the end callback if it exists */ /* the run loop ended. execute the end callback if it exists */
if (runcbs != ASE_NULL && runcbs->on_end != ASE_NULL) if (runcbs != ASE_NULL && runcbs->on_end != ASE_NULL)
@ -2933,6 +2946,16 @@ static ase_awk_val_t* eval_expression (ase_awk_run_t* run, ase_awk_nde_t* nde)
ase_awk_val_t* v; ase_awk_val_t* v;
int n, errnum; int n, errnum;
if (run->exit_level >= EXIT_GLOBAL)
{
/* returns ASE_NULL as if an error occurred but
* clears the error number. ase_awk_run will
* detect this condition and treat it as a
* non-error condition.*/
run->errnum = ASE_AWK_ENOERR;
return ASE_NULL;
}
v = eval_expression0 (run, nde); v = eval_expression0 (run, nde);
if (v == ASE_NULL) return ASE_NULL; if (v == ASE_NULL) return ASE_NULL;

View File

@ -4,6 +4,16 @@
* enhanced the parser to handle ("abc" ++ k) as ("abc" . ++k) when * enhanced the parser to handle ("abc" ++ k) as ("abc" . ++k) when
ASE_AWK_IMPLICIT is on. ASE_AWK_IMPLICIT is on.
* fixed a memory leak bug in the following context.
BEGIN {
d = 90;
x[30] = d;
/* Reference count for d was not properly decremented
* when a map slot is assigned with the same value as
* the previous value. */
x[30] = d;
}
[0.3.2] [0.3.2]
* fixed a build problem for x64 target in MSVC2005 * fixed a build problem for x64 target in MSVC2005

View File

@ -804,7 +804,7 @@ static int print_awk_value (ase_awk_pair_t* pair, void* arg)
static void on_run_statement ( static void on_run_statement (
ase_awk_run_t* run, ase_size_t line, void* custom) ase_awk_run_t* run, ase_size_t line, void* custom)
{ {
/*dprintf (L"running %d\n", (int)line);*/ dprintf (L"running %d\n", (int)line);
} }
static void on_run_return ( static void on_run_return (
@ -1178,9 +1178,9 @@ static int awk_main (int argc, ase_char_t* argv[])
srcios.custom_data = &src_io; srcios.custom_data = &src_io;
ase_awk_setmaxdepth ( ase_awk_setmaxdepth (
awk, ASE_AWK_DEPTH_BLOCK_PARSE | ASE_AWK_DEPTH_EXPR_PARSE, 20); awk, ASE_AWK_DEPTH_BLOCK_PARSE | ASE_AWK_DEPTH_EXPR_PARSE, 50);
ase_awk_setmaxdepth ( ase_awk_setmaxdepth (
awk, ASE_AWK_DEPTH_BLOCK_RUN | ASE_AWK_DEPTH_EXPR_RUN, 50); awk, ASE_AWK_DEPTH_BLOCK_RUN | ASE_AWK_DEPTH_EXPR_RUN, 1000);
/*ase_awk_setkeyword (awk, ASE_T("func"), 4, ASE_T("FX"), 2);*/ /*ase_awk_setkeyword (awk, ASE_T("func"), 4, ASE_T("FX"), 2);*/