Changed a lot of non-const pointers to const.
[pspp] / src / language / stats / examine.q
index 9a55c9f3e5915787f5d28a4e45542ddfe9205870..b040e19bc7fd84f41af7fb9a78033f50bdc81941 100644 (file)
@@ -1,7 +1,6 @@
 /* PSPP - EXAMINE data for normality . -*-c-*-
 
 Copyright (C) 2004 Free Software Foundation, Inc.
-Author: John Darrington 2004, 2006
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License as
@@ -85,7 +84,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
 static struct cmd_examine cmd;
 
-static struct variable **dependent_vars;
+static const struct variable **dependent_vars;
 
 static size_t n_dependent_vars;
 
@@ -117,19 +116,19 @@ static int examine_parse_independent_vars (struct lexer *lexer, const struct dic
 
 
 /* Output functions */
-static void show_summary (struct variable **dependent_var, int n_dep_var,
+static void show_summary (const struct variable **dependent_var, int n_dep_var,
                         const struct factor *f);
 
-static void show_extremes (struct variable **dependent_var,
+static void show_extremes (const struct variable **dependent_var,
                          int n_dep_var,
                          const struct factor *factor,
                          int n_extremities);
 
-static void show_descriptives (struct variable **dependent_var,
+static void show_descriptives (const struct variable **dependent_var,
                              int n_dep_var,
                              struct factor *factor);
 
-static void show_percentiles (struct variable **dependent_var,
+static void show_percentiles (const struct variable **dependent_var,
                             int n_dep_var,
                             struct factor *factor);
 
@@ -179,9 +178,8 @@ const char *factor_to_string_concise (const struct factor *fctr,
 
 
 
-/* Function to use for testing for missing values */
-static var_is_missing_func *value_is_missing;
-
+/* Categories of missing values to exclude. */
+static enum mv_class exclude_values;
 
 /* PERCENTILES */
 
@@ -207,10 +205,7 @@ cmd_examine (struct lexer *lexer, struct dataset *ds)
     }
 
   /* If /MISSING=INCLUDE is set, then user missing values are ignored */
-  if (cmd.incl == XMN_INCLUDE )
-    value_is_missing = var_is_value_system_missing;
-  else
-    value_is_missing = var_is_value_missing;
+  exclude_values = cmd.incl == XMN_INCLUDE ? MV_SYSTEM : MV_ANY;
 
   if ( cmd.st_n == SYSMIS )
     cmd.st_n = 5;
@@ -530,7 +525,7 @@ xmn_custom_variables (struct lexer *lexer, struct dataset *ds, struct cmd_examin
       return 2;
     }
 
-  if (!parse_variables (lexer, dict, &dependent_vars, &n_dependent_vars,
+  if (!parse_variables_const (lexer, dict, &dependent_vars, &n_dependent_vars,
                        PV_NO_DUPLICATE | PV_NUMERIC | PV_NO_SCRATCH) )
     {
       free (dependent_vars);
@@ -696,7 +691,7 @@ factor_calc (const struct ccase *c, int case_no, double weight,
                                        var_get_width (var)
                                        );
 
-         if ( value_is_missing (var, val) || case_missing )
+         if (case_missing || var_is_value_missing (var, val, exclude_values))
            {
              free (val);
              continue;
@@ -763,7 +758,7 @@ run_examine (const struct ccase *first, const struct casefile *cf,
                                                  var_get_width (var)
                                                  );
 
-             if ( value_is_missing (var, val))
+             if ( var_is_value_missing (var, val, exclude_values))
                case_missing = 1;
 
              free (val);
@@ -778,7 +773,8 @@ run_examine (const struct ccase *first, const struct casefile *cf,
                                        var_get_width (var)
                                        );
 
-         if ( value_is_missing (var, val) || case_missing )
+         if ( var_is_value_missing (var, val, exclude_values)
+               || case_missing )
            {
              free (val) ;
              continue ;
@@ -903,7 +899,7 @@ run_examine (const struct ccase *first, const struct casefile *cf,
 
 
 static void
-show_summary (struct variable **dependent_var, int n_dep_var,
+show_summary (const struct variable **dependent_var, int n_dep_var,
             const struct factor *fctr)
 {
   static const char *subtitle[]=
@@ -1128,7 +1124,7 @@ populate_summary (struct tab_table *t, int col, int row,
 
 
 static void
-show_extremes (struct variable **dependent_var, int n_dep_var,
+show_extremes (const struct variable **dependent_var, int n_dep_var,
              const struct factor *fctr, int n_extremities)
 {
   int i;
@@ -1365,7 +1361,7 @@ populate_extremes (struct tab_table *t,
 
 /* Show the descriptives table */
 void
-show_descriptives (struct variable **dependent_var,
+show_descriptives (const struct variable **dependent_var,
                  int n_dep_var,
                  struct factor *fctr)
 {
@@ -1951,7 +1947,7 @@ np_plot (const struct metrics *m, const char *factorname)
 
 /* Show the percentiles */
 void
-show_percentiles (struct variable **dependent_var,
+show_percentiles (const struct variable **dependent_var,
                 int n_dep_var,
                 struct factor *fctr)
 {