po: Update translations from translationproject.org.
[pspp] / src / language / stats / roc.c
index b07a58d118f6fdd876ddeec8b300300a3ff0b595..031314cd3972a70abba559c4a39cfe0574ad8a3a 100644 (file)
@@ -23,9 +23,9 @@
 #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/procedure.h"
 #include "data/subcase.h"
 #include "language/command.h"
 #include "language/lexer/lexer.h"
@@ -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;
 }