Fixed bug parsing binomial test.
[pspp-builds.git] / src / language / stats / npar.q
index c8c44e6d4e825b2c96eef9f1689fa9651691e08f..535797227b2a23974e6a13da5ed265b0a8c419b2 100644 (file)
@@ -16,6 +16,7 @@
 
 #include <config.h>
 
+
 #include <language/stats/npar.h>
 
 #include <math.h>
@@ -32,6 +33,7 @@
 #include <language/stats/chisquare.h>
 #include <language/stats/wilcoxon.h>
 #include <language/stats/sign.h>
+#include <libpspp/cast.h>
 #include <libpspp/hash.h>
 #include <libpspp/pool.h>
 #include <libpspp/taint.h>
@@ -132,6 +134,7 @@ npar_execute(struct casereader *input,
   casereader_destroy (input);
 }
 
+
 int
 cmd_npar_tests (struct lexer *lexer, struct dataset *ds)
 {
@@ -337,7 +340,9 @@ npar_custom_binomial (struct lexer *lexer, struct dataset *ds,
 
   btp->category1 = btp->category2 = btp->cutpoint = SYSMIS;
 
-  if ( lex_match(lexer, '(') )
+  btp->p = 0.5;
+
+  if ( lex_match (lexer, '(') )
     {
       if ( lex_force_num (lexer) )
        {
@@ -348,6 +353,10 @@ npar_custom_binomial (struct lexer *lexer, struct dataset *ds,
       else
        return 0;
     }
+  else
+    /* Kludge: q2c swallows the '=' so put it back here  */
+     lex_put_back (lexer, '=');
+
 
   if ( lex_match (lexer, '=') )
     {
@@ -376,6 +385,7 @@ npar_custom_binomial (struct lexer *lexer, struct dataset *ds,
        }
       else
        return 2;
+
     }
 
   specs->n_tests++;
@@ -585,7 +595,7 @@ one_sample_insert_variables (const struct npar_test *test,
                             struct const_hsh_table *var_hash)
 {
   int i;
-  struct one_sample_test *ost = (struct one_sample_test *) test;
+  struct one_sample_test *ost = UP_CAST (test, struct one_sample_test, parent);
 
   for ( i = 0 ; i < ost->n_vars ; ++i )
     const_hsh_insert (var_hash, ost->vars[i]);