projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
(binary_search): Fix assertion.
[pspp-builds.git]
/
src
/
language
/
dictionary
/
modify-variables.c
diff --git
a/src/language/dictionary/modify-variables.c
b/src/language/dictionary/modify-variables.c
index 7c9a4b24bd0402667b5d83cc50e022978a549095..f3a18325818dae9c8f2c4c65ae67671c8957ad2d 100644
(file)
--- a/
src/language/dictionary/modify-variables.c
+++ b/
src/language/dictionary/modify-variables.c
@@
-1,6
+1,5
@@
/* PSPP - computes sample statistics.
Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
/* PSPP - computes sample statistics.
Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
- Written by Ben Pfaff <blp@gnu.org>.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
@@
-142,7
+141,7
@@
cmd_modify_vars (struct lexer *lexer, struct dataset *ds)
"of variables."));
goto done;
}
"of variables."));
goto done;
}
- dict_get_vars (dataset_dict (ds), &v, &nv, 1u << DC_SYSTEM);
+ dict_get_vars
_mutable
(dataset_dict (ds), &v, &nv, 1u << DC_SYSTEM);
}
else
{
}
else
{
@@
-211,7
+210,8
@@
cmd_modify_vars (struct lexer *lexer, struct dataset *ds)
{
msg (SE, _("Differing number of variables in old name list "
"(%d) and in new name list (%d)."),
{
msg (SE, _("Differing number of variables in old name list "
"(%d) and in new name list (%d)."),
- vm.rename_cnt - prev_nv_2, prev_nv_1 - prev_nv_2);
+ (int) (vm.rename_cnt - prev_nv_2),
+ (int) (prev_nv_1 - prev_nv_2));
for (i = 0; i < prev_nv_1; i++)
free (vm.new_names[i]);
free (vm.new_names);
for (i = 0; i < prev_nv_1; i++)
free (vm.new_names[i]);
free (vm.new_names);
@@
-250,7
+250,7
@@
cmd_modify_vars (struct lexer *lexer, struct dataset *ds)
sort (keep_vars, keep_cnt, sizeof *keep_vars,
compare_variables_given_ordering, &forward_positional_ordering);
sort (keep_vars, keep_cnt, sizeof *keep_vars,
compare_variables_given_ordering, &forward_positional_ordering);
- dict_get_vars (dataset_dict (ds), &all_vars, &all_cnt, 0);
+ dict_get_vars
_mutable
(dataset_dict (ds), &all_vars, &all_cnt, 0);
assert (all_cnt >= keep_cnt);
drop_cnt = all_cnt - keep_cnt;
assert (all_cnt >= keep_cnt);
drop_cnt = all_cnt - keep_cnt;
@@
-354,10
+354,14
@@
compare_variables_given_ordering (const void *a_, const void *b_,
const struct ordering *ordering = ordering_;
int result;
const struct ordering *ordering = ordering_;
int result;
- if (ordering->positional)
- result = a->index < b->index ? -1 : a->index > b->index;
+ if (ordering->positional)
+ {
+ size_t a_index = var_get_dict_index (a);
+ size_t b_index = var_get_dict_index (b);
+ result = a_index < b_index ? -1 : a_index > b_index;
+ }
else
else
- result = strcasecmp (
a->name, b->name
);
+ result = strcasecmp (
var_get_name (a), var_get_name (b)
);
if (!ordering->forward)
result = -result;
return result;
if (!ordering->forward)
result = -result;
return result;
@@
-404,7
+408,7
@@
validate_var_modification (const struct dictionary *d,
size_t i;
/* All variables, in index order. */
size_t i;
/* All variables, in index order. */
- dict_get_vars (d, &all_vars, &all_cnt, 0);
+ dict_get_vars
_mutable
(d, &all_vars, &all_cnt, 0);
/* Drop variables, in index order. */
drop_cnt = vm->drop_cnt;
/* Drop variables, in index order. */
drop_cnt = vm->drop_cnt;
@@
-430,7
+434,7
@@
validate_var_modification (const struct dictionary *d,
for (i = 0; i < keep_cnt; i++)
{
var_renaming[i].var = keep_vars[i];
for (i = 0; i < keep_cnt; i++)
{
var_renaming[i].var = keep_vars[i];
- strcpy (var_renaming[i].new_name,
keep_vars[i]->name
);
+ strcpy (var_renaming[i].new_name,
var_get_name (keep_vars[i])
);
}
/* Rename variables in var_renaming array. */
}
/* Rename variables in var_renaming array. */
@@
-493,7
+497,7
@@
rearrange_dict (struct dictionary *d, const struct var_modification *vm)
still exist, but we can still look them up by name. */
rename_old_names = xnmalloc (vm->rename_cnt, sizeof *rename_old_names);
for (i = 0; i < vm->rename_cnt; i++)
still exist, but we can still look them up by name. */
rename_old_names = xnmalloc (vm->rename_cnt, sizeof *rename_old_names);
for (i = 0; i < vm->rename_cnt; i++)
- rename_old_names[i] = xstrdup (v
m->rename_vars[i]->name
);
+ rename_old_names[i] = xstrdup (v
ar_get_name (vm->rename_vars[i])
);
/* Reorder and delete variables. */
dict_reorder_vars (d, vm->reorder_vars, vm->reorder_cnt);
/* Reorder and delete variables. */
dict_reorder_vars (d, vm->reorder_vars, vm->reorder_cnt);