From 0fb6ac6ec832e8413504668b4390b846a6daba9f Mon Sep 17 00:00:00 2001 From: John Darrington Date: Wed, 25 Apr 2012 00:34:25 +0200 Subject: [PATCH] Replace var_to_string with var_append_string and update all callers. var_to_string returns a const char *. For upcoming changes this string will need to be dynamically allocated and of variable length. Therefore a "struct string" seems like a better choice. --- src/data/variable.c | 8 ++- src/data/variable.h | 2 +- src/language/stats/binomial.c | 8 ++- src/language/stats/chisquare.c | 25 ++++-- src/language/stats/cochran.c | 11 ++- src/language/stats/correlations.c | 22 ++++- src/language/stats/crosstabs.q | 105 +++++++++++++++----- src/language/stats/descriptives.c | 27 +++++- src/language/stats/examine.c | 153 +++++++++++++++++++++--------- src/language/stats/factor.c | 35 ++++++- src/language/stats/frequencies.q | 43 +++++++-- src/language/stats/friedman.c | 10 ++- src/language/stats/jonckheere-terpstra.c | 20 +++- src/language/stats/kruskal-wallis.c | 30 +++++-- src/language/stats/ks-one-sample.c | 6 +- src/language/stats/mann-whitney.c | 14 ++- src/language/stats/mcnemar.c | 29 ++++-- src/language/stats/means.c | 18 +++- src/language/stats/median.c | 29 ++++-- src/language/stats/npar-summary.c | 9 +- src/language/stats/oneway.c | 64 +++++++++--- src/language/stats/quick-cluster.c | 8 +- src/language/stats/regression.c | 16 +++- src/language/stats/reliability.c | 7 +- src/language/stats/roc.c | 44 +++++++-- src/language/stats/runs.c | 6 +- src/language/stats/sign.c | 15 ++- src/language/stats/t-test-indep.c | 24 ++++- src/language/stats/t-test-one-sample.c | 16 +++- src/language/stats/t-test-paired.c | 44 +++++++-- src/language/stats/wilcoxon.c | 33 ++++--- src/math/interaction.c | 5 +- 32 files changed, 665 insertions(+), 221 deletions(-) diff --git a/src/data/variable.c b/src/data/variable.c index 2ceeecd..060fafa 100644 --- a/src/data/variable.c +++ b/src/data/variable.c @@ -586,12 +586,18 @@ var_default_formats (int width) /* Return a string representing this variable, in the form most appropriate from a human factors perspective, that is, its variable label if it has one, otherwise its name. */ -const char * +static const char * var_to_string (const struct variable *v) { return v->label != NULL ? v->label : v->name; } +void +var_append_string (const struct variable *v, struct string *s) +{ + ds_put_cstr (s, var_to_string (v)); +} + /* Returns V's variable label, or a null pointer if it has none. */ const char * var_get_label (const struct variable *v) diff --git a/src/data/variable.h b/src/data/variable.h index aeed5a5..fd87d68 100644 --- a/src/data/variable.h +++ b/src/data/variable.h @@ -96,7 +96,7 @@ void var_set_both_formats (struct variable *, const struct fmt_spec *); struct fmt_spec var_default_formats (int width); /* Variable labels. */ -const char *var_to_string (const struct variable *); +void var_append_string (const struct variable *v, struct string *s); const char *var_get_label (const struct variable *); bool var_set_label (struct variable *, const char *label, bool issue_warning); void var_clear_label (struct variable *); diff --git a/src/language/stats/binomial.c b/src/language/stats/binomial.c index 94d0d97..a23e61f 100644 --- a/src/language/stats/binomial.c +++ b/src/language/stats/binomial.c @@ -213,7 +213,13 @@ binomial_execute (const struct dataset *ds, tab_hline (table, TAL_1, 0, tab_nc (table) -1, 1 + v * 3); /* Titles */ - tab_text (table, 0, 1 + v * 3, TAB_LEFT, var_to_string (var)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (var, &varstr); + tab_text (table, 0, 1 + v * 3, TAB_LEFT, ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_text (table, 1, 1 + v * 3, TAB_LEFT, _("Group1")); tab_text (table, 1, 2 + v * 3, TAB_LEFT, _("Group2")); tab_text (table, 1, 3 + v * 3, TAB_LEFT, _("Total")); diff --git a/src/language/stats/chisquare.c b/src/language/stats/chisquare.c index 10d8113..b536862 100644 --- a/src/language/stats/chisquare.c +++ b/src/language/stats/chisquare.c @@ -157,7 +157,13 @@ create_variable_frequency_table (const struct dictionary *dict, table = tab_create(4, n_cells + 2); - tab_title (table, "%s", var_to_string(var)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (var, &varstr); + tab_title (table, "%s", ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_text (table, 1, 0, TAB_LEFT, _("Observed N")); tab_text (table, 2, 0, TAB_LEFT, _("Expected N")); tab_text (table, 3, 0, TAB_LEFT, _("Residual")); @@ -213,12 +219,17 @@ create_combo_frequency_table (const struct chisquare_test *test) tab_vline (table, TAL_1, i * 4 + 4, 1, tab_nr (table) - 1); - - tab_joint_text (table, - i * 4 + 1, 0, - i * 4 + 4, 0, - TAB_CENTER, - var_to_string (var)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (var, &varstr); + tab_joint_text (table, + i * 4 + 1, 0, + i * 4 + 4, 0, + TAB_CENTER, + ds_cstr (&varstr)); + ds_destroy (&varstr); + } } for ( i = test->lo ; i <= test->hi ; ++i ) diff --git a/src/language/stats/cochran.c b/src/language/stats/cochran.c index 3ea8fd3..2dd764b 100644 --- a/src/language/stats/cochran.c +++ b/src/language/stats/cochran.c @@ -177,9 +177,16 @@ show_freqs_box (const struct one_sample_test *ost, const struct cochran *ct) for (i = 0 ; i < ost->n_vars ; ++i) { - tab_text (table, 0, column_headers + i, - TAB_LEFT, var_to_string (ost->vars[i])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (ost->vars[i], &varstr); + tab_text (table, 0, column_headers + i, + TAB_LEFT, ds_cstr (&varstr)); + ds_destroy (&varstr); + } + tab_double (table, 1, column_headers + i, 0, ct->hits[i], wfmt); diff --git a/src/language/stats/correlations.c b/src/language/stats/correlations.c index bc6508b..cdcc4b9 100644 --- a/src/language/stats/correlations.c +++ b/src/language/stats/correlations.c @@ -122,8 +122,12 @@ output_descriptives (const struct corr *corr, const gsl_matrix *means, for (r = 0 ; r < corr->n_vars_total ; ++r) { const struct variable *v = corr->vars[r]; - tab_text (t, 0, r + heading_rows, TAB_LEFT | TAT_TITLE, var_to_string (v)); - + struct string varstr; + ds_init_empty (&varstr); + var_append_string (v, &varstr); + tab_text (t, 0, r + heading_rows, TAB_LEFT | TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); + for (c = 1 ; c < nc ; ++c) { double x ; @@ -211,8 +215,11 @@ output_correlation (const struct corr *corr, const struct corr_opts *opts, for (r = 0 ; r < corr->n_vars1 ; ++r) { - tab_text (t, 0, 1 + r * rows_per_variable, TAB_LEFT | TAT_TITLE, - var_to_string (corr->vars[r])); + struct string varstr; + ds_init_empty (&varstr); + var_append_string (corr->vars[r], &varstr); + tab_text (t, 0, 1 + r * rows_per_variable, TAB_LEFT | TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); tab_text (t, 1, 1 + r * rows_per_variable, TAB_LEFT | TAT_TITLE, _("Pearson Correlation")); tab_text (t, 1, 2 + r * rows_per_variable, TAB_LEFT | TAT_TITLE, @@ -233,7 +240,12 @@ output_correlation (const struct corr *corr, const struct corr_opts *opts, for (c = 0 ; c < matrix_cols ; ++c) { const struct variable *v = corr->n_vars_total > corr->n_vars1 ? corr->vars[corr->n_vars_total - corr->n_vars1 + c] : corr->vars[c]; - tab_text (t, heading_columns + c, 0, TAB_LEFT | TAT_TITLE, var_to_string (v)); + + struct string varstr; + ds_init_empty (&varstr); +var_append_string (v, &varstr); + tab_text (t, heading_columns + c, 0, TAB_LEFT | TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); } for (r = 0 ; r < corr->n_vars1 ; ++r) diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q index b60133d..b54701f 100644 --- a/src/language/stats/crosstabs.q +++ b/src/language/stats/crosstabs.q @@ -854,7 +854,7 @@ make_summary_table (struct crosstabs_proc *proc) { if (i > 0) ds_put_cstr (&name, " * "); - ds_put_cstr (&name, var_to_string (pt->vars[i])); + var_append_string (pt->vars[i], &name); } tab_text (summary, 0, 0, TAB_LEFT, ds_cstr (&name)); @@ -925,10 +925,14 @@ output_pivot_table (struct crosstabs_proc *proc, struct pivot_table *pt) { struct string vars; int i; - - ds_init_cstr (&vars, var_to_string (pt->vars[0])); + + ds_init_empty (&vars); + var_append_string (pt->vars[0], &vars); for (i = 1; i < pt->n_vars; i++) - ds_put_format (&vars, " * %s", var_to_string (pt->vars[i])); + { + ds_put_cstr (&vars, " * "); + var_append_string (pt->vars[i], &vars); + } /* TRANSLATORS: The %s here describes a crosstabulation. It takes the form "var1 * var2 * var3 * ...". */ @@ -1154,21 +1158,43 @@ create_crosstab_table (struct crosstabs_proc *proc, struct pivot_table *pt) (x.n_entries / x.n_cols) * 3 / 2 * proc->n_cells + 10); tab_headers (table, x.n_consts + 1, 0, 2, 0); - /* First header line. */ - tab_joint_text (table, x.n_consts + 1, 0, - (x.n_consts + 1) + (x.n_cols - 1), 0, - TAB_CENTER | TAT_TITLE, var_to_string (x.vars[COL_VAR])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (x.vars[COL_VAR], &varstr); + /* First header line. */ + tab_joint_text (table, x.n_consts + 1, 0, + (x.n_consts + 1) + (x.n_cols - 1), 0, + TAB_CENTER | TAT_TITLE, + ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_hline (table, TAL_1, x.n_consts + 1, x.n_consts + 2 + x.n_cols - 2, 1); /* Second header line. */ for (i = 2; i < x.n_consts + 2; i++) - tab_joint_text (table, x.n_consts + 2 - i - 1, 0, - x.n_consts + 2 - i - 1, 1, - TAB_RIGHT | TAT_TITLE, var_to_string (x.vars[i])); - tab_text (table, x.n_consts + 2 - 2, 1, TAB_RIGHT | TAT_TITLE, - var_to_string (x.vars[ROW_VAR])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (x.vars[i], &varstr); + tab_joint_text (table, x.n_consts + 2 - i - 1, 0, + x.n_consts + 2 - i - 1, 1, + TAB_RIGHT | TAT_TITLE, + ds_cstr (&varstr)); + ds_destroy (&varstr); + } + + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (x.vars[ROW_VAR], &varstr); + tab_text (table, x.n_consts + 2 - 2, 1, TAB_RIGHT | TAT_TITLE, + ds_cstr (&varstr)); + ds_destroy (&varstr); + } + for (i = 0; i < x.n_cols; i++) table_value_missing (proc, table, x.n_consts + 2 + i - 1, 1, TAB_RIGHT, &x.cols[i], x.vars[COL_VAR]); @@ -1183,14 +1209,17 @@ create_crosstab_table (struct crosstabs_proc *proc, struct pivot_table *pt) { if (i) ds_put_cstr (&title, " * "); - ds_put_cstr (&title, var_to_string (x.vars[i])); + var_append_string (x.vars[i], &title); } + for (i = 0; i < pt->n_consts; i++) { const struct variable *var = pt->const_vars[i]; char *s; - ds_put_format (&title, ", %s=", var_to_string (var)); + ds_put_cstr (&title, ", "); + var_append_string (var, &title); + ds_put_cstr (&title, "="); /* Insert the formatted value of VAR without any leading spaces. */ s = data_out (&pt->const_values[i], var_get_encoding (var), @@ -1358,8 +1387,14 @@ submit (struct pivot_table *pt, struct tab_table *t) tab_offset (t, 0, 0); if (pt != NULL) for (i = 2; i < pt->n_vars; i++) - tab_text (t, pt->n_vars - i - 1, 0, TAB_RIGHT | TAT_TITLE, - var_to_string (pt->vars[i])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (pt->vars[i], &varstr); + tab_text (t, pt->n_vars - i - 1, 0, TAB_RIGHT | TAT_TITLE, + ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_box (t, TAL_2, TAL_2, -1, -1, 0, 0, tab_nc (t) - 1, tab_nr (t) - 1); tab_box (t, -1, -1, -1, TAL_1, tab_l (t), tab_t (t) - 1, tab_nc (t) - 1, tab_nr (t) - 1); @@ -1864,7 +1899,6 @@ static int calc_risk (struct pivot_table *, static void display_risk (struct pivot_table *pt, struct tab_table *risk) { - char buf[256]; double risk_v[3], lower[3], upper[3]; union value c[2]; int i; @@ -1876,23 +1910,29 @@ display_risk (struct pivot_table *pt, struct tab_table *risk) for (i = 0; i < 3; i++) { + char buf[256]; const struct variable *cv = pt->vars[COL_VAR]; const struct variable *rv = pt->vars[ROW_VAR]; int cvw = var_get_width (cv); int rvw = var_get_width (rv); + struct string varstr; + if (risk_v[i] == SYSMIS) continue; + ds_init_empty (&varstr); + var_append_string (cv, &varstr); + switch (i) { case 0: if (var_is_numeric (cv)) sprintf (buf, _("Odds Ratio for %s (%g / %g)"), - var_to_string (cv), c[0].f, c[1].f); + ds_cstr (&varstr), c[0].f, c[1].f); else sprintf (buf, _("Odds Ratio for %s (%.*s / %.*s)"), - var_to_string (cv), + ds_cstr (&varstr), cvw, value_str (&c[0], cvw), cvw, value_str (&c[1], cvw)); break; @@ -1900,14 +1940,16 @@ display_risk (struct pivot_table *pt, struct tab_table *risk) case 2: if (var_is_numeric (rv)) sprintf (buf, _("For cohort %s = %g"), - var_to_string (rv), pt->rows[i - 1].f); + ds_cstr (&varstr), pt->rows[i - 1].f); else sprintf (buf, _("For cohort %s = %.*s"), - var_to_string (rv), + ds_cstr (&varstr), rvw, value_str (&pt->rows[i - 1], rvw)); break; } + ds_destroy (&varstr); + tab_text (risk, 0, 0, TAB_LEFT, buf); tab_double (risk, 1, 0, TAB_RIGHT, risk_v[i], NULL); tab_double (risk, 2, 0, TAB_RIGHT, lower[i], NULL); @@ -2015,18 +2057,27 @@ display_directional (struct crosstabs_proc *proc, struct pivot_table *pt, for (; j < 3; j++) { - const char *string; + struct string varstr; + int k = last[j] = stats_lookup[j][i]; + ds_init_empty (&varstr); if (k == 0) - string = NULL; + { + } else if (k == 1) - string = var_to_string (pt->vars[0]); + { + var_append_string (pt->vars[0], &varstr); + } else - string = var_to_string (pt->vars[1]); + { + var_append_string (pt->vars[1], &varstr); + } tab_text_format (direct, j, 0, TAB_LEFT, - gettext (stats_names[j][k]), string); + gettext (stats_names[j][k]), ds_cstr (&varstr)); + + ds_destroy (&varstr); } } } diff --git a/src/language/stats/descriptives.c b/src/language/stats/descriptives.c index 32a979d..8bc176e 100644 --- a/src/language/stats/descriptives.c +++ b/src/language/stats/descriptives.c @@ -578,7 +578,12 @@ dump_z_table (struct dsc_proc *dsc) for (i = 0, y = 1; i < dsc->var_cnt; i++) if (dsc->vars[i].z_name != NULL) { - tab_text (t, 0, y, TAB_LEFT, var_to_string (dsc->vars[i].v)); + struct string varstr; + ds_init_empty (&varstr); + var_append_string (dsc->vars[i].v, &varstr); + tab_text (t, 0, y, TAB_LEFT, ds_cstr (&varstr)); + ds_destroy (&varstr); + tab_text (t, 1, y++, TAB_LEFT, dsc->vars[i].z_name); } } @@ -680,9 +685,15 @@ setup_z_trns (struct dsc_proc *dsc, struct dataset *ds) struct variable *dst_var; dst_var = dict_create_var_assert (dataset_dict (ds), dv->z_name, 0); - var_set_label (dst_var, - xasprintf (_("Z-score of %s"),var_to_string (dv->v)), - false); + + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (dv->v, &varstr); + var_set_label (dst_var, + xasprintf (_("Z-score of %s"),ds_cstr (&varstr)), false); + ds_destroy (&varstr); + } z = &t->z_scores[cnt++]; z->src_var = dv->v; @@ -914,7 +925,13 @@ display (struct dsc_proc *dsc) size_t j; nc = 0; - tab_text (t, nc++, i + 1, TAB_LEFT, var_to_string (dv->v)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (dv->v, &varstr); + tab_text (t, nc++, i + 1, TAB_LEFT, ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_text_format (t, nc++, i + 1, 0, "%g", dv->valid); if (dsc->format == DSC_SERIAL) tab_text_format (t, nc++, i + 1, 0, "%g", dv->missing); diff --git a/src/language/stats/examine.c b/src/language/stats/examine.c index 9bc287e..830a563 100644 --- a/src/language/stats/examine.c +++ b/src/language/stats/examine.c @@ -266,13 +266,27 @@ show_boxplot_grouped (const struct examine *cmd, int iact_idx) struct string istr; ds_init_empty (&istr); interaction_to_string (iact, &istr); - ds_put_format (&title, _("Boxplot of %s vs. %s"), - var_to_string (cmd->dep_vars[v]), - ds_cstr (&istr)); + + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (cmd->dep_vars[v], &varstr); + ds_put_format (&title, _("Boxplot of %s vs. %s"), + ds_cstr (&varstr), + ds_cstr (&istr)); + ds_destroy (&varstr); + } + ds_destroy (&istr); } else - ds_put_format (&title, _("Boxplot of %s"), var_to_string (cmd->dep_vars[v])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (cmd->dep_vars[v], &varstr); + ds_put_format (&title, _("Boxplot of %s"), ds_cstr (&varstr)); + ds_destroy (&varstr); + } for (grp = 0; grp < n_cats; ++grp) { @@ -307,7 +321,13 @@ show_boxplot_grouped (const struct examine *cmd, int iact_idx) const struct variable *ivar = iact->vars[ivar_idx]; const union value *val = case_data (c, ivar); - ds_put_cstr (&label, var_to_string (ivar)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (ivar, &varstr); + ds_put_cstr (&label, ds_cstr (&varstr)); + ds_destroy (&varstr); + } ds_put_cstr (&label, " = "); append_value_name (ivar, val, &label); ds_put_cstr (&label, "; "); @@ -366,7 +386,7 @@ show_boxplot_variabled (const struct examine *cmd, int iact_idx) const struct variable *ivar = iact->vars[ivar_idx]; const union value *val = case_data (c, ivar); - ds_put_cstr (&label, var_to_string (ivar)); + var_append_string (ivar, &label); ds_put_cstr (&label, " = "); append_value_name (ivar, val, &label); ds_put_cstr (&label, "; "); @@ -387,8 +407,11 @@ show_boxplot_variabled (const struct examine *cmd, int iact_idx) const struct exploratory_stats *es = categoricals_get_user_data_by_category_real (cmd->cats, iact_idx, grp); - boxplot_add_box (boxplot, es[v].box_whisker, - var_to_string (cmd->dep_vars[v])); + struct string varstr; + ds_init_empty (&varstr); + var_append_string (cmd->dep_vars[v], &varstr); + boxplot_add_box (boxplot, es[v].box_whisker, ds_cstr (&varstr)); + ds_destroy (&varstr); } boxplot_submit (boxplot); @@ -422,8 +445,8 @@ show_npplot (const struct examine *cmd, int iact_idx) categoricals_get_user_data_by_category_real (cmd->cats, iact_idx, grp); struct string label; - ds_init_cstr (&label, - var_to_string (cmd->dep_vars[v])); + ds_init_empty (&label); + var_append_string (cmd->dep_vars[v], &label); if ( iact->n_vars > 0) { @@ -432,12 +455,11 @@ show_npplot (const struct examine *cmd, int iact_idx) { const struct variable *ivar = iact->vars[ivar_idx]; const union value *val = case_data (c, ivar); - - ds_put_cstr (&label, var_to_string (ivar)); + + var_append_string (ivar, &label); ds_put_cstr (&label, " = "); append_value_name (ivar, val, &label); ds_put_cstr (&label, "; "); - } ds_put_cstr (&label, ")"); } @@ -485,8 +507,8 @@ show_spreadlevel (const struct examine *cmd, int iact_idx) struct chart_item *sl; struct string label; - ds_init_cstr (&label, - var_to_string (cmd->dep_vars[v])); + ds_init_empty (&label); + var_append_string (cmd->dep_vars[v], &label); if (iact->n_vars > 0) { @@ -547,8 +569,8 @@ show_histogram (const struct examine *cmd, int iact_idx) if (es[v].histogram == NULL) continue; - ds_init_cstr (&label, - var_to_string (cmd->dep_vars[v])); + ds_init_empty (&label); + var_append_string (cmd->dep_vars[v], &label); if ( iact->n_vars > 0) { @@ -558,7 +580,7 @@ show_histogram (const struct examine *cmd, int iact_idx) const struct variable *ivar = iact->vars[ivar_idx]; const union value *val = case_data (c, ivar); - ds_put_cstr (&label, var_to_string (ivar)); + var_append_string (ivar, &label); ds_put_cstr (&label, " = "); append_value_name (ivar, val, &label); ds_put_cstr (&label, "; "); @@ -632,11 +654,14 @@ percentiles_report (const struct examine *cmd, int iact_idx) for (i = 0; i < iact->n_vars; ++i) { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (iact->vars[i], &varstr); tab_text (t, 1 + i, 1, TAT_TITLE, - var_to_string (iact->vars[i]) - ); + ds_cstr (&varstr)); + ds_destroy (&varstr); } @@ -650,15 +675,20 @@ percentiles_report (const struct examine *cmd, int iact_idx) const union value **prev_vals = previous_value_alloc (iact); int ivar_idx; + + struct string varstr; + ds_init_empty (&varstr); + if ( v > 0 ) tab_hline (t, TAL_1, 0, nc - 1, heading_rows + v * rows_per_var); - + + var_append_string (cmd->dep_vars[v], &varstr); tab_text (t, 0, heading_rows + v * rows_per_var, TAT_TITLE | TAB_LEFT, - var_to_string (cmd->dep_vars[v]) - ); - + ds_cstr (&varstr)); + ds_destroy (&varstr); + for (i = 0; i < n_cats; ++i) { const struct ccase *c = @@ -801,27 +831,35 @@ descriptives_report (const struct examine *cmd, int iact_idx) _("Std. Error")); for (i = 0; i < iact->n_vars; ++i) - { + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (iact->vars[i], &varstr); tab_text (t, 1 + i, 0, TAT_TITLE, - var_to_string (iact->vars[i]) + ds_cstr (&varstr) ); + ds_destroy (&varstr); } for (v = 0; v < cmd->n_dep_vars; ++v) { const union value **prev_val = previous_value_alloc (iact); - + struct string varstr; int ivar_idx; if ( v > 0 ) tab_hline (t, TAL_1, 0, nc - 1, heading_rows + v * rows_per_var); + + ds_init_empty (&varstr); + var_append_string (cmd->dep_vars[v], &varstr); tab_text (t, 0, heading_rows + v * rows_per_var, TAT_TITLE | TAB_LEFT, - var_to_string (cmd->dep_vars[v]) + ds_cstr (&varstr) ); + ds_destroy (&varstr); for (i = 0; i < n_cats; ++i) { @@ -1114,8 +1152,14 @@ extremes_report (const struct examine *cmd, int iact_idx) if ( cmd->id_var ) - tab_text (t, heading_columns, 0, TAB_CENTER | TAT_TITLE, - var_to_string (cmd->id_var)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (cmd->id_var, &varstr); + tab_text (t, heading_columns, 0, TAB_CENTER | TAT_TITLE, + ds_cstr (&varstr)); + ds_destroy (&varstr); + } else tab_text (t, heading_columns, 0, TAB_CENTER | TAT_TITLE, _("Case Number")); @@ -1124,12 +1168,15 @@ extremes_report (const struct examine *cmd, int iact_idx) _("Value")); for (i = 0; i < iact->n_vars; ++i) - { + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (iact->vars[i], &varstr); tab_text (t, 1 + i, 0, TAT_TITLE, - var_to_string (iact->vars[i]) - ); + ds_cstr (&varstr)); + ds_destroy (&varstr); } for (v = 0; v < cmd->n_dep_vars; ++v) @@ -1140,11 +1187,16 @@ extremes_report (const struct examine *cmd, int iact_idx) if ( v > 0 ) tab_hline (t, TAL_1, 0, nc - 1, heading_rows + v * rows_per_var); - tab_text (t, - 0, heading_rows + v * rows_per_var, - TAT_TITLE, - var_to_string (cmd->dep_vars[v]) - ); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (cmd->dep_vars[v], &varstr); + tab_text (t, + 0, heading_rows + v * rows_per_var, + TAT_TITLE, + ds_cstr (&varstr)); + ds_destroy (&varstr); + } for (i = 0; i < n_cats; ++i) { @@ -1337,12 +1389,15 @@ summary_report (const struct examine *cmd, int iact_idx) } for (i = 0; i < iact->n_vars; ++i) - { + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (iact->vars[i], &varstr); tab_text (t, 1 + i, 2, TAT_TITLE, - var_to_string (iact->vars[i]) - ); + ds_cstr (&varstr)); + ds_destroy (&varstr); } if (n_cats > 0) @@ -1354,12 +1409,16 @@ summary_report (const struct examine *cmd, int iact_idx) if ( v > 0 ) tab_hline (t, TAL_1, 0, nc - 1, heading_rows + v * n_cats); - tab_text (t, - 0, heading_rows + n_cats * v, - TAT_TITLE, - var_to_string (cmd->dep_vars[v]) - ); - + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (cmd->dep_vars[v], &varstr); + tab_text (t, + 0, heading_rows + n_cats * v, + TAT_TITLE, + ds_cstr (&varstr)); + ds_destroy (&varstr); + } for (i = 0; i < n_cats; ++i) { diff --git a/src/language/stats/factor.c b/src/language/stats/factor.c index 6fc106f..08abb03 100644 --- a/src/language/stats/factor.c +++ b/src/language/stats/factor.c @@ -1313,8 +1313,13 @@ show_communalities (const struct cmd_factor * factor, for (i = 0 ; i < factor->n_vars; ++i) { + struct string varstr; c = 0; - tab_text (t, c++, i + heading_rows, TAT_TITLE, var_to_string (factor->vars[i])); + + ds_init_empty (&varstr); + var_append_string (factor->vars[i], &varstr); + tab_text (t, c++, i + heading_rows, TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); if (factor->print & PRINT_INITIAL) tab_double (t, c++, i + heading_rows, 0, gsl_vector_get (initial, i), NULL); @@ -1400,7 +1405,11 @@ show_factor_matrix (const struct cmd_factor *factor, struct idata *idata, const { int j; const int matrix_row = perm->data[i]; - tab_text (t, 0, i + heading_rows, TAT_TITLE, var_to_string (factor->vars[matrix_row])); + struct string varstr; + ds_init_empty (&varstr); + var_append_string (factor->vars[matrix_row], &varstr); + tab_text (t, 0, i + heading_rows, TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); for (j = 0 ; j < n_factors; ++j) { @@ -1652,7 +1661,13 @@ show_correlation_matrix (const struct cmd_factor *factor, const struct idata *id for (i = 0; i < factor->n_vars; ++i) - tab_text (t, heading_columns + i, 0, TAT_TITLE, var_to_string (factor->vars[i])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (factor->vars[i], &varstr); + tab_text (t, heading_columns + i, 0, TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); + } for (i = 0 ; i < n_data_sets; ++i) @@ -1660,7 +1675,13 @@ show_correlation_matrix (const struct cmd_factor *factor, const struct idata *id int y = heading_rows + i * factor->n_vars; size_t v; for (v = 0; v < factor->n_vars; ++v) - tab_text (t, 1, y + v, TAT_TITLE, var_to_string (factor->vars[v])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (factor->vars[v], &varstr); + tab_text (t, 1, y + v, TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_hline (t, TAL_1, 0, nc - 1, y); } @@ -1805,7 +1826,11 @@ do_factor (const struct cmd_factor *factor, struct casereader *r) for (i = 0 ; i < factor->n_vars; ++i) { const struct variable *v = factor->vars[i]; - tab_text (t, 0, i + heading_rows, TAB_LEFT | TAT_TITLE, var_to_string (v)); + struct string varstr; + ds_init_empty (&varstr); + var_append_string (v, &varstr); + tab_text (t, 0, i + heading_rows, TAB_LEFT | TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); tab_double (t, 1, i + heading_rows, 0, gsl_matrix_get (mean_matrix, i, i), NULL); tab_double (t, 2, i + heading_rows, 0, sqrt (gsl_matrix_get (var_matrix, i, i)), NULL); diff --git a/src/language/stats/frequencies.q b/src/language/stats/frequencies.q index b9da467..a34b0aa 100644 --- a/src/language/stats/frequencies.q +++ b/src/language/stats/frequencies.q @@ -501,13 +501,18 @@ postcalc (struct frq_proc *frq, const struct dataset *ds) if ( histogram) { - chart_item_submit (histogram_chart_create ( - histogram->gsl_hist, var_to_string(vf->var), - vf->tab.valid_cases, - d[FRQ_MEAN], - d[FRQ_STDDEV], - frq->hist->draw_normal)); - + struct string varstr; + ds_init_empty (&varstr); + var_append_string (vf->var, &varstr); + chart_item_submit + (histogram_chart_create + (histogram->gsl_hist, ds_cstr (&varstr), + vf->tab.valid_cases, + d[FRQ_MEAN], + d[FRQ_STDDEV], + frq->hist->draw_normal)); + + ds_destroy (&varstr); statistic_destroy (&histogram->parent); } } @@ -887,7 +892,13 @@ dump_freq_table (const struct var_freqs *vf, const struct variable *wv) tab_fixed (t, 3, r, TAB_NONE, 100.0, 5, 1); tab_fixed (t, 4, r, TAB_NONE, 100.0, 5, 1); - tab_title (t, "%s", var_to_string (vf->var)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (vf->var, &varstr); + tab_title (t, "%s", ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_submit (t); } @@ -1071,7 +1082,13 @@ dump_statistics (const struct frq_proc *frq, const struct var_freqs *vf, r++; } - tab_title (t, "%s", var_to_string (vf->var)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (vf->var, &varstr); + tab_title (t, "%s", ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_submit (t); } @@ -1219,7 +1236,13 @@ do_piechart(const struct frq_chart *pie, const struct variable *var, msg (SW, _("Omitting pie chart for %s, which has over 50 unique values."), var_get_name (var)); else - chart_item_submit (piechart_create (var_to_string(var), slices, n_slices)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (var, &varstr); + chart_item_submit (piechart_create (ds_cstr (&varstr), slices, n_slices)); + ds_destroy (&varstr); + } for (i = 0; i < n_slices; i++) ds_destroy (&slices[i].label); diff --git a/src/language/stats/friedman.c b/src/language/stats/friedman.c index 5ef3083..da4bffc 100644 --- a/src/language/stats/friedman.c +++ b/src/language/stats/friedman.c @@ -242,9 +242,13 @@ show_ranks_box (const struct one_sample_test *ost, const struct friedman *fr) for (i = 0 ; i < ost->n_vars ; ++i) { - tab_text (table, 0, row_headers + i, - TAB_LEFT, var_to_string (ost->vars[i])); - + struct string varstr; + ds_init_empty (&varstr); + var_append_string (ost->vars[i], &varstr); + + tab_text (table, 0, row_headers + i, TAB_LEFT, ds_cstr (&varstr)); + ds_destroy (&varstr); + tab_double (table, 1, row_headers + i, 0, fr->rank_sum[i] / fr->cc, 0); } diff --git a/src/language/stats/jonckheere-terpstra.c b/src/language/stats/jonckheere-terpstra.c index 796168a..e022c6e 100644 --- a/src/language/stats/jonckheere-terpstra.c +++ b/src/language/stats/jonckheere-terpstra.c @@ -374,9 +374,16 @@ show_jt (const struct n_sample_test *nst, const struct jt *jt, const struct vari tab_hline (table, TAL_2, 0, tab_nc (table) -1, column_headers); tab_vline (table, TAL_2, row_headers, 0, tab_nr (table) - 1); - tab_text_format (table, 1, 0, TAT_TITLE | TAB_CENTER, - _("Number of levels in %s"), - var_to_string (nst->indep_var)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (nst->indep_var, &varstr); + tab_text_format (table, 1, 0, TAT_TITLE | TAB_CENTER, + _("Number of levels in %s"), + + ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_text (table, 2, 0, TAT_TITLE | TAB_CENTER, _("N")); tab_text (table, 3, 0, TAT_TITLE | TAB_CENTER, _("Observed J-T Statistic")); tab_text (table, 4, 0, TAT_TITLE | TAB_CENTER, _("Mean J-T Statistic")); @@ -388,9 +395,12 @@ show_jt (const struct n_sample_test *nst, const struct jt *jt, const struct vari for (i = 0; i < nst->n_vars; ++i) { double std_jt; - + struct string varstr; + ds_init_empty (&varstr); + var_append_string (nst->vars[i], &varstr); tab_text (table, 0, i + row_headers, TAT_TITLE, - var_to_string (nst->vars[i]) ); + ds_cstr (&varstr) ); + ds_destroy (&varstr); tab_double (table, 1, i + row_headers, TAT_TITLE, jt[0].levels, &F_8_0); diff --git a/src/language/stats/kruskal-wallis.c b/src/language/stats/kruskal-wallis.c index cea302b..6313d3a 100644 --- a/src/language/stats/kruskal-wallis.c +++ b/src/language/stats/kruskal-wallis.c @@ -265,10 +265,15 @@ show_ranks_box (const struct n_sample_test *nst, const struct kw *kw, int n_grou tab_box (table, TAL_2, TAL_2, -1, -1, 0, 0, tab_nc (table) - 1, tab_nr (table) - 1 ); - tab_text (table, 1, 0, TAT_TITLE, - var_to_string (nst->indep_var) - ); - + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (nst->indep_var, &varstr); + tab_text (table, 1, 0, TAT_TITLE, + ds_cstr (&varstr)); + ds_destroy (&varstr); + } + tab_text (table, 3, 0, 0, _("Mean Rank")); tab_text (table, 2, 0, 0, _("N")); @@ -287,8 +292,13 @@ show_ranks_box (const struct n_sample_test *nst, const struct kw *kw, int n_grou if (i > 0) tab_hline (table, TAL_1, 0, tab_nc (table) -1, row); - tab_text (table, 0, row, - TAT_TITLE, var_to_string (nst->vars[i])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (nst->vars[i], &varstr); + tab_text (table, 0, row, TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); + } /* Sort the rank entries, by iteratin the hash and putting the entries into a binary tree. */ @@ -362,9 +372,13 @@ show_sig_box (const struct n_sample_test *nst, const struct kw *kw) for (i = 0 ; i < nst->n_vars; ++i) { const double df = hmap_count (&kw[i].map) - 1; + + struct string varstr; + ds_init_empty (&varstr); + var_append_string (nst->vars[i], &varstr); tab_text (table, column_headers + 1 + i, 0, TAT_TITLE, - var_to_string (nst->vars[i]) - ); + ds_cstr (&varstr)); + ds_destroy (&varstr); tab_double (table, column_headers + 1 + i, 1, 0, kw[i].h, 0); diff --git a/src/language/stats/ks-one-sample.c b/src/language/stats/ks-one-sample.c index aaab53f..f512726 100644 --- a/src/language/stats/ks-one-sample.c +++ b/src/language/stats/ks-one-sample.c @@ -337,9 +337,13 @@ show_results (const struct ks *ks, double abs = 0; double z = 0; const int col = 2 + i; + struct string varstr; + ds_init_empty (&varstr); + var_append_string (kst->parent.vars[i], &varstr); tab_text (table, col, 0, TAT_TITLE | TAB_CENTER , - var_to_string (kst->parent.vars[i])); + ds_cstr (&varstr)); + ds_destroy (&varstr); switch (kst->dist) { diff --git a/src/language/stats/mann-whitney.c b/src/language/stats/mann-whitney.c index 60f251b..5c431c3 100644 --- a/src/language/stats/mann-whitney.c +++ b/src/language/stats/mann-whitney.c @@ -207,9 +207,13 @@ show_ranks_box (const struct n_sample_test *nst, const struct mw *mwv) for (i = 0 ; i < nst->n_vars ; ++i) { const struct mw *mw = &mwv[i]; + struct string varstr; + ds_init_empty (&varstr); + var_append_string (nst->vars[i], &varstr); tab_text (table, 0, column_headers + i, TAT_TITLE, - var_to_string (nst->vars[i])); - + ds_cstr (&varstr)); + ds_destroy (&varstr); + tab_double (table, 1, column_headers + i, 0, mw->n[0], 0); @@ -275,9 +279,13 @@ show_statistics_box (const struct n_sample_test *nst, const struct mw *mwv, bool for (i = 0 ; i < nst->n_vars ; ++i) { const struct mw *mw = &mwv[i]; + struct string varstr; + ds_init_empty (&varstr); + var_append_string (nst->vars[i], &varstr); tab_text (table, 0, column_headers + i, TAT_TITLE, - var_to_string (nst->vars[i])); + ds_cstr (&varstr)); + ds_destroy (&varstr); tab_double (table, 1, column_headers + i, 0, mw->u, 0); diff --git a/src/language/stats/mcnemar.c b/src/language/stats/mcnemar.c index 4f64bbb..f7c36ff 100644 --- a/src/language/stats/mcnemar.c +++ b/src/language/stats/mcnemar.c @@ -180,9 +180,10 @@ output_freq_table (variable_pair *vp, var_append_value_name ((*vp)[0], ¶m->val0, &val0str); var_append_value_name ((*vp)[1], ¶m->val1, &val1str); - ds_init_cstr (&pair_name, var_to_string ((*vp)[0])); + ds_init_empty (&pair_name); + var_append_string ((*vp)[0], &pair_name); ds_put_cstr (&pair_name, " & "); - ds_put_cstr (&pair_name, var_to_string ((*vp)[1])); + var_append_string ((*vp)[1], &pair_name); tab_title (table, "%s", ds_cstr (&pair_name)); @@ -201,12 +202,23 @@ output_freq_table (variable_pair *vp, tab_vline (table, TAL_2, header_cols, 0, tab_nr (table) - 1); tab_hline (table, TAL_2, 0, tab_nc (table) - 1, header_rows); - tab_text (table, 0, 0, TAB_CENTER, var_to_string ((*vp)[0])); - - tab_joint_text (table, 1, 0, 2, 0, TAB_CENTER, var_to_string ((*vp)[1])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string ((*vp)[0], &varstr); + tab_text (table, 0, 0, TAB_CENTER, ds_cstr (&varstr)); + ds_destroy (&varstr); + } + + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string ((*vp)[1], &varstr); + tab_joint_text (table, 1, 0, 2, 0, TAB_CENTER, ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_hline (table, TAL_1, 1, tab_nc (table) - 1, 1); - tab_text (table, 0, header_rows + 0, TAB_LEFT, ds_cstr (&val0str)); tab_text (table, 0, header_rows + 1, TAB_LEFT, ds_cstr (&val1str)); @@ -273,9 +285,10 @@ output_statistics_table (const struct two_sample_test *t2s, variable_pair *vp = &t2s->pairs[i]; struct string pair_name; - ds_init_cstr (&pair_name, var_to_string ((*vp)[0])); + ds_init_empty (&pair_name); + var_append_string ((*vp)[0], &pair_name); ds_put_cstr (&pair_name, " & "); - ds_put_cstr (&pair_name, var_to_string ((*vp)[1])); + var_append_string ((*vp)[1], &pair_name); tab_text (table, 0, 1 + i, TAB_LEFT, ds_cstr (&pair_name)); ds_destroy (&pair_name); diff --git a/src/language/stats/means.c b/src/language/stats/means.c index 502726e..e094f94 100644 --- a/src/language/stats/means.c +++ b/src/language/stats/means.c @@ -1054,7 +1054,11 @@ output_case_processing_summary (const struct mtable *table) for (v = 0; v < table->n_dep_vars; ++v) { const struct variable *var = table->dep_vars[v]; - const char *dv_name = var_to_string (var); + + struct string varstr; + ds_init_empty (&varstr); + var_append_string (var, &varstr); + for (i = 0; i < table->n_layers; ++i) { const int row = v * table->n_layers + i; @@ -1062,7 +1066,7 @@ output_case_processing_summary (const struct mtable *table) casenumber n_total; struct string str; - ds_init_cstr (&str, dv_name); + ds_init_string (&str, &varstr); ds_put_cstr (&str, ": "); interaction_to_string (iact, &str); @@ -1102,6 +1106,7 @@ output_case_processing_summary (const struct mtable *table) ds_destroy (&str); } + ds_destroy (&varstr); } tab_submit (t); @@ -1138,9 +1143,13 @@ output_report (const struct means *cmd, int iact_idx, tab_vline (t, TAL_2, heading_columns, 0, nr - 1); for (i = 0; i < iact->n_vars; ++i) - { + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (iact->vars[i], &varstr); tab_text (t, 1 + i, 0, TAB_CENTER | TAT_TITLE, - var_to_string (iact->vars[i])); + ds_cstr (&varstr)); + ds_destroy (&varstr); } for (i = 0; i < cmd->n_cells; ++i) @@ -1150,7 +1159,6 @@ output_report (const struct means *cmd, int iact_idx, gettext (cell_spec[cmd->cells[i]].title)); } - for (i = 0; i < n_cats; ++i) { int v, dv; diff --git a/src/language/stats/median.c b/src/language/stats/median.c index a894f01..5049730 100644 --- a/src/language/stats/median.c +++ b/src/language/stats/median.c @@ -325,10 +325,15 @@ show_frequencies (const struct n_sample_test *nst, const struct results *results tab_hline (table, TAL_2, 0, tab_nc (table) -1, column_headers); tab_vline (table, TAL_2, row_headers, 0, tab_nr (table) - 1); - tab_joint_text (table, - row_headers, 0, row_headers + n_vals - 1, 0, - TAT_TITLE | TAB_CENTER, var_to_string (nst->indep_var)); - + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (nst->indep_var, &varstr); + tab_joint_text (table, + row_headers, 0, row_headers + n_vals - 1, 0, + TAT_TITLE | TAB_CENTER, ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_hline (table, TAL_1, row_headers, tab_nc (table) - 1, 1); @@ -351,9 +356,13 @@ show_frequencies (const struct n_sample_test *nst, const struct results *results for (v = 0; v < nst->n_vars; ++v) { const struct results *rs = &results[v]; + struct string varstr; + ds_init_empty (&varstr); + var_append_string (rs->var, &varstr); tab_text (table, 0, column_headers + v * 2, - TAT_TITLE | TAB_LEFT, var_to_string (rs->var) ); - + TAT_TITLE | TAB_LEFT, ds_cstr (&varstr) ); + ds_destroy (&varstr); + tab_text (table, 1, column_headers + v * 2, TAT_TITLE | TAB_LEFT, _("> Median") ); @@ -433,9 +442,13 @@ show_test_statistics (const struct n_sample_test *nst, { double df = n_vals - 1; const struct results *rs = &results[v]; - tab_text (table, 0, column_headers + v, - TAT_TITLE | TAB_LEFT, var_to_string (rs->var)); + struct string varstr; + ds_init_empty (&varstr); + var_append_string (rs->var, &varstr); + tab_text (table, 0, column_headers + v, + TAT_TITLE | TAB_LEFT, ds_cstr (&varstr)); + ds_destroy (&varstr); tab_double (table, row_headers + 0, column_headers + v, 0, rs->n, wfmt); diff --git a/src/language/stats/npar-summary.c b/src/language/stats/npar-summary.c index e1870f6..9cb46cd 100644 --- a/src/language/stats/npar-summary.c +++ b/src/language/stats/npar-summary.c @@ -158,9 +158,12 @@ do_summary_box (const struct descriptives *desc, { const struct variable *var = vv[v]; const struct fmt_spec *fmt = var_get_print_format (var); - - tab_text (table, 0, 2 + v, 0, var_to_string (var)); - + struct string varstr; + ds_init_empty (&varstr); + var_append_string (var, &varstr); + tab_text (table, 0, 2 + v, 0, ds_cstr (&varstr)); + ds_destroy (&varstr); + col = 1; if (desc != NULL) { diff --git a/src/language/stats/oneway.c b/src/language/stats/oneway.c index 9f66014..22ac88e 100644 --- a/src/language/stats/oneway.c +++ b/src/language/stats/oneway.c @@ -932,8 +932,11 @@ show_anova_table (const struct oneway_spec *cmd, const struct oneway_workspace * double n; double df1, df2; double msa; - const char *s = var_to_string (cmd->vars[i]); + const struct per_var_ws *pvw = &ws->vws[i]; + struct string varstr; + ds_init_empty (&varstr); + var_append_string (cmd->vars[i], &varstr); moments1_calculate (ws->dd_total[i]->mom, &n, NULL, NULL, NULL, NULL); @@ -941,11 +944,11 @@ show_anova_table (const struct oneway_spec *cmd, const struct oneway_workspace * df2 = n - pvw->n_groups; msa = pvw->ssa / df1; - tab_text (t, 0, i * 3 + 1, TAB_LEFT | TAT_TITLE, s); + tab_text (t, 0, i * 3 + 1, TAB_LEFT | TAT_TITLE, ds_cstr (&varstr)); tab_text (t, 1, i * 3 + 1, TAB_LEFT | TAT_TITLE, _("Between Groups")); tab_text (t, 1, i * 3 + 2, TAB_LEFT | TAT_TITLE, _("Within Groups")); tab_text (t, 1, i * 3 + 3, TAB_LEFT | TAT_TITLE, _("Total")); - + ds_destroy (&varstr); if (i > 0) tab_hline (t, TAL_1, 0, n_cols - 1, i * 3 + 1); @@ -1037,7 +1040,6 @@ show_descriptives (const struct oneway_spec *cmd, const struct oneway_workspace row = 2; for (v = 0; v < cmd->n_vars; ++v) { - const char *s = var_to_string (cmd->vars[v]); const struct fmt_spec *fmt = var_get_print_format (cmd->vars[v]); int count = 0; @@ -1045,7 +1047,12 @@ show_descriptives (const struct oneway_spec *cmd, const struct oneway_workspace struct per_var_ws *pvw = &ws->vws[v]; const struct categoricals *cats = covariance_get_categoricals (pvw->cov); - tab_text (t, 0, row, TAB_LEFT | TAT_TITLE, s); + struct string varstr; + ds_init_empty (&varstr); + var_append_string (cmd->vars[v], &varstr); + + tab_text (t, 0, row, TAB_LEFT | TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); if ( v > 0) tab_hline (t, TAL_1, 0, n_cols - 1, row); @@ -1180,17 +1187,19 @@ show_homogeneity (const struct oneway_spec *cmd, const struct oneway_workspace * double n; const struct per_var_ws *pvw = &ws->vws[v]; double F = levene_calculate (pvw->nl); - - const struct variable *var = cmd->vars[v]; - const char *s = var_to_string (var); double df1, df2; + const struct variable *var = cmd->vars[v]; + struct string varstr; + ds_init_empty (&varstr); + var_append_string (var, &varstr); moments1_calculate (ws->dd_total[v]->mom, &n, NULL, NULL, NULL, NULL); df1 = pvw->n_groups - 1; df2 = n - pvw->n_groups; - tab_text (t, 0, v + 1, TAB_LEFT | TAT_TITLE, s); + tab_text (t, 0, v + 1, TAB_LEFT | TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); tab_double (t, 1, v + 1, TAB_RIGHT, F, NULL); tab_fixed (t, 2, v + 1, TAB_RIGHT, df1, 8, 0); @@ -1250,9 +1259,14 @@ show_contrast_coeffs (const struct oneway_spec *cmd, const struct oneway_workspa tab_text (t, 0, 2, TAB_LEFT | TAT_TITLE, _("Contrast")); - - tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE, - var_to_string (cmd->indep_var)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (cmd->indep_var, &varstr); + tab_joint_text (t, 2, 0, n_cols - 1, 0, TAB_CENTER | TAT_TITLE, + ds_cstr (&varstr)); + ds_destroy (&varstr); + } for ( cli = ll_head (&cmd->contrast_list); cli != ll_null (&cmd->contrast_list); @@ -1337,8 +1351,14 @@ show_contrast_tests (const struct oneway_spec *cmd, const struct oneway_workspac int i = 0; int lines_per_variable = 2 * n_contrasts; - tab_text (t, 0, (v * lines_per_variable) + 1, TAB_LEFT | TAT_TITLE, - var_to_string (cmd->vars[v])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (cmd->vars[v], &varstr); + tab_text (t, 0, (v * lines_per_variable) + 1, TAB_LEFT | TAT_TITLE, + ds_cstr (&varstr)); + ds_destroy (&varstr); + } for ( cli = ll_head (&cmd->contrast_list); cli != ll_null (&cmd->contrast_list); @@ -1525,8 +1545,20 @@ show_comparisons (const struct oneway_spec *cmd, const struct oneway_workspace * tab_title (t, _("Multiple Comparisons")); - tab_text_format (t, 1, 1, TAB_LEFT | TAT_TITLE, _("(I) %s"), var_to_string (cmd->indep_var)); - tab_text_format (t, 2, 1, TAB_LEFT | TAT_TITLE, _("(J) %s"), var_to_string (cmd->indep_var)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (cmd->indep_var, &varstr); + tab_text_format (t, 1, 1, TAB_LEFT | TAT_TITLE, _("(I) %s"), ds_cstr (&varstr)); + ds_destroy (&varstr); + } + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (cmd->indep_var, &varstr); + tab_text_format (t, 2, 1, TAB_LEFT | TAT_TITLE, _("(J) %s"), ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Mean Difference")); tab_text (t, 3, 1, TAB_CENTER | TAT_TITLE, _("(I - J)")); tab_text (t, 4, 1, TAB_CENTER | TAT_TITLE, _("Std. Error")); diff --git a/src/language/stats/quick-cluster.c b/src/language/stats/quick-cluster.c index e6987f4..2581051 100644 --- a/src/language/stats/quick-cluster.c +++ b/src/language/stats/quick-cluster.c @@ -419,9 +419,13 @@ quick_cluster_show_centers (struct Kmeans *kmeans, bool initial, const struct qc tab_hline (t, TAL_1, 1, nc - 1, currow); currow++; for (i = 0; i < qc->n_vars; i++) - { + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (qc->vars[i], &varstr); tab_text (t, 0, currow + i, TAB_LEFT, - var_to_string (qc->vars[i])); + ds_cstr (&varstr)); + ds_destroy (&varstr); } for (i = 0; i < qc->ngroups; i++) diff --git a/src/language/stats/regression.c b/src/language/stats/regression.c index 0a2e2a8..269e032 100644 --- a/src/language/stats/regression.c +++ b/src/language/stats/regression.c @@ -774,7 +774,13 @@ reg_stats_coeff (linreg * c, void *aux_) this_row = j + 2; v = linreg_indep_var (c, j); - label = var_to_string (v); + { + struct string varstr; + ds_init_empty (&varstr); +var_append_string (v, &varstr); + label = ds_cstr (&varstr); + ds_destroy (&varstr); + } /* Do not overwrite the variable's name. */ ds_put_cstr (&tstr, label); tab_text (t, 1, this_row, TAB_CENTER, ds_cstr (&tstr)); @@ -899,7 +905,13 @@ reg_stats_bcov (linreg * c, void *aux UNUSED) for (i = 0; i < linreg_n_coeffs (c); i++) { const struct variable *v = linreg_indep_var (c, i); - label = var_to_string (v); + { + struct string varstr; + ds_init_empty (&varstr); +var_append_string (v, &varstr); + label = ds_cstr (&varstr); + ds_destroy (&varstr); + } tab_text (t, 2, i, TAB_CENTER, label); tab_text (t, i + 2, 0, TAB_CENTER, label); for (k = 1; k < linreg_n_coeffs (c); k++) diff --git a/src/language/stats/reliability.c b/src/language/stats/reliability.c index 7447633..2a20d01 100644 --- a/src/language/stats/reliability.c +++ b/src/language/stats/reliability.c @@ -626,8 +626,13 @@ reliability_summary_total (const struct reliability *rel) double mean, weight, var; const struct cronbach *s = &rel->sc[rel->total_start + i]; + + struct string varstr; + ds_init_empty (&varstr); + var_append_string (rel->sc[0].items[i], &varstr); tab_text (tbl, 0, heading_rows + i, TAB_LEFT| TAT_TITLE, - var_to_string (rel->sc[0].items[i])); + ds_cstr (&varstr)); + ds_destroy (&varstr); moments1_calculate (s->total, &weight, &mean, &var, 0, 0); diff --git a/src/language/stats/roc.c b/src/language/stats/roc.c index 471b946..bdbe6fc 100644 --- a/src/language/stats/roc.c +++ b/src/language/stats/roc.c @@ -954,7 +954,14 @@ show_auc (struct roc_state *rs, const struct cmd_roc *roc) if ( roc->n_vars > 1) tab_title (tbl, _("Area Under the Curve")); else - tab_title (tbl, _("Area Under the Curve (%s)"), var_to_string (roc->vars[0])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (roc->vars[0], &varstr); + tab_title (tbl, _("Area Under the Curve (%s)"), ds_cstr (&varstr)); + ds_destroy (&varstr); + } + tab_headers (tbl, n_cols - n_fields, 0, 1, 0); @@ -993,9 +1000,13 @@ show_auc (struct roc_state *rs, const struct cmd_roc *roc) for ( i = 0 ; i < roc->n_vars ; ++i ) - { - tab_text (tbl, 0, 2 + i, TAT_TITLE, var_to_string (roc->vars[i])); - + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (roc->vars[i], &varstr); + tab_text (tbl, 0, 2 + i, TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); + tab_double (tbl, n_cols - n_fields, 2 + i, 0, rs[i].auc, NULL); if ( roc->print_se ) @@ -1063,8 +1074,13 @@ show_summary (const struct cmd_roc *roc) tab_hline (tbl, TAL_2, 1, n_cols - 1, 1); tab_vline (tbl, TAL_1, 2, 1, n_rows - 1); - - tab_text (tbl, 0, 1, TAT_TITLE | TAB_LEFT, var_to_string (roc->state_var)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (roc->state_var, &varstr); + tab_text (tbl, 0, 1, TAT_TITLE | TAB_LEFT, ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_text (tbl, 1, 1, TAT_TITLE, _("Unweighted")); tab_text (tbl, 2, 1, TAT_TITLE, _("Weighted")); @@ -1104,7 +1120,13 @@ show_coords (struct roc_state *rs, const struct cmd_roc *roc) if ( roc->n_vars > 1) tab_title (tbl, _("Coordinates of the Curve")); else - tab_title (tbl, _("Coordinates of the Curve (%s)"), var_to_string (roc->vars[0])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (roc->vars[0], &varstr); + tab_title (tbl, _("Coordinates of the Curve (%s)"), ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_headers (tbl, 1, 0, 1, 0); @@ -1134,7 +1156,13 @@ show_coords (struct roc_state *rs, const struct cmd_roc *roc) struct casereader *r = casereader_clone (rs[i].cutpoint_rdr); if ( roc->n_vars > 1) - tab_text (tbl, 0, x, TAT_TITLE, var_to_string (roc->vars[i])); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (roc->vars[i], &varstr); + tab_text (tbl, 0, x, TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); + } if ( i > 0) tab_hline (tbl, TAL_1, 0, n_cols - 1, x); diff --git a/src/language/stats/runs.c b/src/language/stats/runs.c index 7e36065..c817346 100644 --- a/src/language/stats/runs.c +++ b/src/language/stats/runs.c @@ -334,9 +334,13 @@ show_runs_result (const struct runs_test *rt, const struct run_state *rs, const double z = runs_statistic (run); + struct string varstr; + ds_init_empty (&varstr); + var_append_string (otp->vars[i], &varstr); tab_text (table, row_headers + i, 0, TAT_TITLE | TAB_CENTER , - var_to_string (otp->vars[i])); + ds_cstr (&varstr)); + ds_destroy (&varstr); tab_double (table, row_headers +i, 1, 0, run->cutpoint, 0); diff --git a/src/language/stats/sign.c b/src/language/stats/sign.c index e208ce9..111d599 100644 --- a/src/language/stats/sign.c +++ b/src/language/stats/sign.c @@ -78,11 +78,13 @@ output_frequency_table (const struct two_sample_test *t2s, variable_pair *vp = &t2s->pairs[i]; struct string pair_name; - ds_init_cstr (&pair_name, var_to_string ((*vp)[0])); + ds_init_empty (&pair_name); + var_append_string ((*vp)[0], &pair_name); + ds_put_cstr (&pair_name, " - "); - ds_put_cstr (&pair_name, var_to_string ((*vp)[1])); - + var_append_string ((*vp)[1], &pair_name); + tab_text (table, 0, 1 + i * 4, TAB_LEFT, ds_cstr (&pair_name)); ds_destroy (&pair_name); @@ -143,9 +145,12 @@ output_statistics_table (const struct two_sample_test *t2s, variable_pair *vp = &t2s->pairs[i]; struct string pair_name; - ds_init_cstr (&pair_name, var_to_string ((*vp)[0])); + ds_init_empty (&pair_name); + var_append_string ((*vp)[0], &pair_name); + ds_put_cstr (&pair_name, " - "); - ds_put_cstr (&pair_name, var_to_string ((*vp)[1])); + + var_append_string ((*vp)[1], &pair_name); tab_text (table, 1 + i, 0, TAB_LEFT, ds_cstr (&pair_name)); ds_destroy (&pair_name); diff --git a/src/language/stats/t-test-indep.c b/src/language/stats/t-test-indep.c index c805054..b265a6d 100644 --- a/src/language/stats/t-test-indep.c +++ b/src/language/stats/t-test-indep.c @@ -207,7 +207,13 @@ indep_summary (const struct tt *tt, struct indep_samples *is, const struct pair_ tab_vline (t, TAL_GAP, 1, 0, rows - 1); tab_title (t, _("Group Statistics")); - tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, var_to_string (is->gvar)); + { + struct string varstr; + ds_init_empty (&varstr); +var_append_string (is->gvar, &varstr); + tab_text (t, 1, 0, TAB_CENTER | TAT_TITLE, ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_text (t, 2, 0, TAB_CENTER | TAT_TITLE, _("N")); tab_text (t, 3, 0, TAB_CENTER | TAT_TITLE, _("Mean")); tab_text (t, 4, 0, TAB_CENTER | TAT_TITLE, _("Std. Deviation")); @@ -232,8 +238,14 @@ indep_summary (const struct tt *tt, struct indep_samples *is, const struct pair_ int i; const struct variable *var = tt->vars[v]; + { + struct string varstr; + ds_init_empty (&varstr); +var_append_string (var, &varstr); tab_text (t, 0, v * 2 + heading_rows, TAB_LEFT, - var_to_string (var)); + ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_text (t, 1, v * 2 + heading_rows, TAB_LEFT, ds_cstr (&vallab0)); @@ -309,7 +321,13 @@ indep_test (const struct tt *tt, const struct pair_stats *ps) moments_calculate (ps[v].mom[0], &cc0, &mean0, &sigma0, NULL, NULL); moments_calculate (ps[v].mom[1], &cc1, &mean1, &sigma1, NULL, NULL); - tab_text (t, 0, v * 2 + heading_rows, TAB_LEFT, var_to_string (tt->vars[v])); + { + struct string varstr; + ds_init_empty (&varstr); +var_append_string (tt->vars[v], &varstr); + tab_text (t, 0, v * 2 + heading_rows, TAB_LEFT, ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_text (t, 1, v * 2 + heading_rows, TAB_LEFT, _("Equal variances assumed")); df = cc0 + cc1 - 2.0; diff --git a/src/language/stats/t-test-one-sample.c b/src/language/stats/t-test-one-sample.c index 38c1eff..6ae38f8 100644 --- a/src/language/stats/t-test-one-sample.c +++ b/src/language/stats/t-test-one-sample.c @@ -118,7 +118,13 @@ one_sample_test (const struct tt *tt, const struct one_samp *os) p = gsl_cdf_tdist_P (tval, df); q = gsl_cdf_tdist_Q (tval, df); - tab_text (t, 0, v + heading_rows, TAB_LEFT, var_to_string (per_var_stats->var)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (per_var_stats->var, &varstr); + tab_text (t, 0, v + heading_rows, TAB_LEFT, ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_double (t, 1, v + heading_rows, TAB_RIGHT, tval, NULL); tab_double (t, 2, v + heading_rows, TAB_RIGHT, df, wfmt); @@ -167,7 +173,13 @@ one_sample_summary (const struct tt *tt, const struct one_samp *os) double cc, mean, sigma; moments_calculate (m, &cc, &mean, &sigma, NULL, NULL); - tab_text (t, 0, v + heading_rows, TAB_LEFT, var_to_string (per_var_stats->var)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (per_var_stats->var, &varstr); + tab_text (t, 0, v + heading_rows, TAB_LEFT, ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_double (t, 1, v + heading_rows, TAB_RIGHT, cc, wfmt); tab_double (t, 2, v + heading_rows, TAB_RIGHT, mean, NULL); tab_double (t, 3, v + heading_rows, TAB_RIGHT, sqrt (sigma), NULL); diff --git a/src/language/stats/t-test-paired.c b/src/language/stats/t-test-paired.c index edeaa38..bbf27ed 100644 --- a/src/language/stats/t-test-paired.c +++ b/src/language/stats/t-test-paired.c @@ -190,7 +190,13 @@ paired_summary (const struct tt *tt, struct paired_samp *os) /* first var */ moments_calculate (pp->mom0, &cc, &mean, &sigma, NULL, NULL); - tab_text (t, 1, v * 2 + heading_rows, TAB_LEFT, var_to_string (pp->var0)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (pp->var0, &varstr); + tab_text (t, 1, v * 2 + heading_rows, TAB_LEFT, ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_double (t, 3, v * 2 + heading_rows, TAB_RIGHT, cc, wfmt); tab_double (t, 2, v * 2 + heading_rows, TAB_RIGHT, mean, NULL); tab_double (t, 4, v * 2 + heading_rows, TAB_RIGHT, sqrt (sigma), NULL); @@ -198,7 +204,13 @@ paired_summary (const struct tt *tt, struct paired_samp *os) /* second var */ moments_calculate (pp->mom1, &cc, &mean, &sigma, NULL, NULL); - tab_text (t, 1, v * 2 + 1 + heading_rows, TAB_LEFT, var_to_string (pp->var1)); + { + struct string varstr; + ds_init_empty (&varstr); + var_append_string (pp->var1, &varstr); + tab_text (t, 1, v * 2 + 1 + heading_rows, TAB_LEFT, ds_cstr (&varstr)); + ds_destroy (&varstr); + } tab_double (t, 3, v * 2 + 1 + heading_rows, TAB_RIGHT, cc, wfmt); tab_double (t, 2, v * 2 + 1 + heading_rows, TAB_RIGHT, mean, NULL); tab_double (t, 4, v * 2 + 1 + heading_rows, TAB_RIGHT, sqrt (sigma), NULL); @@ -243,13 +255,20 @@ paired_correlations (const struct tt *tt, struct paired_samp *os) tab_text_format (t, 0, v + heading_rows, TAB_LEFT, _("Pair %d"), pp->posn); - tab_text_format (t, 1, v + heading_rows, TAB_LEFT, _("%s & %s"), - var_to_string (pp->var0), - var_to_string (pp->var1)); + { + struct string pair_name; + ds_init_empty (&pair_name); + var_append_string (pp->var0, &pair_name); + ds_put_cstr (&pair_name, " & "); + var_append_string (pp->var1, &pair_name); + + tab_text_format (t, 1, v + heading_rows, TAB_LEFT, ds_cstr (&pair_name)); + ds_destroy (&pair_name); + } moments_calculate (pp->mom0, &cc0, &mean0, &sigma0, NULL, NULL); moments_calculate (pp->mom1, &cc1, &mean1, &sigma1, NULL, NULL); - + /* If this fails, then we're not dealing with missing values properly */ assert (cc0 == cc1); @@ -326,9 +345,16 @@ paired_test (const struct tt *tt, const struct paired_samp *os) df = cc - 1.0; tab_text_format (t, 0, v + heading_rows, TAB_LEFT, _("Pair %d"), v); - tab_text_format (t, 1, v + heading_rows, TAB_LEFT, _("%s - %s"), - var_to_string (pp->var0), - var_to_string (pp->var1)); + { + struct string pair_name; + ds_init_empty (&pair_name); + var_append_string (pp->var0, &pair_name); + ds_put_cstr (&pair_name, " - "); + var_append_string (pp->var1, &pair_name); + + tab_text_format (t, 1, v + heading_rows, TAB_LEFT, ds_cstr (&pair_name)); + ds_destroy (&pair_name); + } tval = mean * sqrt (cc / sigma); se_mean = sqrt (sigma / cc); diff --git a/src/language/stats/wilcoxon.c b/src/language/stats/wilcoxon.c index 284e547..a01326b 100644 --- a/src/language/stats/wilcoxon.c +++ b/src/language/stats/wilcoxon.c @@ -244,11 +244,6 @@ show_ranks_box (const struct wilcoxon_state *ws, { variable_pair *vp = &t2s->pairs[i]; - struct string pair_name; - ds_init_cstr (&pair_name, var_to_string ((*vp)[0])); - ds_put_cstr (&pair_name, " - "); - ds_put_cstr (&pair_name, var_to_string ((*vp)[1])); - tab_text (table, 1, 1 + i * 4, TAB_LEFT, _("Negative Ranks")); tab_text (table, 1, 2 + i * 4, TAB_LEFT, _("Positive Ranks")); tab_text (table, 1, 3 + i * 4, TAB_LEFT, _("Ties")); @@ -256,10 +251,16 @@ show_ranks_box (const struct wilcoxon_state *ws, tab_hline (table, TAL_1, 0, tab_nc (table) - 1, 1 + i * 4); + { + struct string pair_name; + ds_init_empty (&pair_name); + var_append_string ((*vp)[0], &pair_name); + ds_put_cstr (&pair_name, " - "); + var_append_string ((*vp)[1], &pair_name); - tab_text (table, 0, 1 + i * 4, TAB_LEFT, ds_cstr (&pair_name)); - ds_destroy (&pair_name); - + tab_text (table, 0, 1 + i * 4, TAB_LEFT, ds_cstr (&pair_name)); + ds_destroy (&pair_name); + } /* N */ tab_double (table, 2, 1 + i * 4, TAB_RIGHT, ws[i].negatives.n, wfmt); @@ -333,14 +334,16 @@ show_tests_box (const struct wilcoxon_state *ws, double n = ws[i].positives.n + ws[i].negatives.n; variable_pair *vp = &t2s->pairs[i]; - struct string pair_name; - ds_init_cstr (&pair_name, var_to_string ((*vp)[0])); - ds_put_cstr (&pair_name, " - "); - ds_put_cstr (&pair_name, var_to_string ((*vp)[1])); - + { + struct string pair_name; + ds_init_empty (&pair_name); + var_append_string ((*vp)[0], &pair_name); + ds_put_cstr (&pair_name, " - "); + var_append_string ((*vp)[1], &pair_name); - tab_text (table, 1 + i, 0, TAB_CENTER, ds_cstr (&pair_name)); - ds_destroy (&pair_name); + tab_text (table, 1 + i, 0, TAB_CENTER, ds_cstr (&pair_name)); + ds_destroy (&pair_name); + } z = MIN (ws[i].positives.sum, ws[i].negatives.sum); z -= n * (n + 1)/ 4.0; diff --git a/src/math/interaction.c b/src/math/interaction.c index a36755b..3c2daab 100644 --- a/src/math/interaction.c +++ b/src/math/interaction.c @@ -168,11 +168,12 @@ interaction_to_string (const struct interaction *iact, struct string *str) int v = 0; if ( iact->n_vars == 0) return; - ds_put_cstr (str, var_to_string (iact->vars[v])); + + var_append_string (iact->vars[v], str); for (v = 1; v < iact->n_vars; ++v) { ds_put_cstr (str, " * "); - ds_put_cstr (str, var_to_string (iact->vars[v])); + var_append_string (iact->vars[v], str); } } -- 1.5.6.5