From: Ben Pfaff Date: Mon, 15 Jun 2009 03:09:42 +0000 (-0700) Subject: Allow variables created by var_create_internal to have any width. X-Git-Tag: build37~69 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04c88b897db0d2281faa2829ed57b0f344395b8a;p=pspp-builds.git Allow variables created by var_create_internal to have any width. Until now, var_create_internal has always created a numeric variable. In the long run we wish to phase out the use of internal variables entirely, but this change should help Jason get some work done in the short term. --- diff --git a/src/data/variable.c b/src/data/variable.c index c0767d7c..8d85b518 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -149,13 +149,13 @@ var_clone (const struct variable *old_var) return new_var; } -/* 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. */ +/* Create a variable of the specified WIDTH 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) +var_create_internal (int case_idx, int width) { - struct variable *v = var_create ("$internal", 0); + struct variable *v = var_create ("$internal", width); struct vardict_info vdi; static int counter = INT_MAX / 2; diff --git a/src/data/variable.h b/src/data/variable.h index 2752aeb3..5d28d5b8 100644 --- a/src/data/variable.h +++ b/src/data/variable.h @@ -32,7 +32,7 @@ union value; struct variable *var_create (const char *name, int width); struct variable *var_clone (const struct variable *); void var_destroy (struct variable *); -struct variable *var_create_internal (int case_idx); +struct variable *var_create_internal (int case_idx, int width); /* Variable names. */ diff --git a/src/language/stats/aggregate.c b/src/language/stats/aggregate.c index 0d181bd4..08d2f5e1 100644 --- a/src/language/stats/aggregate.c +++ b/src/language/stats/aggregate.c @@ -1105,10 +1105,10 @@ initialize_aggregate_info (struct agr_proc *agr, const struct ccase *input) proto = caseproto_add_width (proto, 0); if ( ! iter->subject) - iter->subject = var_create_internal (0); + iter->subject = var_create_internal (0, 0); if ( ! iter->weight) - iter->weight = var_create_internal (1); + iter->weight = var_create_internal (1, 0); subcase_init_var (&ordering, iter->subject, SC_ASCEND); iter->writer = sort_create_writer (&ordering, proto); diff --git a/src/language/stats/wilcoxon.c b/src/language/stats/wilcoxon.c index 37d2b191..03a307f3 100644 --- a/src/language/stats/wilcoxon.c +++ b/src/language/stats/wilcoxon.c @@ -88,7 +88,7 @@ wilcoxon_execute (const struct dataset *ds, struct wilcoxon_state *ws = xcalloc (sizeof (*ws), t2s->n_pairs); const struct variable *weight = dict_get_weight (dict); - struct variable *weightx = var_create_internal (WEIGHT_IDX); + struct variable *weightx = var_create_internal (WEIGHT_IDX, 0); struct caseproto *proto; input = @@ -108,8 +108,8 @@ wilcoxon_execute (const struct dataset *ds, struct subcase ordering; variable_pair *vp = &t2s->pairs[i]; - ws[i].sign = var_create_internal (0); - ws[i].absdiff = var_create_internal (1); + ws[i].sign = var_create_internal (0, 0); + ws[i].absdiff = var_create_internal (1, 0); r = casereader_create_filter_missing (r, *vp, 2, exclude, diff --git a/src/math/interaction.c b/src/math/interaction.c index c8795ed5..133d7d7c 100644 --- a/src/math/interaction.c +++ b/src/math/interaction.c @@ -83,7 +83,7 @@ interaction_variable_create (const struct variable **vars, int n_vars) } } } - result->intr = var_create_internal (0); + result->intr = var_create_internal (0, 0); return result; }