Fix PR 11492.
authorBen Pfaff <blp@gnu.org>
Sat, 12 Mar 2005 21:19:53 +0000 (21:19 +0000)
committerBen Pfaff <blp@gnu.org>
Sat, 12 Mar 2005 21:19:53 +0000 (21:19 +0000)
src/ChangeLog
src/vfm.c
tests/ChangeLog
tests/Makefile.am
tests/bugs/temp-freq.sh [new file with mode: 0755]

index 0fceb2827dcd4aac705d818291288b71959b42e4..6073c81b355d1d35a4eaf681ec993612a4e89f1e 100644 (file)
@@ -1,3 +1,8 @@
+Sat Mar 12 13:17:12 2005  Ben Pfaff  <blp@gnu.org>
+
+       * vfm.c: (procedure_with_splits) Fix PR 11492: end_func() must be
+       called *before* close_active_file().
+
 Sat Mar 12 12:20:57 2005  Ben Pfaff  <blp@gnu.org>
 
        * file-handle.q: (struct file_handle) Change open_mode from
index 796e3bcff07eda9daac4101bb5793d8721d2dd8f..8e939277d3144c86b4badca0e463f5ebe18235ea 100644 (file)
--- a/src/vfm.c
+++ b/src/vfm.c
@@ -783,10 +783,12 @@ procedure_with_splits (void (*begin_func) (void *aux),
   split_aux.end_func = end_func;
   split_aux.func_aux = func_aux;
 
-  procedure (procedure_with_splits_callback, &split_aux);
-
+  open_active_file ();
+  internal_procedure (procedure_with_splits_callback, &split_aux);
   if (split_aux.case_count > 0 && end_func != NULL)
     end_func (func_aux);
+  close_active_file ();
+
   case_destroy (&split_aux.prev_case);
 }
 
index 3a9a93da8e4b111fa1efbd57899d715394dfac3f..26fdf957017f17ad7faa92d834a74dfbef9752e0 100644 (file)
@@ -1,3 +1,7 @@
+Sat Mar 12 13:16:34 2005  Ben Pfaff  <blp@gnu.org>
+
+       * bugs/temp-freq.sh: Add another test.
+
 Fri Mar 11 10:40:41 2005  Ben Pfaff  <blp@gnu.org>
 
        * expressions/expressions.sh: Add another test.
index 62b806090d5dfdc31a442df9d148971e00a97d3d..d018e19ed584e6f414d52908283679ea05e2cee4 100644 (file)
@@ -70,6 +70,7 @@ TESTS = \
        bugs/val-labs-trailing-slash.sh \
        bugs/recode-copy-bug.sh \
        bugs/computebug.sh \
+       bugs/temp-freq.sh \
        xforms/casefile.sh \
        stats/descript-basic.sh \
        stats/descript-missing.sh \
diff --git a/tests/bugs/temp-freq.sh b/tests/bugs/temp-freq.sh
new file mode 100755 (executable)
index 0000000..d2c1061
--- /dev/null
@@ -0,0 +1,110 @@
+#!/bin/sh
+
+# This program tests for a bug which caused FREQUENCIES following
+# TEMPORARY to crash (PR 11492).
+
+TEMPDIR=/tmp/pspp-tst-$$
+TESTFILE=$TEMPDIR/`basename $0`.sps
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+export STAT_CONFIG_PATH=$top_srcdir/config
+
+
+cleanup()
+{
+     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
+
+activity="create program"
+cat > $TESTFILE <<EOF
+DATA LIST LIST /SEX (A1) X *.
+BEGIN DATA.
+M 31
+F 21
+M 41
+F 31
+M 13
+F 12
+M 14
+F 13
+END DATA.
+
+
+TEMPORARY
+SELECT IF SEX EQ 'F'
+FREQUENCIES /X .
+
+FINISH
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+$SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE
+if [ $? -ne 0 ] ; then no_result ; fi
+
+diff -b -B -w $TEMPDIR/pspp.list - << EOF
+1.1 DATA LIST.  Reading free-form data from the command file.
++--------+------+
+|Variable|Format|
+#========#======#
+|SEX     |A1    |
+|X       |F8.0  |
++--------+------+
+
+2.1 FREQUENCIES.  X: 
++-----------+--------+---------+--------+--------+--------+
+|           |        |         |        |  Valid |   Cum  |
+|Value Label|  Value |Frequency| Percent| Percent| Percent|
+#===========#========#=========#========#========#========#
+|           |   12.00|        1|    25.0|    25.0|    25.0|
+|           |   13.00|        1|    25.0|    25.0|    50.0|
+|           |   21.00|        1|    25.0|    25.0|    75.0|
+|           |   31.00|        1|    25.0|    25.0|   100.0|
+#===========#========#=========#========#========#========#
+|               Total|        4|   100.0|   100.0|        |
++--------------------+---------+--------+--------+--------+
+
++---------------+------+
+|N       Valid  |     4|
+|        Missing|     0|
+|Mean           |19.250|
+|Std Dev        | 8.808|
+|Minimum        |12.000|
+|Maximum        |31.000|
++---------------+------+
+
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+pass;