X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdictionary.c;h=03670fe42f429f825a031c11ce3609ea7867ce37;hb=0dd2d22c89cc94f92de0323c60ff16b993a46b18;hp=dba6bb142a065c564ef0b32577d207338aa06498;hpb=3a7fba81ceae5b049d0f7d671e9e3c3c43bbf703;p=pspp diff --git a/src/dictionary.c b/src/dictionary.c index dba6bb142a..03670fe42f 100644 --- a/src/dictionary.c +++ b/src/dictionary.c @@ -86,23 +86,14 @@ dict_clone (const struct dictionary *s) { d->split = xmalloc (d->split_cnt * sizeof *d->split); for (i = 0; i < d->split_cnt; i++) - { - d->split[i] = dict_lookup_var (d, s->split[i]->name); - assert (d->split[i] != NULL); - } + d->split[i] = dict_lookup_var_assert (d, s->split[i]->name); } if (s->weight != NULL) - { - d->weight = dict_lookup_var (d, s->weight->name); - assert (d->weight != NULL); - } + d->weight = dict_lookup_var_assert (d, s->weight->name); if (s->filter != NULL) - { - d->filter = dict_lookup_var (d, s->filter->name); - assert (d->filter != NULL); - } + d->filter = dict_lookup_var_assert (d, s->filter->name); d->case_limit = s->case_limit; dict_set_label (d, dict_get_label (s)); @@ -227,7 +218,8 @@ dict_create_var (struct dictionary *d, const char *name, int width) v->width = width; v->fv = d->value_cnt; v->nv = width == 0 ? 1 : DIV_RND_UP (width, 8); - v->left = name[0] == '#'; + v->init = 1; + v->reinit = name[0] != '#'; v->miss_type = MISSING_NONE; if (v->type == NUMERIC) { @@ -258,6 +250,14 @@ dict_create_var (struct dictionary *d, const char *name, int width) return v; } +struct variable * +dict_create_var_assert (struct dictionary *d, const char *name, int width) +{ + struct variable *v = dict_create_var (d, name, width); + assert (v != NULL); + return v; +} + struct variable * dict_clone_var (struct dictionary *d, const struct variable *ov, const char *name) @@ -273,7 +273,8 @@ dict_clone_var (struct dictionary *d, const struct variable *ov, if (nv == NULL) return NULL; - nv->left = ov->left; + nv->init = 1; + nv->reinit = ov->reinit; nv->miss_type = ov->miss_type; memcpy (nv->missing, ov->missing, sizeof nv->missing); nv->print = ov->print; @@ -321,6 +322,14 @@ dict_lookup_var (const struct dictionary *d, const char *name) return hsh_find (d->name_tab, &v); } +struct variable * +dict_lookup_var_assert (const struct dictionary *d, const char *name) +{ + struct variable *v = dict_lookup_var (d, name); + assert (v != NULL); + return v; +} + int dict_contains_var (const struct dictionary *d, const struct variable *v) { @@ -331,7 +340,7 @@ dict_contains_var (const struct dictionary *d, const struct variable *v) } static int -compare_variable_dblptrs (const void *a_, const void *b_, void *aux unused) +compare_variable_dblptrs (const void *a_, const void *b_, void *aux UNUSED) { struct variable *const *a = a_; struct variable *const *b = b_;