Change how checking for missing values works.
[pspp] / src / language / stats / means.c
index 0a3b413df721e7c8ef1f6114a358d1dcc523c885..4ebd60d83ab496239d21ef1a556e44ebeefd75c4 100644 (file)
@@ -868,7 +868,7 @@ control_var_missing (const struct means *means,
       const struct variable *var = layer->factor_vars[ws->control_idx[l]];
       const union value *vv = case_data (c, var);
 
-      miss = var_is_value_missing (var, vv, means->ctrl_exclude);
+      miss = (var_is_value_missing (var, vv) & means->ctrl_exclude) != 0;
       if (miss)
        break;
     }
@@ -930,7 +930,7 @@ service_cell_map (const struct means *means, const struct mtable *mt,
             {
               const struct variable *dep_var = mt->dep_vars[v];
              const union value *vv = case_data (c, dep_var);
-             if (var_is_value_missing (dep_var, vv, means->dep_exclude))
+             if (var_is_value_missing (dep_var, vv) & means->dep_exclude)
                continue;
 
               for (int stat = 0; stat < means->n_statistics; ++stat)
@@ -970,10 +970,8 @@ prepare_means (struct means *cmd)
         {
           struct workspace *ws = mt->ws + i;
          ws->root_cell = NULL;
-          ws->control_idx = xzalloc (mt->n_layers
-                                        * sizeof *ws->control_idx);
-          ws->instances = xzalloc (mt->n_layers
-                                        * sizeof *ws->instances);
+          ws->control_idx = xcalloc (mt->n_layers, sizeof *ws->control_idx);
+          ws->instances = xcalloc (mt->n_layers, sizeof *ws->instances);
           int cmb = i;
           for (int l = mt->n_layers - 1; l >= 0; --l)
             {
@@ -1049,7 +1047,7 @@ update_summaries (const struct means *means, struct mtable *mt,
          const struct variable *var = mt->dep_vars[dv];
          const union value *vv = case_data (c, var);
          /* First check if the dependent variable is missing.  */
-         if (var_is_value_missing (var, vv, means->dep_exclude))
+         if (var_is_value_missing (var, vv) & means->dep_exclude)
            summ->n_missing += weight;
          /* If the dep var is not missing, then check each
             control variable.  */
@@ -1060,7 +1058,7 @@ update_summaries (const struct means *means, struct mtable *mt,
                const struct variable *var
                  = layer->factor_vars[ws->control_idx[l]];
                const union value *vv = case_data (c, var);
-               if (var_is_value_missing (var, vv, means->ctrl_exclude))
+               if (var_is_value_missing (var, vv) & means->ctrl_exclude)
                  {
                    summ->n_missing += weight;
                    break;
@@ -1149,9 +1147,9 @@ cmd_means (struct lexer *lexer, struct dataset *ds)
        for (int t = 0; t < means.n_tables; ++t)
        {
          struct mtable *mt = means.table + t;
-         mt->summ = xzalloc (mt->n_combinations * mt->n_dep_vars
-                             sizeof (*mt->summ));
-         mt->ws = xzalloc (mt->n_combinations * sizeof (*mt->ws));
+         mt->summ = xcalloc (mt->n_combinations * mt->n_dep_vars,
+                             sizeof (*mt->summ));
+         mt->ws = xcalloc (mt->n_combinations, sizeof (*mt->ws));
        }
        run_means (&means, group, ds);
        for (int t = 0; t < means.n_tables; ++t)