X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Fchisquare.c;h=158064dcf920b6f539017c57d2bb9203e2c90457;hb=436b01ace5b84c27963f6130dca0e69fe15f9a17;hp=6b0b0567257bd80d5b812a96438464e8fc4bf75f;hpb=43b1296aafe7582e7dbe6c2b6a8b478d7d9b0fcf;p=pspp-builds.git diff --git a/src/language/stats/chisquare.c b/src/language/stats/chisquare.c index 6b0b0567..158064dc 100644 --- a/src/language/stats/chisquare.c +++ b/src/language/stats/chisquare.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include #include @@ -39,6 +38,8 @@ #include +#include "xalloc.h" + #include "gettext.h" #define _(msgid) gettext (msgid) @@ -194,6 +195,8 @@ create_variable_frequency_table (const struct dictionary *dict, test->n_expected, n_cells, var_get_name (var) ); + hsh_destroy (*freq_hash); + *freq_hash = NULL; return NULL; } @@ -359,12 +362,17 @@ chisquare_execute (const struct dataset *ds, xsq[v] = 0.0; for ( i = 0 ; i < n_cells ; ++i ) { + struct string str; double exp; const union value *observed_value = ff[i]->value; + ds_init_empty (&str); + var_append_value_name (ost->vars[v], observed_value, &str); + /* The key */ - tab_text (freq_table, 0, i + 1, TAB_LEFT, - var_get_value_name (ost->vars[v], observed_value)); + tab_text (freq_table, 0, i + 1, TAB_LEFT, ds_cstr (&str)); + ds_destroy (&str); + /* The observed N */ tab_float (freq_table, 1, i + 1, TAB_NONE, @@ -425,13 +433,17 @@ chisquare_execute (const struct dataset *ds, xsq[v] = 0.0; for ( i = 0 ; i < hsh_count (freq_hash) ; ++i ) { + struct string str; double exp; const union value *observed_value = ff[i]->value; + ds_init_empty (&str); + var_append_value_name (ost->vars[v], observed_value, &str); /* The key */ tab_text (freq_table, v * 4 + 1, i + 2 , TAB_LEFT, - var_get_value_name (ost->vars[v], observed_value)); + ds_cstr (&str)); + ds_destroy (&str); /* The observed N */ tab_float (freq_table, v * 4 + 2, i + 2 , TAB_NONE,