From da5982c8d346b81c279ea21e128cf9e1ff084c70 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 7 Dec 2007 20:48:09 +0000 Subject: [PATCH] --- ase/awk/run.c | 43 +++++++++++++++++++++++++++++++++---------- ase/change.log | 10 ++++++++++ ase/test/awk/awk.c | 6 +++--- 3 files changed, 46 insertions(+), 13 deletions(-) diff --git a/ase/awk/run.c b/ase/awk/run.c index f159adf6..e9745e3a 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -661,20 +661,33 @@ int ase_awk_run (ase_awk_t* awk, n = run_main (run, main, runarg); if (n == -1) { - /* if no callback is specified, awk's error number - * is updated with the run's error number */ - if (runcbs == ASE_NULL) + if (awk->errnum == ASE_AWK_ENOERR) { - awk->errnum = run->errnum; - awk->errlin = run->errlin; - - ase_strxcpy ( - awk->errmsg, ASE_COUNTOF(awk->errmsg), - run->errmsg); + /* 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 { - ase_awk_seterrnum (awk, ASE_AWK_ERUNTIME); + /* if no callback is specified, awk's error number + * is updated with the run's error number */ + if (runcbs == ASE_NULL) + { + awk->errnum = run->errnum; + awk->errlin = run->errlin; + + ase_strxcpy ( + awk->errmsg, ASE_COUNTOF(awk->errmsg), + run->errmsg); + } + else + { + ase_awk_seterrnum (awk, ASE_AWK_ERUNTIME); + } } } @@ -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; 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); if (v == ASE_NULL) return ASE_NULL; diff --git a/ase/change.log b/ase/change.log index 7b239569..898d98cd 100644 --- a/ase/change.log +++ b/ase/change.log @@ -4,6 +4,16 @@ * enhanced the parser to handle ("abc" ++ k) as ("abc" . ++k) when 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] * fixed a build problem for x64 target in MSVC2005 diff --git a/ase/test/awk/awk.c b/ase/test/awk/awk.c index 754b63e8..c2242631 100644 --- a/ase/test/awk/awk.c +++ b/ase/test/awk/awk.c @@ -804,7 +804,7 @@ static int print_awk_value (ase_awk_pair_t* pair, void* arg) static void on_run_statement ( 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 ( @@ -1178,9 +1178,9 @@ static int awk_main (int argc, ase_char_t* argv[]) srcios.custom_data = &src_io; 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 ( - 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);*/