Fixed bug #14822.
authorJohn Darrington <john@darrington.wattle.id.au>
Mon, 24 Oct 2005 01:02:34 +0000 (01:02 +0000)
committerJohn Darrington <john@darrington.wattle.id.au>
Mon, 24 Oct 2005 01:02:34 +0000 (01:02 +0000)
src/plot-hist.c
tests/Makefile.am
tests/bugs/examine-missing.sh [new file with mode: 0755]

index 15578879e1eba6fe9679225e15cd67565e53c23e..fd1a88d8a69cfbb325723522707eaf8471ff565c 100644 (file)
@@ -41,7 +41,7 @@ histogram_write_legend(struct chart *ch, const struct normal_curve *norm)
 {
   char buf[100];
   if ( !ch )
-         return ;
+    return ;
 
   pl_savestate_r(ch->lp);
 
@@ -121,14 +121,22 @@ histogram_plot(const gsl_histogram *hist,
   
   struct chart *ch;
 
-  bins = gsl_histogram_bins(hist);
-
   ch = chart_create();
   chart_write_title(ch, _("HISTOGRAM"));
 
   chart_write_ylabel(ch, _("Frequency"));
   chart_write_xlabel(ch, factorname);
 
+  if ( ! hist ) /* If this happens, probably all values are SYSMIS */
+    {
+      chart_submit(ch);
+      return ;
+    }
+  else
+    {
+      bins = gsl_histogram_bins(hist);
+    }
+
   chart_write_yscale(ch, 0, gsl_histogram_max_val(hist), 5);
 
   for ( i = 0 ; i < bins ; ++i ) 
index 21b70ddab6bdfd1b6d80b20c9c857cc7c8060f84..a80f9cd975b73031506d946c432173049d22e368 100644 (file)
@@ -64,6 +64,7 @@ TESTS = \
        bugs/double-frequency.sh \
        bugs/get.sh \
        bugs/examine-1sample.sh \
+       bugs/examine-missing.sh \
        bugs/get-no-file.sh \
        bugs/html-frequency.sh \
        bugs/if_crash.sh \
diff --git a/tests/bugs/examine-missing.sh b/tests/bugs/examine-missing.sh
new file mode 100755 (executable)
index 0000000..71f8ee3
--- /dev/null
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+# This program tests for a bug which caused EXAMINE to 
+# crash if all its values were SYSMIS
+
+
+TEMPDIR=/tmp/pspp-tst-$$
+TESTFILE=$TEMPDIR/`basename $0`.sps
+
+here=`pwd`;
+
+# ensure that top_srcdir is absolute
+cd $top_srcdir; top_srcdir=`pwd`
+
+STAT_CONFIG_PATH=$top_srcdir/config
+export STAT_CONFIG_PATH
+
+
+cleanup()
+{
+     cd /
+     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 /x *.
+BEGIN DATA.
+.
+.
+.
+.
+END DATA.
+
+EXAMINE /x PLOT=HISTOGRAM.
+
+EOF
+if [ $? -ne 0 ] ; then no_result ; fi
+
+activity="run program"
+$SUPERVISOR $here/../src/pspp -o raw-ascii $TESTFILE > /dev/null
+if [ $? -ne 0 ] ; then fail ; fi
+
+pass;