Corrected logical errors in tests for error conditions.
[pspp] / src / language / stats / examine.c
index 0d260cffbf55ae130c056f2bcc0073a5ac8446d1..f4f49f329ffdf2b1f706d34ce9824e51515035c4 100644 (file)
@@ -129,9 +129,9 @@ struct examine
   size_t n_percentiles;
   
   bool npplot;
-  bool histogram;
+  bool histogramplot;
   bool boxplot;
-  bool spreadlevel;
+  bool spreadlevelplot;
   int sl_power;
 
   enum bp_mode boxplot_mode;
@@ -1527,7 +1527,7 @@ update_n (const void *aux1, void *aux2 UNUSED, void *user_data,
   int v;
   const struct examine *examine = aux1;
   struct exploratory_stats *es = user_data;
-
+  
   for (v = 0; v < examine->n_dep_vars; v++)
     {
       struct ccase *outcase ;
@@ -1584,7 +1584,7 @@ calculate_n (const void *aux1, void *aux2 UNUSED, void *user_data)
       struct casereader *reader;
       struct ccase *c;
 
-      if (examine->histogram)
+      if (examine->histogramplot)
         {
           /* Sturges Rule */
           double bin_width = fabs (es[v].minimum - es[v].maximum)
@@ -1801,12 +1801,10 @@ run_examine (struct examine *cmd, struct casereader *input)
 
   categoricals_set_payload (cmd->cats, &payload, cmd, NULL);
 
-  if (cmd->id_idx == -1)
+  if (cmd->id_var == NULL)
     {
       struct ccase *c = casereader_peek (input,  0);
 
-      assert (cmd->id_var == NULL);
-
       cmd->id_idx = case_get_value_cnt (c);
       input = casereader_create_arithmetic_sequence (input, 1.0, 1.0);
 
@@ -1856,13 +1854,13 @@ run_examine (struct examine *cmd, struct casereader *input)
             }
         }
 
-      if (cmd->histogram)
+      if (cmd->histogramplot)
         show_histogram (cmd, i);
 
       if (cmd->npplot)
         show_npplot (cmd, i);
 
-      if (cmd->spreadlevel)
+      if (cmd->spreadlevelplot)
         show_spreadlevel (cmd, i);
 
       if (cmd->descriptives)
@@ -1913,10 +1911,10 @@ cmd_examine (struct lexer *lexer, struct dataset *ds)
 
   examine.dep_excl = MV_ANY;
   examine.fctr_excl = MV_ANY;
-  examine.histogram = false;
+  examine.histogramplot = false;
   examine.npplot = false;
   examine.boxplot = false;
-  examine.spreadlevel = false;
+  examine.spreadlevelplot = false;
   examine.sl_power = 0;
   
   examine.dict = dataset_dict (ds);
@@ -2151,11 +2149,11 @@ cmd_examine (struct lexer *lexer, struct dataset *ds)
                 }
               else if (lex_match_id (lexer, "HISTOGRAM"))
                 {
-                  examine.histogram = true;
+                  examine.histogramplot = true;
                 }
               else if (lex_match_id (lexer, "SPREADLEVEL"))
                 {
-                 examine.spreadlevel = true;
+                 examine.spreadlevelplot = true;
                  examine.sl_power = 0;
                  if (lex_match (lexer, T_LPAREN))
                    {
@@ -2168,13 +2166,13 @@ cmd_examine (struct lexer *lexer, struct dataset *ds)
                 }
               else if (lex_match_id (lexer, "NONE"))
                 {
-                  examine.histogram = false;
+                  examine.histogramplot = false;
                   examine.npplot = false;
                   examine.boxplot = false;
                 }
               else if (lex_match (lexer, T_ALL))
                 {
-                  examine.histogram = true;
+                  examine.histogramplot = true;
                   examine.npplot = true;
                   examine.boxplot = true;
                 }
@@ -2280,6 +2278,8 @@ cmd_examine (struct lexer *lexer, struct dataset *ds)
 
   caseproto_unref (examine.ex_proto);
 
+  for (i = 0; i < examine.n_iacts; ++i)
+    interaction_destroy (examine.iacts[i]);
   free (examine.ptiles);
   free (examine.dep_vars);
   pool_destroy (examine.pool);