X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fdictionary.c;fp=src%2Fdata%2Fdictionary.c;h=ebc88b4d9b9765f64306c9a4a2f86644859f3586;hb=66f75a6ba7c0e51f41ddba7b1c82c6e6b5279ed1;hp=2c4633f7f9804b93b87570598481d813fad77488;hpb=1dcdba517fbb5c99c37e0a03275325f256975c7c;p=pspp diff --git a/src/data/dictionary.c b/src/data/dictionary.c index 2c4633f7f9..ebc88b4d9b 100644 --- a/src/data/dictionary.c +++ b/src/data/dictionary.c @@ -950,10 +950,12 @@ dict_contains_var (const struct dictionary *d, const struct variable *v) void dict_reorder_var (struct dictionary *d, struct variable *v, size_t new_index) { - size_t old_index = var_get_dict_index (v); - assert (new_index < d->n_vars); + size_t old_index = var_get_dict_index (v); + if (new_index == old_index) + return; + unindex_vars (d, MIN (old_index, new_index), MAX (old_index, new_index) + 1); move_element (d->vars, d->n_vars, sizeof *d->vars, old_index, new_index); reindex_vars (d, MIN (old_index, new_index), MAX (old_index, new_index) + 1, false);