From 77cbf2d7d1e5712d4ef952f265ed5c2917fc3f68 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 11 Mar 2004 07:30:36 +0000 Subject: [PATCH] Change explicit variable name checks into use of dict_class_from_id(). --- src/ChangeLog | 20 ++++++++++++++++++++ src/dictionary.c | 2 +- src/get.c | 2 +- src/sel-if.c | 2 +- src/sysfile-info.c | 2 +- src/vars-prs.c | 3 ++- src/vfm.c | 6 +++--- src/weight.c | 2 +- 8 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 82f9fca4..4abd99da 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,23 @@ +Wed Mar 10 23:25:13 2004 Ben Pfaff + + Change explicit variable name checks into use of + dict_class_from_id(). + + * dictionary.c: (dict_create_var) Change explicit variable name + check into use of dict_class_from_id(). + + * get.c: (trim_dictionary) Ditto. + + * sel-if.c: (cmd_filter) Ditto. + + * sysfile-info.c: (cmd_display) Ditto. + + * vars-prs.c: (parse_DATA_LIST_vars) Ditto. + + * vfm.c: (arrange_compaction) Ditto. + + * weight.c: (cmd_weight) Ditto. + Wed Mar 10 21:16:34 2004 Ben Pfaff * temporary.c: (cmd_temporary) When TEMPORARY was the first diff --git a/src/dictionary.c b/src/dictionary.c index 9b69c898..adf3b29e 100644 --- a/src/dictionary.c +++ b/src/dictionary.c @@ -236,7 +236,7 @@ dict_create_var (struct dictionary *d, const char *name, int width) v->fv = d->next_value_idx; v->nv = width == 0 ? 1 : DIV_RND_UP (width, 8); v->init = 1; - v->reinit = name[0] != '#'; + v->reinit = dict_class_from_id (name) != DC_SCRATCH; v->miss_type = MISSING_NONE; if (v->type == NUMERIC) { diff --git a/src/get.c b/src/get.c index e0ecc55d..df6e207c 100644 --- a/src/get.c +++ b/src/get.c @@ -312,7 +312,7 @@ trim_dictionary (struct dictionary *dict, int *options) v = xmalloc (sizeof *v * dict_get_var_cnt (dict)); nv = 0; for (i = 0; i < dict_get_var_cnt (dict); i++) - if (dict_get_var (dict, i)->name[0] == '#') + if (dict_class_from_id (dict_get_var (dict, i)->name) == DC_SCRATCH) v[nv++] = dict_get_var (dict, i); dict_delete_vars (dict, v, nv); free (v); diff --git a/src/sel-if.c b/src/sel-if.c index 514c4471..f686a9dd 100644 --- a/src/sel-if.c +++ b/src/sel-if.c @@ -105,7 +105,7 @@ cmd_filter (void) return CMD_FAILURE; } - if (v->name[0] == '#') + if (dict_class_from_id (v->name) == DC_SCRATCH) { msg (SE, _("The filter variable may not be scratch.")); return CMD_FAILURE; diff --git a/src/sysfile-info.c b/src/sysfile-info.c index f35bead7..e4a2dce7 100644 --- a/src/sysfile-info.c +++ b/src/sysfile-info.c @@ -247,7 +247,7 @@ cmd_display (void) { int i, m; for (i = 0, m = n; i < n; i++) - if (vl[i]->name[0] != '#') + if (dict_class_from_id (vl[i]->name) != DC_SCRATCH) { vl[i] = NULL; m--; diff --git a/src/vars-prs.c b/src/vars-prs.c index 8b15fd7b..6f3d7f3e 100644 --- a/src/vars-prs.c +++ b/src/vars-prs.c @@ -392,7 +392,8 @@ parse_DATA_LIST_vars (char ***names, int *nnames, int pv_opts) lex_error ("expecting variable name"); goto fail; } - if (tokid[0] == '#' && (pv_opts & PV_NO_SCRATCH)) + if (dict_class_from_id (tokid) == DC_SCRATCH + && (pv_opts & PV_NO_SCRATCH)) { msg (SE, _("Scratch variables not allowed here.")); goto fail; diff --git a/src/vfm.c b/src/vfm.c index 07bfaad3..51bd02cc 100644 --- a/src/vfm.c +++ b/src/vfm.c @@ -346,7 +346,7 @@ arrange_compaction (void) { struct variable *v = dict_get_var (temp_dict, i); - if (v->name[0] != '#') + if (dict_class_from_id (v->name) != DC_SCRATCH) { assert (v->nv > 0); count_values += v->nv; @@ -1260,7 +1260,7 @@ compact_case (struct ccase *dest, const struct ccase *src) { struct variable *v = dict_get_var (default_dict, i); - if (v->name[0] == '#') + if (dict_class_from_id (v->name) == DC_SCRATCH) continue; if (v->type == NUMERIC) @@ -1285,7 +1285,7 @@ finish_compaction (void) { struct variable *v = dict_get_var (default_dict, i); - if (v->name[0] == '#') + if (dict_class_from_id (v->name) == DC_SCRATCH) dict_delete_var (default_dict, v); else i++; diff --git a/src/weight.c b/src/weight.c index fd19f8c8..41dc33f6 100644 --- a/src/weight.c +++ b/src/weight.c @@ -54,7 +54,7 @@ cmd_weight (void) msg (SE, _("The weighting variable must be numeric.")); return CMD_FAILURE; } - if (v->name[0] == '#') + if (dict_class_from_id (v->name) == DC_SCRATCH) { msg (SE, _("The weighting variable may not be scratch.")); return CMD_FAILURE; -- 2.30.2