diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2015-01-30 10:06:16 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2015-01-30 10:06:16 +0200 |
commit | 1bd1b885c7dd16b5e4ab78c040312f6f7d742784 (patch) | |
tree | d7e1c0c8dfdf4002d9a0c7f4bf634cafe2663a42 /awkgram.y | |
parent | 5153d0f04b7ad460b23ae5a011061f7b93a122ef (diff) | |
download | egawk-1bd1b885c7dd16b5e4ab78c040312f6f7d742784.tar.gz egawk-1bd1b885c7dd16b5e4ab78c040312f6f7d742784.tar.bz2 egawk-1bd1b885c7dd16b5e4ab78c040312f6f7d742784.zip |
Disallow calling a function parameter. Check params are not function names.
Diffstat (limited to 'awkgram.y')
-rw-r--r-- | awkgram.y | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -85,6 +85,7 @@ static void check_funcs(void); static ssize_t read_one_line(int fd, void *buffer, size_t count); static int one_line_close(int fd); +static bool at_seen = false; static bool want_source = false; static bool want_regexp = false; /* lexical scanning kludge */ static char *in_function; /* parsing kludge */ @@ -239,11 +240,13 @@ rule | '@' LEX_INCLUDE source statement_term { want_source = false; + at_seen = false; yyerrok; } | '@' LEX_LOAD library statement_term { want_source = false; + at_seen = false; yyerrok; } ; @@ -367,7 +370,10 @@ func_name YYABORT; } | '@' LEX_EVAL - { $$ = $2; } + { + $$ = $2; + at_seen = false; + } ; lex_builtin @@ -1612,12 +1618,24 @@ func_call */ $$ = list_prepend($2, t); + at_seen = false; } ; direct_func_call : FUNC_CALL '(' opt_expression_list r_paren { + NODE *n; + + if (! at_seen) { + n = lookup($1->func_name); + if (n != NULL && n->type != Node_func + && n->type != Node_ext_func && n->type != Node_old_ext_func) { + error_ln($1->source_line, + _("attempt to use non-function `%s' in function call"), + $1->func_name); + } + } param_sanity($3); $1->opcode = Op_func_call; $1->func_body = NULL; @@ -2304,6 +2322,9 @@ parse_program(INSTRUCTION **pcode) if (ret == 0) /* avoid spurious warning if parser aborted with YYABORT */ check_funcs(); + if (! check_param_names()) + errcount++; + if (args_array == NULL) emalloc(args_array, NODE **, (max_args + 2) * sizeof(NODE *), "parse_program"); else @@ -3114,6 +3135,7 @@ retry: return lasttok = NEWLINE; case '@': + at_seen = true; return lasttok = '@'; case '\\': |