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

@ -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;

View File

@ -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

View File

@ -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);*/