From f5a2f5d70f6c88ce5cded0be603770219782e457 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 20 Dec 2007 08:37:04 +0000 Subject: [PATCH] --- ase/awk/parse.c | 64 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/ase/awk/parse.c b/ase/awk/parse.c index 74534970..89ef0367 100644 --- a/ase/awk/parse.c +++ b/ase/awk/parse.c @@ -839,7 +839,6 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk) return ASE_NULL; } - #if 0 if (awk->option & ASE_AWK_UNIQUEFN) { /* check if it coincides to be a global variable name */ @@ -852,7 +851,6 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk) return ASE_NULL; } } - #endif /* clone the function name before it is overwritten */ name_dup = ase_awk_strxdup (awk, name, name_len); @@ -917,7 +915,6 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk) param = ASE_STR_BUF(&awk->token.name); param_len = ASE_STR_LEN(&awk->token.name); - #if 0 if (awk->option & ASE_AWK_UNIQUEFN) { /* check if a parameter conflicts with a function */ @@ -940,7 +937,6 @@ static ase_awk_nde_t* parse_function (ase_awk_t* awk) * x in print x is a parameter */ } - #endif /* check if a parameter conflicts with other parameters */ if (ase_awk_tab_find ( @@ -1437,7 +1433,6 @@ static int add_global ( { ase_size_t nglobals; - #if 0 if (awk->option & ASE_AWK_UNIQUEFN) { /* check if it conflict with a builtin function name */ @@ -1457,8 +1452,17 @@ static int add_global ( name, len); return -1; } + + /* check if it conflict with a function name + * caught in the function call table */ + if (ase_awk_tab_find (&awk->parse.afns, 0, name, len) != (ase_size_t)-1) + { + SETERRARG ( + awk, ASE_AWK_EAFNRED, line, + name, len); + return -1; + } } - #endif /* check if it conflicts with other global variable names */ if (find_global (awk, name, len) != (ase_size_t)-1) @@ -1603,7 +1607,6 @@ static ase_awk_t* collect_locals (ase_awk_t* awk, ase_size_t nlocals) local = ASE_STR_BUF(&awk->token.name); local_len = ASE_STR_LEN(&awk->token.name); - #if 0 if (awk->option & ASE_AWK_UNIQUEFN) { ase_bool_t iscur = ase_false; @@ -1632,8 +1635,17 @@ static ase_awk_t* collect_locals (ase_awk_t* awk, ase_size_t nlocals) local, local_len); return ASE_NULL; } + + /* check if it conflict with a function name + * caught in the function call table */ + if (ase_awk_tab_find (&awk->parse.afns, 0, local, local_len) != (ase_size_t)-1) + { + SETERRARG ( + awk, ASE_AWK_EAFNRED, awk->token.line, + local, local_len); + return ASE_NULL; + } } - #endif /* check if it conflicts with a paremeter name */ n = ase_awk_tab_find (&awk->parse.params, 0, local, local_len); @@ -3154,10 +3166,9 @@ static ase_awk_nde_t* parse_primary_ident (ase_awk_t* awk, ase_size_t line) if (awk->option & ASE_AWK_IMPLICIT) { - #if 0 if (awk->option & ASE_AWK_UNIQUEFN) { - ase_bool_t iscur; + ase_bool_t iscur = ase_false; /* the name should not conflict with a function name */ /* check if it is a builtin function */ @@ -3181,8 +3192,13 @@ static ase_awk_nde_t* parse_primary_ident (ase_awk_t* awk, ase_size_t line) SETERRARG (awk, ASE_AWK_EAFNRED, line, name_dup, name_len); goto exit_func; } + + if (ase_awk_tab_find (&awk->parse.afns, 0, name_dup, name_len) != (ase_size_t)-1) + { + SETERRARG (awk, ASE_AWK_EAFNRED, line, name_dup, name_len); + goto exit_func; + } } - #endif nde->type = ASE_AWK_NDE_NAMED; nde->line = line; @@ -3319,7 +3335,6 @@ static ase_awk_nde_t* parse_hashidx ( if (awk->option & ASE_AWK_IMPLICIT) { - #if 0 if (awk->option & ASE_AWK_UNIQUEFN) { ase_bool_t iscur = ase_false; @@ -3345,8 +3360,13 @@ static ase_awk_nde_t* parse_hashidx ( SETERRARG (awk, ASE_AWK_EAFNRED, line, name, name_len); goto exit_func; } + + if (ase_awk_tab_find (&awk->parse.afns, 0, name, name_len) != (ase_size_t)-1) + { + SETERRARG (awk, ASE_AWK_EAFNRED, line, name, name_len); + goto exit_func; + } } - #endif nde->type = ASE_AWK_NDE_NAMEDIDX; nde->line = line; @@ -3481,14 +3501,18 @@ static ase_awk_nde_t* parse_fncall ( call->args = head; call->nargs = nargs; - if ((awk->option & ASE_AWK_EXPLICIT) && - !(awk->option & ASE_AWK_IMPLICIT) && - ase_awk_tab_adduniq (&awk->parse.afns, name, name_len) == (ase_size_t)-1) + if (((awk->option & ASE_AWK_EXPLICIT) && + !(awk->option & ASE_AWK_IMPLICIT)) || + (awk->option & ASE_AWK_UNIQUEFN)) { - ASE_AWK_FREE (awk, call); - if (head != ASE_NULL) ase_awk_clrpt (awk, head); - SETERRLIN (awk, ASE_AWK_ENOMEM, line); - return ASE_NULL; + if (ase_awk_tab_adduniq ( + &awk->parse.afns, name, name_len) == (ase_size_t)-1) + { + ASE_AWK_FREE (awk, call); + if (head != ASE_NULL) ase_awk_clrpt (awk, head); + SETERRLIN (awk, ASE_AWK_ENOMEM, line); + return ASE_NULL; + } } }