X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fexpr-prs.c;h=fee00a3e93e1525917485f15cf7726c3a0245f8b;hb=e22db86f67a3b77124af022bbd734922c62c424c;hp=3d5973950695d22aa553442ee4396988b09d9f7f;hpb=7fa020a6e6a7807bbc810576cbf4fcea56c98d44;p=pspp diff --git a/src/expr-prs.c b/src/expr-prs.c index 3d59739506..fee00a3e93 100644 --- a/src/expr-prs.c +++ b/src/expr-prs.c @@ -18,6 +18,8 @@ 02111-1307, USA. */ #include +#include "expr.h" +#include "exprP.h" #include #include #include @@ -25,14 +27,12 @@ #include "algorithm.h" #include "alloc.h" #include "error.h" -#include "expr.h" -#include "exprP.h" #include "lexer.h" #include "misc.h" #include "str.h" #include "var.h" -#include "vector.h" #include "vfm.h" +#include "pool.h" /* Declarations. */ @@ -82,7 +82,7 @@ expr_free (struct expression *e) free (e->num); free (e->str); free (e->stack); - free (e->str_stack); + pool_destroy (e->pool); free (e); } @@ -624,7 +624,7 @@ parse_primary (union any_node **n) } /* Otherwise, it must be a user variable. */ - v = find_variable (tokid); + v = dict_lookup_var (default_dict, tokid); lex_get (); if (v == NULL) { @@ -691,7 +691,7 @@ static int func_count; static int get_num_args (struct function *, int, union any_node **); static int -unary_func (struct function * f, int x unused, union any_node ** n) +unary_func (struct function * f, int x UNUSED, union any_node ** n) { double divisor; struct nonterm_node *c; @@ -739,7 +739,7 @@ multiply: } static int -binary_func (struct function * f, int x unused, union any_node ** n) +binary_func (struct function * f, int x UNUSED, union any_node ** n) { if (!get_num_args (f, 2, n)) return EX_ERROR; @@ -747,7 +747,7 @@ binary_func (struct function * f, int x unused, union any_node ** n) } static int -ternary_func (struct function * f, int x unused, union any_node ** n) +ternary_func (struct function * f, int x UNUSED, union any_node ** n) { if (!get_num_args (f, 3, n)) return EX_ERROR; @@ -755,9 +755,11 @@ ternary_func (struct function * f, int x unused, union any_node ** n) } static int -MISSING_func (struct function * f, int x unused, union any_node ** n) +MISSING_func (struct function * f, int x UNUSED, union any_node ** n) { - if (token == T_ID && is_varname (tokid) && lex_look_ahead () == ')') + if (token == T_ID + && dict_lookup_var (default_dict, tokid) != NULL + && lex_look_ahead () == ')') { struct var_node *c = xmalloc (sizeof *c); c->v = parse_variable (); @@ -771,11 +773,13 @@ MISSING_func (struct function * f, int x unused, union any_node ** n) } static int -SYSMIS_func (struct function * f unused, int x unused, union any_node ** n) +SYSMIS_func (struct function * f UNUSED, int x UNUSED, union any_node ** n) { int t; - if (token == T_ID && is_varname (tokid) && lex_look_ahead () == ')') + if (token == T_ID + && dict_lookup_var (default_dict, tokid) + && lex_look_ahead () == ')') { struct variable *v; v = parse_variable (); @@ -815,7 +819,7 @@ SYSMIS_func (struct function * f unused, int x unused, union any_node ** n) } static int -VALUE_func (struct function *f unused, int x unused, union any_node **n) +VALUE_func (struct function *f UNUSED, int x UNUSED, union any_node **n) { struct variable *v = parse_variable (); @@ -836,7 +840,7 @@ VALUE_func (struct function *f unused, int x unused, union any_node **n) } static int -LAG_func (struct function *f unused, int x unused, union any_node **n) +LAG_func (struct function *f UNUSED, int x UNUSED, union any_node **n) { struct variable *v = parse_variable (); int nlag = 1; @@ -894,7 +898,7 @@ nary_num_func (struct function *f, int min_args, union any_node **n) /* FIXME: Is this condition failsafe? Can we _ever_ have two juxtaposed identifiers otherwise? */ - if (token == T_ID && is_varname (tokid) + if (token == T_ID && dict_lookup_var (default_dict, tokid) != NULL && toupper (lex_look_ahead ()) == 'T') { struct variable **v; @@ -906,7 +910,7 @@ nary_num_func (struct function *f, int min_args, union any_node **n) opts |= PV_NUMERIC; else if (type == ALPHA) opts |= PV_STRING; - if (!parse_variables (NULL, &v, &nv, opts)) + if (!parse_variables (default_dict, &v, &nv, opts)) goto fail; if (nv + (*n)->nonterm.n >= m) { @@ -1037,7 +1041,7 @@ fail: } static int -CONCAT_func (struct function * f unused, int x unused, union any_node ** n) +CONCAT_func (struct function * f UNUSED, int x UNUSED, union any_node ** n) { int m = 0; @@ -1085,7 +1089,7 @@ fail: arg; and `f', format spec (this must be the last arg). If the optional args are included, the type becomes f->t+1. */ static int -generic_str_func (struct function *f, int x unused, union any_node ** n) +generic_str_func (struct function *f, int x UNUSED, union any_node ** n) { int max_args = 0; int type; @@ -1221,10 +1225,10 @@ parse_function (union any_node ** n) char fname[32], *cp; int t; int min_args; - struct vector *v; + const struct vector *v; /* Check for a vector with this name. */ - v = find_vector (tokid); + v = dict_lookup_vector (default_dict, tokid); if (v) { lex_get (); @@ -1233,7 +1237,7 @@ parse_function (union any_node ** n) *n = xmalloc (sizeof (struct nonterm_node) + sizeof (union any_node *[2])); - (*n)->nonterm.type = (v->v[0]->type == NUMERIC + (*n)->nonterm.type = (v->var[0]->type == NUMERIC ? OP_VEC_ELEM_NUM : OP_VEC_ELEM_STR); (*n)->nonterm.n = 0; @@ -1252,9 +1256,9 @@ parse_function (union any_node ** n) msg (SE, _("`)' expected after a vector index value.")); goto fail; } - ((*n)->nonterm.arg[1]) = (union any_node *) v->index; + ((*n)->nonterm.arg[1]) = (union any_node *) v->idx; - return v->v[0]->type == NUMERIC ? EX_NUMERIC : EX_STRING; + return v->var[0]->type == NUMERIC ? EX_NUMERIC : EX_STRING; } ds_truncate (&tokstr, 31); @@ -1623,7 +1627,7 @@ static struct function func_tab[] = /* An algo_compare_func that compares functions A and B based on their names. */ static int -compare_functions (const void *a_, const void *b_, void *aux unused) +compare_functions (const void *a_, const void *b_, void *aux UNUSED) { const struct function *a = a_; const struct function *b = b_;