*** empty log message ***

This commit is contained in:
hyung-hwan 2006-04-20 16:17:01 +00:00
parent 12c435e374
commit fd39be4cc1
3 changed files with 39 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.c,v 1.41 2006-04-16 04:31:38 bacon Exp $ * $Id: awk.c,v 1.42 2006-04-20 16:17:01 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -120,8 +120,34 @@ int xp_awk_close (xp_awk_t* awk)
void xp_awk_clear (xp_awk_t* awk) void xp_awk_clear (xp_awk_t* awk)
{ {
/* clear named variables */
xp_awk_map_clear (&awk->run.named); xp_awk_map_clear (&awk->run.named);
/* destroy run stack */
if (awk->run.stack != XP_NULL)
{
xp_free (awk->run.stack);
awk->run.stack = XP_NULL;
awk->run.stack_top = 0;
awk->run.stack_base = 0;
awk->run.stack_limit = 0;
}
/* destroy values in free list */
while (awk->run.icache_count > 0)
{
--awk->run.icache_count;
xp_awk_freeval (awk,
awk->run.icache[awk->run.icache_count], xp_false);
}
while (awk->run.rcache_count > 0)
{
--awk->run.rcache_count;
xp_awk_freeval (awk,
awk->run.rcache[awk->run.rcache_count], xp_false);
}
xp_awk_tab_clear (&awk->parse.globals); xp_awk_tab_clear (&awk->parse.globals);
xp_awk_tab_clear (&awk->parse.locals); xp_awk_tab_clear (&awk->parse.locals);
xp_awk_tab_clear (&awk->parse.params); xp_awk_tab_clear (&awk->parse.params);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c,v 1.63 2006-04-20 05:44:29 bacon Exp $ * $Id: run.c,v 1.64 2006-04-20 16:17:01 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -1852,7 +1852,7 @@ static xp_awk_val_t* __eval_incpst (xp_awk_t* awk, xp_awk_nde_t* nde)
res2 = xp_awk_makeintval (awk, r + 1); res2 = xp_awk_makeintval (awk, r + 1);
if (res2 == XP_NULL) if (res2 == XP_NULL)
{ {
xp_awk_freeval (awk, res); xp_awk_freeval (awk, res, xp_true);
PANIC (awk, XP_AWK_ENOMEM); PANIC (awk, XP_AWK_ENOMEM);
} }
} }
@ -1865,7 +1865,7 @@ static xp_awk_val_t* __eval_incpst (xp_awk_t* awk, xp_awk_nde_t* nde)
res2 = xp_awk_makerealval (awk, r + 1.0); res2 = xp_awk_makerealval (awk, r + 1.0);
if (res2 == XP_NULL) if (res2 == XP_NULL)
{ {
xp_awk_freeval (awk, res); xp_awk_freeval (awk, res, xp_true);
PANIC (awk, XP_AWK_ENOMEM); PANIC (awk, XP_AWK_ENOMEM);
} }
} }
@ -1886,7 +1886,7 @@ static xp_awk_val_t* __eval_incpst (xp_awk_t* awk, xp_awk_nde_t* nde)
res2 = xp_awk_makeintval (awk, r - 1); res2 = xp_awk_makeintval (awk, r - 1);
if (res2 == XP_NULL) if (res2 == XP_NULL)
{ {
xp_awk_freeval (awk, res); xp_awk_freeval (awk, res, xp_true);
PANIC (awk, XP_AWK_ENOMEM); PANIC (awk, XP_AWK_ENOMEM);
} }
} }
@ -1899,7 +1899,7 @@ static xp_awk_val_t* __eval_incpst (xp_awk_t* awk, xp_awk_nde_t* nde)
res2 = xp_awk_makerealval (awk, r - 1.0); res2 = xp_awk_makerealval (awk, r - 1.0);
if (res2 == XP_NULL) if (res2 == XP_NULL)
{ {
xp_awk_freeval (awk, res); xp_awk_freeval (awk, res, xp_true);
PANIC (awk, XP_AWK_ENOMEM); PANIC (awk, XP_AWK_ENOMEM);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: val.c,v 1.22 2006-04-20 05:44:29 bacon Exp $ * $Id: val.c,v 1.23 2006-04-20 16:17:01 bacon Exp $
*/ */
#include <xp/awk/awk_i.h> #include <xp/awk/awk_i.h>
@ -156,7 +156,7 @@ xp_bool_t xp_awk_isbuiltinval (xp_awk_val_t* val)
val <= (xp_awk_val_t*)&__awk_int[xp_countof(__awk_int)-1]); val <= (xp_awk_val_t*)&__awk_int[xp_countof(__awk_int)-1]);
} }
void xp_awk_freeval (xp_awk_t* awk, xp_awk_val_t* val) void xp_awk_freeval (xp_awk_t* awk, xp_awk_val_t* val, xp_bool_t cache)
{ {
if (xp_awk_isbuiltinval(val)) return; if (xp_awk_isbuiltinval(val)) return;
@ -170,7 +170,8 @@ xp_printf (XP_TEXT("\n"));
return; return;
case XP_AWK_VAL_INT: case XP_AWK_VAL_INT:
if (awk->run.icache_count < xp_countof(awk->run.icache)) if (cache == xp_true &&
awk->run.icache_count < xp_countof(awk->run.icache))
{ {
awk->run.icache[awk->run.icache_count++] = awk->run.icache[awk->run.icache_count++] =
(xp_awk_val_int_t*)val; (xp_awk_val_int_t*)val;
@ -179,7 +180,8 @@ xp_printf (XP_TEXT("\n"));
return; return;
case XP_AWK_VAL_REAL: case XP_AWK_VAL_REAL:
if (awk->run.rcache_count < xp_countof(awk->run.rcache)) if (cache == xp_true &&
awk->run.rcache_count < xp_countof(awk->run.rcache))
{ {
awk->run.rcache[awk->run.rcache_count++] = awk->run.rcache[awk->run.rcache_count++] =
(xp_awk_val_real_t*)val; (xp_awk_val_real_t*)val;
@ -232,7 +234,7 @@ xp_printf (XP_TEXT("**FREEING "));
xp_awk_printval (val); xp_awk_printval (val);
xp_printf (XP_TEXT("\n")); xp_printf (XP_TEXT("\n"));
*/ */
xp_awk_freeval(awk, val); xp_awk_freeval(awk, val, xp_true);
} }
} }