Merge commit 'origin/stable'
authorJohn Darrington <john@darrington.wattle.id.au>
Thu, 23 Jul 2009 06:15:20 +0000 (08:15 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Thu, 23 Jul 2009 06:15:20 +0000 (08:15 +0200)
Conflicts:

src/language/stats/t-test.q

src/data/por-file-reader.c
src/data/sys-file-reader.c
src/language/data-io/data-parser.c
src/language/stats/t-test.q
tests/automake.mk
tests/bugs/t-test-paired.sh [new file with mode: 0755]
tests/command/data-list.sh

index cd8b213e8d74062bffd5b6e344a1d29047b7f9a9..a463124274a20c6cd62e1071f15c51cd95edcb3a 100644 (file)
@@ -882,17 +882,30 @@ pfm_detect (FILE *file)
 {
   unsigned char header[464];
   char trans[256];
-  int cooked_cnt, raw_cnt;
+  int cooked_cnt, raw_cnt, line_len;
   int i;
 
   cooked_cnt = raw_cnt = 0;
+  line_len = 0;
   while (cooked_cnt < sizeof header)
     {
       int c = getc (file);
       if (c == EOF || raw_cnt++ > 512)
         return false;
-      else if (c != '\n' && c != '\r')
-        header[cooked_cnt++] = c;
+      else if (c == '\n')
+        {
+          while (line_len < 80 && cooked_cnt < sizeof header)
+            {
+              header[cooked_cnt++] = ' ';
+              line_len++;
+            }
+          line_len = 0;
+        }
+      else if (c != '\r')
+        {
+          header[cooked_cnt++] = c;
+          line_len++;
+        }
     }
 
   memset (trans, 0, 256);
index 9978d43a4e58d993649935a9d2580ce1cf4faa2b..b0a41a83573b0e986fb35bfb3bce46379282662f 100644 (file)
@@ -505,9 +505,21 @@ read_header (struct sfm_reader *r, struct dictionary *dict,
   read_bytes (r, raw_bias, sizeof raw_bias);
   if (float_identify (100.0, raw_bias, sizeof raw_bias, &r->float_format) == 0)
     {
-      sys_warn (r, _("Compression bias is not the usual "
-                     "value of 100, or system file uses unrecognized "
-                     "floating-point format."));
+      uint8_t zero_bias[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+
+      if (memcmp (raw_bias, zero_bias, 8))
+        sys_warn (r, _("Compression bias is not the usual "
+                       "value of 100, or system file uses unrecognized "
+                       "floating-point format."));
+      else
+        {
+          /* Some software is known to write all-zeros to this
+             field.  Such software also writes floating-point
+             numbers in the format that we expect by default
+             (it seems that all software most likely does, in
+             reality), so don't warn in this case. */
+        }
+
       if (r->integer_format == INTEGER_MSB_FIRST)
         r->float_format = FLOAT_IEEE_DOUBLE_BE;
       else
index 6ec3d0d50bc94e258d44306d25d1157483f73c70..020f8e4c7e5a20a0caabc4add9f228f98937d1b6 100644 (file)
@@ -485,7 +485,8 @@ cut_field (const struct data_parser *parser, struct dfm_reader *reader,
       /* Regular field. */
       ss_get_chars (&p, ss_cspan (p, ds_ss (&parser->any_sep)), field);
       *last_column = dfm_column_start (reader);
-      if (!ss_ltrim (&p, parser->soft_seps) || ss_is_empty (p))
+      if (!ss_ltrim (&p, parser->soft_seps) || ss_is_empty (p)
+          || ss_find_char (parser->hard_seps, p.string[0]) != SIZE_MAX)
         {
           /* Advance past a trailing hard separator,
              regardless of whether one actually existed.  If
index 09a96cfc194930b3cc063c77056622c91455237b..d02cdb28d21597a087f51640762de88573c33a3b 100644 (file)
@@ -974,8 +974,8 @@ trbox_paired_populate (struct trbox *trb,
       /* Degrees of freedom */
       tab_double (trb->t, 8, i + 3, TAB_RIGHT, df, &proc->weight_format);
 
-      p = gsl_cdf_tdist_P (t, df);
-      q = gsl_cdf_tdist_P (t, df);
+      p = gsl_cdf_tdist_P (t,df);
+      q = gsl_cdf_tdist_Q (t,df);
 
       tab_double (trb->t, 9, i + 3, TAB_RIGHT, 2.0 * (t > 0 ? q : p), NULL);
     }
index aba1a62c1170580a185b5f6ca2b39042e48a1ef1..15e297a0150209c1586636de126a7a92a5d8defe 100644 (file)
@@ -143,6 +143,7 @@ dist_TESTS = \
        tests/bugs/t-test-alpha.sh \
        tests/bugs/t-test-alpha2.sh \
        tests/bugs/t-test-alpha3.sh \
+       tests/bugs/t-test-paired.sh \
        tests/bugs/temporary.sh \
        tests/bugs/unwritable-dir.sh \
        tests/bugs/val-labs.sh \
diff --git a/tests/bugs/t-test-paired.sh b/tests/bugs/t-test-paired.sh
new file mode 100755 (executable)
index 0000000..f722f61
--- /dev/null
@@ -0,0 +1,117 @@
+#!/bin/sh
+
+# This program tests for a bug in the paired samples T test.
+# Thanks to Mike Griffiths for reporting this problem.
+
+TEMPDIR=/tmp/pspp-tst-$$
+TESTFILE=$TEMPDIR/`basename $0`.sps
+
+# ensure that top_srcdir and top_builddir  are absolute
+if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi
+if [ -z "$top_builddir" ] ; then top_builddir=. ; fi
+top_srcdir=`cd $top_srcdir; pwd`
+top_builddir=`cd $top_builddir; pwd`
+
+PSPP=$top_builddir/src/ui/terminal/pspp
+
+STAT_CONFIG_PATH=$top_srcdir/config
+export STAT_CONFIG_PATH
+
+LANG=C
+export LANG
+
+
+cleanup()
+{
+     if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then 
+       echo "NOT cleaning $TEMPDIR"
+       return ; 
+     fi
+     rm -rf $TEMPDIR
+}
+
+
+fail()
+{
+    echo $activity
+    echo FAILED
+    cleanup;
+    exit 1;
+}
+
+
+no_result()
+{
+    echo $activity
+    echo NO RESULT;
+    cleanup;
+    exit 2;
+}
+
+pass()
+{
+    cleanup;
+    exit 0;
+}
+
+mkdir -p $TEMPDIR
+
+cd $TEMPDIR
+
+cat >> $TESTFILE <<EOF
+set format f8.3.
+data list list /A * B *.
+begin data.
+11 2
+1  1
+1  1
+end data.
+
+t-test pairs = a with b (paired).
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="run program"
+$SUPERVISOR $PSPP --testing-mode -o raw-ascii $TESTFILE
+if [ $? -ne 0 ] ; then no_result ; fi
+
+
+activity="compare output"
+perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list
+diff  -b  $TEMPDIR/pspp.list - << EOF
+1.1 DATA LIST.  Reading free-form data from INLINE.
++--------+------+
+|Variable|Format|
+#========#======#
+|A       |F8.0  |
+|B       |F8.0  |
++--------+------+
+2.1 T-TEST.  Paired Sample Statistics
+#========#=====#=#==============#========#
+#        # Mean|N|Std. Deviation|SE. Mean#
+#========#=====#=#==============#========#
+#Pair 0 A#4.333|3|         5.774|   3.333#
+#       B#1.333|3|          .577|    .333#
+#========#=====#=#==============#========#
+2.2 T-TEST.  Paired Samples Correlations
+#======#=====#=#===========#====#
+#      |     #N|Correlation|Sig.#
+#======#=====#=#===========#====#
+#Pair 0|A & B#3|      1.000|.000#
+#======#=====#=#===========#====#
+2.3 T-TEST.  Paired Samples Test
+#===========#==================================================#=====#==#===============#
+#           #                Paired Differences                |     |  |               #
+#           #-----+--------------+---------------+-------------+     |  |               #
+#           #     |              |               |     95%     |     |  |               #
+#           #     |              |               +------+------+     |  |               #
+#           # Mean|Std. Deviation|Std. Error Mean| Lower| Upper|  t  |df|Sig. (2-tailed)#
+#===========#=====#==============#===============#======#======#=====#==#===============#
+#Pair 0A - B#3.000|         5.196|          3.000|-9.908|15.908|1.000| 2|           .423#
+#===========#=====#==============#===============#======#======#=====#==#===============#
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+
+pass;
index 7d3890c3430bf5fe34c22467cfcc9338bf4ff6f7..3f821199ff3e2d10f22627e6ce35c93ec7b1f157 100755 (executable)
@@ -76,7 +76,7 @@ begin data.
 6
 7,
 8 9
-0,1,,,
+0,1 ,,,
 ,,,,
 2