More constness/namespace policing
[pspp-builds.git] / src / language / stats / crosstabs.q
index a2115cef8aaac660d337e03e05f5b5a1336cb7be..e7466d7239e50256b0627c64af16bf1d7f1e6831 100644 (file)
@@ -293,7 +293,7 @@ internal_cmd_crosstabs (void)
   else
     write = CRS_WR_NONE;
 
-  ok = procedure_with_splits (precalc,
+  ok = procedure_with_splits (current_dataset, precalc,
                               mode == GENERAL ? calc_general : calc_integer,
                               postcalc, NULL);
 
@@ -313,7 +313,7 @@ crs_custom_tables (struct cmd_crosstabs *cmd UNUSED, void *aux UNUSED)
 
   /* Ensure that this is a TABLES subcommand. */
   if (!lex_match_id ("TABLES")
-      && (token != T_ID || dict_lookup_var (default_dict, tokid) == NULL)
+      && (token != T_ID || dict_lookup_var (dataset_dict (current_dataset), tokid) == NULL)
       && token != T_ALL)
     return 2;
   lex_match ('=');
@@ -321,7 +321,7 @@ crs_custom_tables (struct cmd_crosstabs *cmd UNUSED, void *aux UNUSED)
   if (variables != NULL)
     var_set = var_set_create_from_array (variables, variables_cnt);
   else
-    var_set = var_set_create_from_dict (default_dict);
+    var_set = var_set_create_from_dict (dataset_dict (current_dataset));
   assert (var_set != NULL);
   
   for (n_by = 0; ;)
@@ -423,7 +423,7 @@ crs_custom_variables (struct cmd_crosstabs *cmd UNUSED, void *aux UNUSED)
 
       long min, max;
       
-      if (!parse_variables (default_dict, &variables, &variables_cnt,
+      if (!parse_variables (dataset_dict (current_dataset), &variables, &variables_cnt,
                            (PV_APPEND | PV_NUMERIC
                             | PV_NO_DUPLICATE | PV_NO_SCRATCH)))
        return 0;
@@ -487,7 +487,7 @@ static int compare_table_entry (const void *, const void *, void *);
 static unsigned hash_table_entry (const void *, void *);
 
 /* Set up the crosstabulation tables for processing. */
-static void
+static  void
 precalc (const struct ccase *first, void *aux UNUSED)
 {
   output_split_file_values (first);
@@ -558,16 +558,17 @@ precalc (const struct ccase *first, void *aux UNUSED)
                               n_sorted_tab + 1, sizeof *sorted_tab);
       sorted_tab[n_sorted_tab] = NULL;
     }
+
 }
 
 /* Form crosstabulations for general mode. */
 static bool
 calc_general (const struct ccase *c, void *aux UNUSED)
 {
-  int bad_warn = 1;
+  bool bad_warn = true;
 
   /* Case weight. */
-  double weight = dict_get_case_weight (default_dict, c, &bad_warn);
+  double weight = dict_get_case_weight (dataset_dict (current_dataset), c, &bad_warn);
 
   /* Flattened current table index. */
   int t;
@@ -638,10 +639,10 @@ calc_general (const struct ccase *c, void *aux UNUSED)
 static bool
 calc_integer (const struct ccase *c, void *aux UNUSED)
 {
-  int bad_warn = 1;
+  bool bad_warn = true;
 
   /* Case weight. */
-  double weight = dict_get_case_weight (default_dict, c, &bad_warn);
+  double weight = dict_get_case_weight (dataset_dict (current_dataset), c, &bad_warn);
   
   /* Flattened current table index. */
   int t;
@@ -949,7 +950,7 @@ static int n_rows;
 static int ns_cols, ns_rows;
 
 /* Crosstabulation. */
-static struct crosstab *x;
+static const struct crosstab *x;
 
 /* Number of variables from the crosstabulation to consider.  This is
    either x->nvar, if pivoting is on, or 2, if pivoting is off. */
@@ -1702,11 +1703,11 @@ display_dimensions (struct tab_table *table, int first_difference, struct table_
 }
 
 /* Put VALUE into cell (C,R) of TABLE, suffixed with character
-   SUFFIX if nonzero.  If MARK_MISSING is nonzero the entry is
+   SUFFIX if nonzero.  If MARK_MISSING is true the entry is
    additionally suffixed with a letter `M'. */
 static void
 format_cell_entry (struct tab_table *table, int c, int r, double value,
-                   char suffix, int mark_missing)
+                   char suffix, bool mark_missing)
 {
   const struct fmt_spec f = {FMT_F, 10, 1};
   union value v;
@@ -1755,13 +1756,13 @@ display_crosstabulation (void)
          tab_hline (table, TAL_1, -1, n_cols, 0);
        for (c = 0; c < n_cols; c++)
          {
-            int mark_missing = 0;
+            bool mark_missing = false;
             double expected_value = row_tot[r] * col_tot[c] / W;
             if (cmd.miss == CRS_REPORT
                 && (mv_is_num_user_missing (&x->vars[COL_VAR]->miss, cols[c].f)
                     || mv_is_num_user_missing (&x->vars[ROW_VAR]->miss,
                                                rows[r].f)))
-              mark_missing = 1;
+              mark_missing = true;
            for (i = 0; i < num_cells; i++)
              {
                double v;
@@ -1821,11 +1822,11 @@ display_crosstabulation (void)
     for (r = 0; r < n_rows; r++) 
       {
         char suffix = 0;
-        int mark_missing = 0;
+        bool mark_missing = false;
 
         if (cmd.miss == CRS_REPORT
             && mv_is_num_user_missing (&x->vars[ROW_VAR]->miss, rows[r].f))
-          mark_missing = 1;
+          mark_missing = true;
 
         for (i = 0; i < num_cells; i++)
           {
@@ -1874,13 +1875,13 @@ display_crosstabulation (void)
     for (c = 0; c <= n_cols; c++)
       {
        double ct = c < n_cols ? col_tot[c] : W;
-        int mark_missing = 0;
+        bool mark_missing = false;
         char suffix = 0;
         int i;
            
         if (cmd.miss == CRS_REPORT && c < n_cols 
             && mv_is_num_user_missing (&x->vars[COL_VAR]->miss, cols[c].f))
-          mark_missing = 1;
+          mark_missing = true;
 
         for (i = 0; i < num_cells; i++)
          {