X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdictionary.c;h=758f199763facd24f20513520bc934508c86d457;hb=64f58bbdab17e4a09b725e713f4f82f567f44076;hp=0fd59e1172113cd1f8754b82c3b08a48d5072943;hpb=317e6b778833b5dcd5dd195c0b677835a8024b2a;p=pspp-builds.git diff --git a/src/dictionary.c b/src/dictionary.c index 0fd59e11..758f1997 100644 --- a/src/dictionary.c +++ b/src/dictionary.c @@ -32,6 +32,9 @@ #include "value-labels.h" #include "var.h" +#include "gettext.h" +#define _(msgid) gettext (msgid) + /* A dictionary. */ struct dictionary { @@ -220,7 +223,7 @@ dict_get_var (const struct dictionary *d, size_t idx) exclude ordinary, system, and/or scratch variables. */ void dict_get_vars (const struct dictionary *d, struct variable ***vars, - size_t *cnt, unsigned exclude_classes) + int *cnt, unsigned exclude_classes) { size_t count; size_t i; @@ -276,23 +279,17 @@ dict_create_var (struct dictionary *d, const char *name, int width) v->init = 1; v->reinit = dict_class_from_id (v->name) != DC_SCRATCH; v->index = d->var_cnt; - v->miss_type = MISSING_NONE; + mv_init (&v->miss, width); if (v->type == NUMERIC) { - v->print.type = FMT_F; - v->print.w = 8; - v->print.d = 2; - + v->print = f8_2; v->alignment = ALIGN_RIGHT; v->display_width = 8; v->measure = MEASURE_SCALE; } else { - v->print.type = FMT_A; - v->print.w = v->width; - v->print.d = 0; - + v->print = make_output_format (FMT_A, v->width, 0); v->alignment = ALIGN_LEFT; v->display_width = 8; v->measure = MEASURE_NOMINAL; @@ -357,8 +354,7 @@ dict_clone_var (struct dictionary *d, const struct variable *ov, the same short name. */ nv->init = 1; nv->reinit = ov->reinit; - nv->miss_type = ov->miss_type; - memcpy (nv->missing, ov->missing, sizeof nv->missing); + mv_copy (&nv->miss, &ov->miss); nv->print = ov->print; nv->write = ov->write; val_labs_destroy (nv->val_labs); @@ -495,6 +491,23 @@ dict_delete_vars (struct dictionary *d, dict_delete_var (d, *vars++); } +/* Deletes scratch variables from dictionary D. */ +void +dict_delete_scratch_vars (struct dictionary *d) +{ + int i; + + /* FIXME: this can be done in O(count) time, but this algorithm + is O(count**2). */ + assert (d != NULL); + + for (i = 0; i < d->var_cnt; ) + if (dict_class_from_id (d->var[i]->name) == DC_SCRATCH) + dict_delete_var (d, d->var[i]); + else + i++; +} + /* Moves V to 0-based position IDX in D. Other variables in D, if any, retain their relative positions. Runs in time linear in the distance moved. */ @@ -681,7 +694,7 @@ dict_get_case_weight (const struct dictionary *d, const struct ccase *c, else { double w = case_num (c, d->weight->fv); - if ( w < 0.0 || w == SYSMIS || is_num_user_missing(w, d->weight) ) + if (w < 0.0 || mv_is_num_missing (&d->weight->miss, w)) w = 0.0; if ( w == 0.0 && *warn_on_invalid ) { *warn_on_invalid = 0;