From f93a7f43457fd79e00c91f48636d8f9bd312e2c0 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 27 Mar 2006 14:14:00 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/awk.c | 11 +++++------ ase/awk/map.c | 12 ++++++------ ase/awk/map.h | 8 +++++--- ase/awk/run.c | 6 ++++-- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/ase/awk/awk.c b/ase/awk/awk.c index cb31cab1..bd184ce5 100644 --- a/ase/awk/awk.c +++ b/ase/awk/awk.c @@ -1,5 +1,5 @@ /* - * $Id: awk.c,v 1.33 2006-03-27 11:43:17 bacon Exp $ + * $Id: awk.c,v 1.34 2006-03-27 14:14:00 bacon Exp $ */ #include @@ -9,7 +9,7 @@ #include #endif -static void __free_func (void* func); +static void __free_func (xp_awk_t* awk, void* func); xp_awk_t* xp_awk_open (xp_awk_t* awk) { @@ -25,7 +25,7 @@ xp_awk_t* xp_awk_open (xp_awk_t* awk) return XP_NULL; } - if (xp_awk_map_open(&awk->tree.funcs, 256, __free_func) == XP_NULL) { + if (xp_awk_map_open (&awk->tree.funcs, awk, 256, __free_func) == XP_NULL) { xp_str_close (&awk->token.name); if (awk->__dynamic) xp_free (awk); return XP_NULL; @@ -56,8 +56,7 @@ xp_awk_t* xp_awk_open (xp_awk_t* awk) } // TODO: initial map size... - if (xp_awk_map_open(&awk->run.named, - 256, (void(*)(void*))xp_awk_refdownval) == XP_NULL) { + if (xp_awk_map_open(&awk->run.named,awk,256,xp_awk_refdownval) == XP_NULL) { xp_str_close (&awk->token.name); xp_awk_map_close (&awk->tree.funcs); xp_awk_tab_close (&awk->parse.globals); @@ -189,7 +188,7 @@ int xp_awk_detsrc (xp_awk_t* awk) return 0; } -static void __free_func (void* func) +static void __free_func (xp_awk_t* awk, void* func) { xp_awk_func_t* f = (xp_awk_func_t*) func; diff --git a/ase/awk/map.c b/ase/awk/map.c index 1172eb8d..75f0b00f 100644 --- a/ase/awk/map.c +++ b/ase/awk/map.c @@ -1,5 +1,5 @@ /* - * $Id: map.c,v 1.7 2006-03-07 16:09:18 bacon Exp $ + * $Id: map.c,v 1.8 2006-03-27 14:14:00 bacon Exp $ */ #include @@ -20,12 +20,13 @@ static xp_size_t __hash (const xp_char_t* key); { \ xp_free ((xp_char_t*)(pair)->key); \ if ((map)->freeval != XP_NULL) \ - (map)->freeval ((pair)->val); \ + (map)->freeval ((map)->awk, (pair)->val); \ xp_free (pair); \ } while (0) xp_awk_map_t* xp_awk_map_open ( - xp_awk_map_t* map, xp_size_t capa, void (*freeval) (void*)) + xp_awk_map_t* map, xp_awk_t* awk, + xp_size_t capa, void(*freeval)(xp_awk_t*,void*)) { if (map == XP_NULL) { @@ -43,6 +44,7 @@ xp_awk_map_t* xp_awk_map_open ( return XP_NULL; } + map->awk = awk; map->capa = capa; map->size = 0; map->freeval = freeval; @@ -70,10 +72,8 @@ void xp_awk_map_clear (xp_awk_map_t* map) while (pair != XP_NULL) { next = pair->next; - FREE_PAIR (map, pair); map->size--; - pair = next; } @@ -180,7 +180,7 @@ xp_awk_pair_t* xp_awk_map_setpair ( { if (map->freeval != XP_NULL) { - map->freeval (pair->val); + map->freeval (map->awk, pair->val); } pair->val = val; } diff --git a/ase/awk/map.h b/ase/awk/map.h index eec2340d..6127a909 100644 --- a/ase/awk/map.h +++ b/ase/awk/map.h @@ -1,5 +1,5 @@ /* - * $Id: map.h,v 1.5 2006-03-07 15:55:14 bacon Exp $ + * $Id: map.h,v 1.6 2006-03-27 14:14:00 bacon Exp $ */ #ifndef _XP_AWK_MAP_H_ @@ -28,10 +28,11 @@ struct xp_awk_pair_t struct xp_awk_map_t { + xp_awk_t* awk; xp_size_t size; xp_size_t capa; xp_awk_pair_t** buck; - void (*freeval) (void*); + void (*freeval) (xp_awk_t*,void*); xp_bool_t __dynamic; }; @@ -40,7 +41,8 @@ extern "C" { #endif xp_awk_map_t* xp_awk_map_open ( - xp_awk_map_t* map, xp_size_t capa, void (*freeval) (void*)); + xp_awk_map_t* map, xp_awk_t* awk, + xp_size_t capa, void(*freeval)(xp_awk_t*,void*)); void xp_awk_map_close (xp_awk_map_t* map); void xp_awk_map_clear (xp_awk_map_t* map); diff --git a/ase/awk/run.c b/ase/awk/run.c index 4a7b3872..c747f332 100644 --- a/ase/awk/run.c +++ b/ase/awk/run.c @@ -1,5 +1,5 @@ /* - * $Id: run.c,v 1.21 2006-03-27 11:43:17 bacon Exp $ + * $Id: run.c,v 1.22 2006-03-27 14:14:00 bacon Exp $ */ #include @@ -481,7 +481,9 @@ static xp_awk_val_t* __eval_expression (xp_awk_t* awk, xp_awk_nde_t* nde) break; default: - /* somthing wrong */ + /* somthing wrong. internal error */ + /* TODO: set the error code instead of assertion below */ + xp_assert (XP_TEXT("should never happen") == XP_NULL); return XP_NULL; }