From: John Darrington Date: Mon, 24 Oct 2005 01:02:34 +0000 (+0000) Subject: Fixed bug #14822. X-Git-Tag: v0.6.0~1182 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4611b8e15a8286d4039ce64b59e5a891af549238;p=pspp-builds.git Fixed bug #14822. --- diff --git a/src/plot-hist.c b/src/plot-hist.c index 15578879..fd1a88d8 100644 --- a/src/plot-hist.c +++ b/src/plot-hist.c @@ -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 ) diff --git a/tests/Makefile.am b/tests/Makefile.am index 21b70dda..a80f9cd9 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 index 00000000..71f8ee3f --- /dev/null +++ b/tests/bugs/examine-missing.sh @@ -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 < /dev/null +if [ $? -ne 0 ] ; then fail ; fi + +pass;