X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flanguage%2Fstats%2Froc.c;h=866eba83f3d7daebf4524f41fad839c6534e6f1a;hb=d6111d26da0701438a2e2813f14b0edfdf5453c8;hp=0709992ce469ae113814f6996b549fe0d684b7fc;hpb=1fe8ef2486ef1e853d68bbab967ccb812900128f;p=pspp-builds.git diff --git a/src/language/stats/roc.c b/src/language/stats/roc.c index 0709992c..866eba83 100644 --- a/src/language/stats/roc.c +++ b/src/language/stats/roc.c @@ -16,10 +16,10 @@ #include -#include "roc.h" #include #include #include +#include #include #include @@ -49,7 +49,7 @@ struct cmd_roc const struct variable **vars; const struct dictionary *dict; - struct variable *state_var ; + const struct variable *state_var ; union value state_value; /* Plot the roc curve */ @@ -98,18 +98,18 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) if (!parse_variables_const (lexer, dict, &roc.vars, &roc.n_vars, PV_APPEND | PV_NO_DUPLICATE | PV_NUMERIC)) - return 2; + goto error;; if ( ! lex_force_match (lexer, T_BY)) { - return 2; + goto error;; } roc.state_var = parse_variable (lexer, dict); if ( !lex_force_match (lexer, '(')) { - return 2; + goto error;; } parse_value (lexer, &roc.state_value, var_get_width (roc.state_var)); @@ -117,7 +117,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) if ( !lex_force_match (lexer, ')')) { - return 2; + goto error;; } @@ -140,7 +140,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - return 2; + goto error;; } } } @@ -164,7 +164,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - return 2; + goto error;; } } else if (lex_match_id (lexer, "PRINT")) @@ -183,7 +183,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - return 2; + goto error;; } } } @@ -206,7 +206,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - return 2; + goto error;; } lex_force_match (lexer, ')'); } @@ -224,7 +224,7 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - return 2; + goto error;; } lex_force_match (lexer, ')'); } @@ -250,14 +250,14 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) else { lex_error (lexer, NULL); - return 2; + goto error;; } lex_force_match (lexer, ')'); } else { lex_error (lexer, NULL); - return 2; + goto error;; } } } @@ -268,9 +268,14 @@ cmd_roc (struct lexer *lexer, struct dataset *ds) } } - run_roc (ds, &roc); + if ( ! run_roc (ds, &roc)) + goto error;; - return 1; + return CMD_SUCCESS; + + error: + free (roc.vars); + return CMD_FAILURE; } @@ -388,12 +393,13 @@ accumulate_counts (struct casereader *cutpoint_rdr, struct ccase *cpc; double prev_cp = SYSMIS; - for ( ; (cpc = casereader_read (r) ); case_unref (cpc)) { struct ccase *new_case; const double cp = case_data_idx (cpc, CUTPOINT)->f; + assert (cp != SYSMIS); + /* We don't want duplicates here */ if ( cp == prev_cp ) continue; @@ -640,14 +646,21 @@ do_roc (struct cmd_roc *roc, struct casereader *reader, struct dictionary *dict) struct subcase up_ordering; struct subcase down_ordering; + struct casewriter *neg_wtr = NULL; + struct casereader *input = casereader_create_filter_missing (reader, roc->vars, roc->n_vars, roc->exclude, NULL, NULL); + input = casereader_create_filter_missing (input, + &roc->state_var, 1, + roc->exclude, + NULL, + NULL); - struct casewriter *neg_wtr = autopaging_writer_create (casereader_get_proto (input)); + neg_wtr = autopaging_writer_create (casereader_get_proto (input)); prepare_cutpoints (roc, rs, input);