X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fdictionary.c;h=99ea5b8bcbec501a1cd3c57fa3252351b7d0fb17;hb=304c185799902df1dd96a8ff2d13d279005a82e5;hp=3e864d3e8d6338bd371d22eeb0ff07f14aa66f1b;hpb=ae692b0ac5ceff417fa9e9fc136d95acae3e99e1;p=pspp diff --git a/src/dictionary.c b/src/dictionary.c index 3e864d3e8d..99ea5b8bcb 100644 --- a/src/dictionary.c +++ b/src/dictionary.c @@ -435,9 +435,8 @@ dict_delete_var (struct dictionary *d, struct variable *v) dict_clear_vectors (d); /* Remove V from var array. */ + remove_element (d->var, d->var_cnt, sizeof *d->var, v->index); d->var_cnt--; - memmove (d->var + v->index, d->var + v->index + 1, - (d->var_cnt - v->index) * sizeof *d->var); /* Update index. */ for (i = v->index; i < d->var_cnt; i++) @@ -701,6 +700,30 @@ dict_compact_values (struct dictionary *d) } } +/* Copies values from SRC, which represents a case arranged + according to dictionary D, to DST, which represents a case + arranged according to the dictionary that will be produced by + dict_compact_values(D). */ +void +dict_compact_case (const struct dictionary *d, + struct ccase *dst, const struct ccase *src) +{ + size_t i; + size_t value_idx; + + value_idx = 0; + for (i = 0; i < d->var_cnt; i++) + { + struct variable *v = d->var[i]; + + if (dict_class_from_id (v->name) != DC_SCRATCH) + { + case_copy (dst, value_idx, src, v->fv, v->nv); + value_idx += v->nv; + } + } +} + /* Returns the number of values that would be used by a case if dict_compact_values() were called. */ size_t