Changed int to bool in dict_get_weight and sort_active_file_in_place
[pspp] / src / language / stats / t-test.q
index 4754b211297bf4182ef2be42994d47595f9bb920..1f182ec8a1dedbc9d91e6a2638e63130485f46f0 100644 (file)
    02110-1301, USA. */
 
 #include <config.h>
+
 #include <gsl/gsl_cdf.h>
-#include <libpspp/message.h>
+#include <math.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <math.h>
-#include <libpspp/alloc.h>
+
 #include <data/case.h>
 #include <data/casefile.h>
+#include <data/dictionary.h>
+#include <data/procedure.h>
+#include <data/value-labels.h>
+#include <data/variable.h>
 #include <language/command.h>
+#include <language/dictionary/split-file.h>
+#include <language/lexer/lexer.h>
+#include <libpspp/alloc.h>
+#include <libpspp/assertion.h>
 #include <libpspp/compiler.h>
-#include <data/dictionary.h>
-#include <libpspp/message.h>
-#include <math/group-proc.h>
 #include <libpspp/hash.h>
-#include <math/levene.h>
-#include <language/lexer/lexer.h>
 #include <libpspp/magic.h>
+#include <libpspp/message.h>
+#include <libpspp/message.h>
 #include <libpspp/misc.h>
-#include "size_max.h"
-#include <output/manager.h>
 #include <libpspp/str.h>
+#include <math/group-proc.h>
+#include <math/levene.h>
+#include <output/manager.h>
 #include <output/table.h>
-#include <data/value-labels.h>
-#include <data/variable.h>
-#include <procedure.h>
+
+#include "size_max.h"
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
    "T-TEST" (tts_):
      +groups=custom;
      testval=double;
-     variables=varlist("PV_NO_SCRATCH | PV_NUMERIC");
-     pairs=custom;
-     +missing=miss:!analysis/listwise,
-             incl:include/!exclude;
-     format=fmt:!labels/nolabels;
+     +variables=varlist("PV_NO_SCRATCH | PV_NUMERIC");
+     +pairs=custom;
+     missing=miss:!analysis/listwise,
+            incl:include/!exclude;
+     +format=fmt:!labels/nolabels;
      criteria=:cin(d:criteria,"%s > 0. && %s < 1.").
 */
 /* (declarations) */
@@ -230,13 +235,14 @@ static int  group_calc (const struct ccase *, struct cmd_t_test *);
 static void group_postcalc (struct cmd_t_test *);
 
 
-static bool calculate(const struct casefile *cf, void *_mode);
+static bool calculate(const struct ccase *first,
+                      const struct casefile *cf, void *_mode);
 
 static  int mode;
 
 static struct cmd_t_test cmd;
 
-static int bad_weight_warn;
+static bool bad_weight_warn = false;
 
 
 static int compare_group_binary(const struct group_statistics *a, 
@@ -254,7 +260,7 @@ cmd_t_test(void)
 {
   bool ok;
   
-  if ( !parse_t_test(&cmd) )
+  if ( !parse_t_test(&cmd, NULL) )
     return CMD_FAILURE;
 
   if (! cmd.sbc_criteria)
@@ -337,7 +343,7 @@ cmd_t_test(void)
   else
     value_is_missing = mv_is_value_missing;
 
-  bad_weight_warn = 1;
+  bad_weight_warn = true;
 
   ok = multipass_procedure_with_splits (calculate, &cmd);
 
@@ -361,7 +367,7 @@ cmd_t_test(void)
 }
 
 static int
-tts_custom_groups (struct cmd_t_test *cmd UNUSED)
+tts_custom_groups (struct cmd_t_test *cmd UNUSED, void *aux UNUSED)
 {
   int n_group_values=0;
 
@@ -440,7 +446,7 @@ tts_custom_groups (struct cmd_t_test *cmd UNUSED)
 
 
 static int
-tts_custom_pairs (struct cmd_t_test *cmd UNUSED)
+tts_custom_pairs (struct cmd_t_test *cmd UNUSED, void *aux UNUSED)
 {
   struct variable **vars;
   size_t n_vars;
@@ -577,7 +583,7 @@ parse_value (union value * v, int type )
     {
       if (!lex_force_string ())
        return 0;
-      strncpy (v->s, ds_c_str (&tokstr), ds_length (&tokstr));
+      strncpy (v->s, ds_cstr (&tokstr), ds_length (&tokstr));
     }
 
   lex_get ();
@@ -618,7 +624,7 @@ ssbox_create(struct ssbox *ssb, struct cmd_t_test *cmd, int mode)
        ssbox_paired_init(ssb,cmd);
        break;
       default:
-       assert(0);
+       NOT_REACHED ();
       }
 }
 
@@ -932,7 +938,7 @@ trbox_create(struct trbox *trb,
        trbox_paired_init(trb,cmd);
        break;
       default:
-       assert(0);
+        NOT_REACHED ();
       }
 }
 
@@ -1410,7 +1416,7 @@ common_calc (const struct ccase *c, void *_cmd)
   int i;
   struct cmd_t_test *cmd = (struct cmd_t_test *)_cmd;  
 
-  double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
+  double weight = dict_get_case_weight (default_dict, c, &bad_weight_warn);
 
 
   /* Skip the entire case if /MISSING=LISTWISE is set */
@@ -1510,7 +1516,7 @@ one_sample_calc (const struct ccase *c, void *cmd_)
   struct cmd_t_test *cmd = (struct cmd_t_test *)cmd_;
 
 
-  double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
+  double weight = dict_get_case_weight (default_dict, c, &bad_weight_warn);
 
   /* Skip the entire case if /MISSING=LISTWISE is set */
   if ( cmd->miss == TTS_LISTWISE ) 
@@ -1600,7 +1606,7 @@ paired_calc (const struct ccase *c, void *cmd_)
 
   struct cmd_t_test *cmd  = (struct cmd_t_test *) cmd_;
 
-  double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
+  double weight = dict_get_case_weight (default_dict, c, &bad_weight_warn);
 
   /* Skip the entire case if /MISSING=LISTWISE is set , 
    AND one member of a pair is missing */
@@ -1745,7 +1751,8 @@ group_calc (const struct ccase *c, struct cmd_t_test *cmd)
 
   const union value *gv = case_data (c, indep_var->fv);
 
-  const double weight = dict_get_case_weight(default_dict,c,&bad_weight_warn);
+  const double weight = 
+    dict_get_case_weight (default_dict, c, &bad_weight_warn);
 
   if ( value_is_missing(&indep_var->miss, gv) )
     {
@@ -1832,7 +1839,7 @@ group_postcalc ( struct cmd_t_test *cmd )
 
 
 static bool
-calculate(const struct casefile *cf, void *cmd_)
+calculate(const struct ccase *first, const struct casefile *cf, void *cmd_)
 {
   struct ssbox stat_summary_box;
   struct trbox test_results_box;
@@ -1842,6 +1849,7 @@ calculate(const struct casefile *cf, void *cmd_)
 
   struct cmd_t_test *cmd = (struct cmd_t_test *) cmd_;
 
+  output_split_file_values (first);
   common_precalc(cmd);
   for(r = casefile_get_reader (cf);
       casereader_read (r, &c) ;
@@ -1964,7 +1972,7 @@ hash_group_binary(const struct group_statistics *g,
       flag = which_group(g,p);
     }
   else
-    assert(0);
+    NOT_REACHED ();
 
   return flag;
 }