CORRELATIONS: Improve error messages and coding style.
[pspp] / src / language / stats / examine.c
index bb77e9010a3564dfa0982ac129558b1606607db9..6ad5e67e4ba83b75c143cca5b209fb20a9ae1eb5 100644 (file)
@@ -71,7 +71,7 @@ static void
 append_value_name (const struct variable *var, const union value *val, struct string *str)
 {
   var_append_value_name (var, val, str);
-  if (var_is_value_missing (var, val, MV_ANY))
+  if (var_is_value_missing (var, val))
     ds_put_cstr (str, _(" (missing)"));
 }
 
@@ -551,7 +551,7 @@ new_value_with_missing_footnote (const struct variable *var,
                                  struct pivot_footnote *missing_footnote)
 {
   struct pivot_value *pv = pivot_value_new_var_value (var, value);
-  if (var_is_value_missing (var, value, MV_USER))
+  if (var_is_value_missing (var, value) == MV_USER)
     pivot_value_add_footnote (pv, missing_footnote);
   return pv;
 }
@@ -1033,7 +1033,7 @@ create_n (const void *aux1, void *aux2 UNUSED)
       es[v].minimum =  DBL_MAX;
     }
 
-  subcase_destroy (&ordering);
+  subcase_uninit (&ordering);
   return es;
 }
 
@@ -1053,7 +1053,8 @@ update_n (const void *aux1, void *aux2 UNUSED, void *user_data,
        {
          const struct variable *var = examine->dep_vars[v];
 
-         if (var_is_value_missing (var, case_data (c, var), examine->dep_excl))
+         if (var_is_value_missing (var, case_data (c, var))
+              & examine->dep_excl)
            {
              es[v].missing += weight;
              this_case_is_missing = true;
@@ -1070,7 +1071,7 @@ update_n (const void *aux1, void *aux2 UNUSED, void *user_data,
       const struct variable *var = examine->dep_vars[v];
       const double x = case_num (c, var);
 
-      if (var_is_value_missing (var, case_data (c, var), examine->dep_excl))
+      if (var_is_value_missing (var, case_data (c, var)) & examine->dep_excl)
         {
           es[v].missing += weight;
           continue;
@@ -1514,7 +1515,7 @@ cmd_examine (struct lexer *lexer, struct dataset *ds)
       while (iact);
     }
 
-
+  int nototals_ofs = 0;
   while (lex_token (lexer) != T_ENDCMD)
     {
       lex_match (lexer, T_SLASH);
@@ -1567,15 +1568,10 @@ cmd_examine (struct lexer *lexer, struct dataset *ds)
             {
               while (lex_is_number (lexer))
                 {
+                  if (!lex_force_num_range_open (lexer, "PERCENTILES", 0, 100))
+                    goto error;
                   double p = lex_number (lexer);
 
-                  if (p <= 0 || p >= 100.0)
-                    {
-                      lex_error (lexer,
-                                 _("Percentiles must lie in the range (0, 100)"));
-                      goto error;
-                    }
-
                   examine.n_percentiles++;
                   examine.ptiles =
                     xrealloc (examine.ptiles,
@@ -1634,6 +1630,7 @@ cmd_examine (struct lexer *lexer, struct dataset *ds)
       else if (lex_match_id (lexer, "NOTOTAL"))
         {
           nototals_seen = true;
+          nototals_ofs = lex_ofs (lexer) - 1;
         }
       else if (lex_match_id (lexer, "MISSING"))
         {
@@ -1660,7 +1657,7 @@ cmd_examine (struct lexer *lexer, struct dataset *ds)
                 }
               else if (lex_match_id (lexer, "REPORT"))
                 {
-                  examine.fctr_excl = MV_NEVER;
+                  examine.fctr_excl = 0;
                 }
               else if (lex_match_id (lexer, "NOREPORT"))
                 {
@@ -1762,7 +1759,9 @@ cmd_examine (struct lexer *lexer, struct dataset *ds)
 
   if (totals_seen && nototals_seen)
     {
-      msg (SE, _("%s and %s are mutually exclusive"), "TOTAL", "NOTOTAL");
+      lex_ofs_error (lexer, nototals_ofs, nototals_ofs,
+                     _("%s and %s are mutually exclusive."),
+                     "TOTAL", "NOTOTAL");
       goto error;
     }