From: John Darrington Date: Fri, 20 Feb 2004 06:41:14 +0000 (+0000) Subject: Fixed a bug causing pspp to crash when computed variables had no format X-Git-Tag: v0.4.0~343 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d4d9866bb2ec1797b8fb103e7144d0e9ffd1abff;p=pspp-builds.git Fixed a bug causing pspp to crash when computed variables had no format defined, and were subsequently saved. --- diff --git a/src/ChangeLog b/src/ChangeLog index f28af403..2c524f32 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +Fri Feb 20 14:37:41 WAST 2004 John Darrington + + * compute.c: Fixed a bug where the Format was not getting set for + computed variables (thus causing a crash when SAVEing). + + * Added a test to stop this bug ever coming back + Wed Feb 18 22:21:35 2004 Ben Pfaff Got rid of approx.h. In general, replaced all references to diff --git a/src/compute.c b/src/compute.c index 0a1077d4..d26bf1ed 100644 --- a/src/compute.c +++ b/src/compute.c @@ -397,11 +397,20 @@ lvalue_finalize (struct lvalue *lvalue, { compute->variable = dict_lookup_var (default_dict, lvalue->var_name); if (compute->variable == NULL) - compute->variable = dict_create_var_assert (default_dict, - lvalue->var_name, 0); + { + struct fmt_spec input_spec = { 0,8,2 }; + compute->variable = dict_create_var_assert (default_dict, + lvalue->var_name, 0); + + convert_fmt_ItoO (&input_spec, &compute->variable->print); + compute->variable->write = compute->variable->print; + } + compute->fv = compute->variable->fv; compute->width = compute->variable->width; + + /* Goofy behavior, but compatible: Turn off LEAVE. */ if (dict_class_from_id (compute->variable->name) != DC_SCRATCH) compute->variable->reinit = 1; diff --git a/tests/Makefile.am b/tests/Makefile.am index b79cdbe0..c5c40add 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -26,11 +26,12 @@ TESTS = command/aggregate.sh \ command/t-test-groups.sh \ command/weight.sh \ bugs/alpha-freq.sh \ + bugs/compute-fmt.sh \ bugs/double-frequency.sh \ bugs/html-frequency.sh \ bugs/crosstabs.sh \ bugs/data-crash.sh \ - bugs/random.sh + bugs/random.sh noinst_PROGRAMS = gengarbage diff --git a/tests/bugs/compute-fmt.sh b/tests/bugs/compute-fmt.sh new file mode 100755 index 00000000..90947510 --- /dev/null +++ b/tests/bugs/compute-fmt.sh @@ -0,0 +1,67 @@ +#!/bin/sh + +# This program tests for a bug which caused a crash after SAVE FILE +# was called on a COMPUTEd variable + + +TEMPDIR=/tmp/pspp-tst-$$ + +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 > $TEMPDIR/foo.sps <