X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fvariable.c;h=505ae79da395cac5f00de6e57bbcfa91b8fec80e;hb=37329c68f3f4c77ee2baa88a70e9ba6701e4008f;hp=d14237d925c3442e4baa8bbf9204a09044f41818;hpb=5a0b0d607efde2ab3a47d0d9c9fc62128a3156c1;p=pspp-builds.git diff --git a/src/data/variable.c b/src/data/variable.c index d14237d9..505ae79d 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -1,5 +1,5 @@ /* 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 @@ -148,17 +148,21 @@ var_clone (const struct variable *old_var) 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); @@ -319,7 +323,7 @@ hash_var_by_name (const void *v_, const void *aux UNUSED) { 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 @@ -355,7 +359,7 @@ hash_var_ptr_by_name (const void *v_, const void *aux UNUSED) { struct variable *const *v = v_; - return hsh_hash_case_string (var_get_name (*v)); + return hash_case_string (var_get_name (*v), 0); } /* Returns the type of variable V. */ @@ -716,8 +720,8 @@ var_set_label (struct variable *v, const char *label) 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. */ @@ -778,9 +782,15 @@ var_get_display_width (const struct variable *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); }