INPUT PROGRAM: Avoid infinite loop for trivially empty input program.
[pspp] / src / language / stats / npar.c
index 8d40faad0144bd9c327ee8a39c0784d5a5da0279..fbcdeae058e1dd1c47abc8cdcab01c905496598b 100644 (file)
@@ -155,22 +155,26 @@ static int
 parse_npar_tests (struct lexer *lexer, struct dataset *ds, struct cmd_npar_tests *npt,
                  struct npar_specs *nps)
 {
-  npt->binomial = 0;
   npt->chisquare = 0;
-  npt->ks_one_sample = 0;
   npt->cochran = 0;
+  npt->binomial = 0;
+  npt->ks_one_sample = 0;
+  npt->wilcoxon = 0;
+  npt->sign = 0;
+  npt->runs = 0;
   npt->friedman = 0;
+  npt->kendall = 0;
   npt->kruskal_wallis = 0;
   npt->mann_whitney = 0;
-  npt->jonckheere_terpstra = 0;
   npt->mcnemar = 0;
-  npt->runs = 0;
-  npt->sign = 0;
-  npt->wilcoxon = 0;
-  npt->missing = 0;
+  npt->median = 0;
+  npt->jonckheere_terpstra = 0;
+
   npt->miss = MISS_ANALYSIS;
+  npt->missing = 0;
   npt->method = 0;
   npt->statistics = 0;
+
   memset (npt->a_statistics, 0, sizeof npt->a_statistics);
   for (;;)
     {
@@ -826,11 +830,11 @@ npar_chisquare (struct lexer *lexer, struct dataset *ds,
     {
       cstp->ranged = true;
       if ( ! lex_force_num (lexer)) return 0;
-      cstp->lo = lex_integer (lexer);
+      cstp->lo = lex_number (lexer);
       lex_get (lexer);
       lex_force_match (lexer, T_COMMA);
       if (! lex_force_num (lexer) ) return 0;
-      cstp->hi = lex_integer (lexer);
+      cstp->hi = lex_number (lexer);
       if ( cstp->lo >= cstp->hi )
        {
          msg (ME,
@@ -941,7 +945,8 @@ npar_binomial (struct lexer *lexer, struct dataset *ds,
        {
          if (lex_match (lexer, T_LPAREN))
            {
-             lex_force_num (lexer);
+             if (! lex_force_num (lexer))
+               return 2;
              btp->category1 = lex_number (lexer);
              lex_get (lexer);
              if ( lex_match (lexer, T_COMMA))
@@ -1076,7 +1081,7 @@ parse_two_sample_related_test (struct lexer *lexer,
   if (!parse_variables_const_pool (lexer, pool,
                                   dict,
                                   &vlist1, &n_vlist1,
-                                  PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE) )
+                                  PV_NUMERIC | PV_NO_SCRATCH | PV_DUPLICATE) )
     return false;
 
   if ( lex_match (lexer, T_WITH))
@@ -1084,7 +1089,7 @@ parse_two_sample_related_test (struct lexer *lexer,
       with = true;
       if ( !parse_variables_const_pool (lexer, pool, dict,
                                        &vlist2, &n_vlist2,
-                                       PV_NUMERIC | PV_NO_SCRATCH | PV_NO_DUPLICATE) )
+                                       PV_NUMERIC | PV_NO_SCRATCH | PV_DUPLICATE) )
        return false;
 
       paired = (lex_match (lexer, T_LPAREN) &&
@@ -1097,9 +1102,12 @@ parse_two_sample_related_test (struct lexer *lexer,
       if (paired)
        {
          if ( n_vlist1 != n_vlist2)
-           msg (SE, _("PAIRED was specified but the number of variables "
+            {
+             msg (SE, _("PAIRED was specified but the number of variables "
                       "preceding WITH (%zu) did not match the number "
                       "following (%zu)."), n_vlist1, n_vlist2);
+              return false;
+            }
 
          test_parameters->n_pairs = n_vlist1 ;
        }