X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Froc.c;h=031314cd3972a70abba559c4a39cfe0574ad8a3a;hb=2e4f99b049133c801ca4feffddb86bbf33de3978;hp=22e4acb6fa161621ea2748eb5c33268a7b04e7b0;hpb=691c25e36fd1ee722dd35419d6110e3876b99f9c;p=pspp diff --git a/src/language/stats/roc.c b/src/language/stats/roc.c index 22e4acb6fa..031314cd39 100644 --- a/src/language/stats/roc.c +++ b/src/language/stats/roc.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2009, 2010, 2011 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 @@ -16,27 +16,27 @@ #include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "language/stats/roc.h" #include +#include "data/casegrouper.h" +#include "data/casereader.h" +#include "data/casewriter.h" +#include "data/dataset.h" +#include "data/dictionary.h" +#include "data/format.h" +#include "data/subcase.h" +#include "language/command.h" +#include "language/lexer/lexer.h" +#include "language/lexer/value-parser.h" +#include "language/lexer/variable-parser.h" +#include "libpspp/misc.h" +#include "math/sort.h" +#include "output/chart-item.h" +#include "output/charts/roc-chart.h" +#include "output/tab.h" + #include "gettext.h" #define _(msgid) gettext (msgid) #define N_(msgid) msgid @@ -49,6 +49,7 @@ struct cmd_roc const struct variable *state_var; union value state_value; + size_t state_var_width; /* Plot the roc curve */ bool curve; @@ -94,6 +95,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) roc.neg = roc.neg_weighted = 0; roc.dict = dataset_dict (ds); roc.state_var = NULL; + roc.state_var_width = -1; lex_match (lexer, T_SLASH); if (!parse_variables_const (lexer, dict, &roc.vars, &roc.n_vars, @@ -112,8 +114,9 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) goto error; } - value_init (&roc.state_value, var_get_width (roc.state_var)); - parse_value (lexer, &roc.state_value, var_get_width (roc.state_var)); + roc.state_var_width = var_get_width (roc.state_var); + value_init (&roc.state_value, roc.state_var_width); + parse_value (lexer, &roc.state_value, roc.state_var); if ( !lex_force_match (lexer, T_RPAREN)) @@ -121,7 +124,6 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) goto error; } - while (lex_token (lexer) != T_ENDCMD) { lex_match (lexer, T_SLASH); @@ -272,13 +274,14 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) if ( ! run_roc (ds, &roc)) goto error; - value_destroy (&roc.state_value, var_get_width (roc.state_var)); + if ( roc.state_var) + value_destroy (&roc.state_value, roc.state_var_width); free (roc.vars); return CMD_SUCCESS; error: if ( roc.state_var) - value_destroy (&roc.state_value, var_get_width (roc.state_var)); + value_destroy (&roc.state_value, roc.state_var_width); free (roc.vars); return CMD_FAILURE; }