From bc06fd0557774e379144fb6646a9c3c193f03d92 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 14 Jul 2006 05:21:30 +0000 Subject: [PATCH] *** empty log message *** --- ase/awk/func.c | 17 +++-------------- ase/awk/func.h | 4 ++-- ase/awk/parse.c | 5 +++-- ase/awk/tree.c | 5 ++--- ase/awk/tree.h | 3 ++- 5 files changed, 12 insertions(+), 22 deletions(-) diff --git a/ase/awk/func.c b/ase/awk/func.c index 2441dd2b..e958f2e5 100644 --- a/ase/awk/func.c +++ b/ase/awk/func.c @@ -1,5 +1,5 @@ /* - * $Id: func.c,v 1.9 2006-07-14 04:19:21 bacon Exp $ + * $Id: func.c,v 1.10 2006-07-14 05:21:30 bacon Exp $ */ #include @@ -21,8 +21,6 @@ static xp_awk_bfn_t __sys_bfn[] = { XP_NULL, 0, 0, 0, XP_NULL } }; -static xp_awk_bfn_t* __usr_bfn = XP_NULL; - xp_awk_bfn_t* xp_awk_addbfn ( xp_awk_t* awk, const xp_char_t* name, int when_valid, xp_size_t min_args, xp_size_t max_args, int (*handler)(void*)) @@ -34,13 +32,8 @@ xp_awk_bfn_t* xp_awk_addbfn ( p = (xp_awk_bfn_t*) xp_malloc (xp_sizeof(xp_awk_bfn_t)); if (p == XP_NULL) return XP_NULL; - p->name = xp_strdup(name); - if (p->name == XP_NULL) - { - xp_free (p); - return XP_NULL; - } - + /* NOTE: make sure that name is a constant string */ + p->name = name; p->valid = when_valid; p->min_args = min_args; p->max_args = max_args; @@ -64,7 +57,6 @@ int xp_awk_delbfn (xp_awk_t* awk, const xp_char_t* name) awk->bfn.user = p->next; else pp->next = p->next; - xp_free (p->name); xp_free (p); return 0; } @@ -83,10 +75,7 @@ void xp_awk_clrbfn (xp_awk_t* awk) while (p != XP_NULL) { np = p; - - xp_free (p->name); xp_free (p); - p = np; } diff --git a/ase/awk/func.h b/ase/awk/func.h index 07d21abb..53d80d6b 100644 --- a/ase/awk/func.h +++ b/ase/awk/func.h @@ -1,5 +1,5 @@ /* - * $Id: func.h,v 1.5 2006-07-14 04:19:21 bacon Exp $ + * $Id: func.h,v 1.6 2006-07-14 05:21:30 bacon Exp $ */ #ifndef _XP_AWK_FUNC_H_ @@ -13,7 +13,7 @@ typedef struct xp_awk_bfn_t xp_awk_bfn_t; struct xp_awk_bfn_t { - xp_char_t* name; + const xp_char_t* name; int valid; /* the entry is valid when this option is set */ xp_size_t min_args; diff --git a/ase/awk/parse.c b/ase/awk/parse.c index cbaad365..d1f7082a 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -1,5 +1,5 @@ /* - * $Id: parse.c,v 1.136 2006-07-14 04:19:21 bacon Exp $ + * $Id: parse.c,v 1.137 2006-07-14 05:21:30 bacon Exp $ */ #include @@ -2425,9 +2425,10 @@ static xp_awk_nde_t* __parse_fncall ( call->next = XP_NULL; /*call->what.bfn = bfn; */ + call->what.bfn.name = bfn->name; call->what.bfn.min_args = bfn->min_args; call->what.bfn.max_args = bfn->max_args; - call->what.bfn.handler = bfn->handler; + call->what.bfn.handler = bfn->handler; call->args = head; call->nargs = nargs; diff --git a/ase/awk/tree.c b/ase/awk/tree.c index e13f62ee..0dcbaa9c 100644 --- a/ase/awk/tree.c +++ b/ase/awk/tree.c @@ -1,5 +1,5 @@ /* - * $Id: tree.c,v 1.64 2006-07-14 04:19:22 bacon Exp $ + * $Id: tree.c,v 1.65 2006-07-14 05:21:30 bacon Exp $ */ #include @@ -350,8 +350,7 @@ static int __print_expression (xp_awk_nde_t* nde) case XP_AWK_NDE_BFN: { xp_awk_nde_call_t* px = (xp_awk_nde_call_t*)nde; - /*xp_printf (XP_T("%s ("), px->what.bfn->name);*/ - xp_printf (XP_T("__bfn (")); + xp_printf (XP_T("%s ("), px->what.bfn.name); if (__print_expression_list (px->args) == -1) return -1; xp_printf (XP_T(")")); break; diff --git a/ase/awk/tree.h b/ase/awk/tree.h index 1324ccc8..432882df 100644 --- a/ase/awk/tree.h +++ b/ase/awk/tree.h @@ -1,5 +1,5 @@ /* - * $Id: tree.h,v 1.59 2006-07-14 04:19:22 bacon Exp $ + * $Id: tree.h,v 1.60 2006-07-14 05:21:30 bacon Exp $ */ #ifndef _XP_AWK_TREE_H_ @@ -237,6 +237,7 @@ struct xp_awk_nde_call_t * needed during run-time. */ struct { + const xp_char_t* name; xp_size_t min_args; xp_size_t max_args; int (*handler) (void* run);