/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
return new_var;
}
-/* Create a variable to be used for internal calculations only */
+/* Create a variable to be used for internal calculations only.
+ The variable is assigned a unique dictionary index and a case
+ index of CASE_IDX. */
struct variable *
var_create_internal (int case_idx)
{
struct variable *v = var_create ("$internal", 0);
-
struct vardict_info vdi;
+ static int counter = INT_MAX / 2;
vdi.dict = NULL;
- vdi.dict_index = 0;
vdi.case_index = case_idx;
+ vdi.dict_index = counter++;
+ if (counter == INT_MAX)
+ counter = INT_MAX / 2;
var_set_vardict (v, &vdi);
{
const struct variable *v = v_;
- return hsh_hash_case_string (v->name);
+ return hash_case_string (v->name, 0);
}
/* A hsh_compare_func that orders pointers to variables A and B
{
struct variable *const *v = v_;
- return hsh_hash_case_string (var_get_name (*v));
+ return hash_case_string (var_get_name (*v), 0);
}
\f
/* Returns the type of variable V. */
ss_truncate (&s, 255);
if (!ss_is_empty (s))
v->label = ss_xstrdup (s);
- dict_var_changed (v);
}
+ dict_var_changed (v);
}
/* Removes any variable label from V. */
/* Sets V's display width to DISPLAY_WIDTH. */
void
-var_set_display_width (struct variable *v, int display_width)
+var_set_display_width (struct variable *v, int new_width)
{
- v->display_width = display_width;
+ int old_width = v->display_width;
+
+ v->display_width = new_width;
+
+ if ( old_width != new_width)
+ dict_var_display_width_changed (v);
+
dict_var_changed (v);
}