From: Ben Pfaff Date: Mon, 14 Feb 2005 00:15:56 +0000 (+0000) Subject: Fix Bug #11955. X-Git-Tag: v0.4.0~177 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29c51e39acf3554a56aa2adc9451cc5fd70318ae;p=pspp-builds.git Fix Bug #11955. --- diff --git a/src/ChangeLog b/src/ChangeLog index 8cbab8f2..c5fd1977 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +Sun Feb 13 16:11:13 2005 Ben Pfaff + + Fix Bug #11955. + + * aggregate.c: (parse_aggregate_functions) Code cleanup. + Important part: get rid of spurious copying of function->format to + destvar->print and destvar->write. + Fri Feb 11 00:08:36 2005 Ben Pfaff Fix Bug #11916, which was confusing a variable's `index' member diff --git a/src/aggregate.c b/src/aggregate.c index 46e743c9..a2569837 100644 --- a/src/aggregate.c +++ b/src/aggregate.c @@ -421,7 +421,9 @@ parse_aggregate_functions (struct agr_proc *agr) lex_error (_("expecting `('")); goto error; } - } else { + } + else + { /* Parse list of source variables. */ { int pv_opts = PV_NO_SCRATCH; @@ -514,8 +516,6 @@ parse_aggregate_functions (struct agr_proc *agr) if (src) { - int output_width; - v->src = src[i]; if (src[i]->type == ALPHA) @@ -523,28 +523,29 @@ parse_aggregate_functions (struct agr_proc *agr) v->function |= FSTRING; v->string = xmalloc (src[i]->width); } - - if (v->src->type == NUMERIC || function->alpha_type == NUMERIC) - output_width = 0; - else - output_width = v->src->width; if (function->alpha_type == ALPHA) destvar = dict_clone_var (agr->dict, v->src, dest[i]); - else - { - destvar = dict_create_var (agr->dict, dest[i], output_width); - if (output_width == 0) - destvar->print = destvar->write = function->format; - if (output_width == 0 && dict_get_weight (default_dict) != NULL - && (func_index == N || func_index == N_NO_VARS - || func_index == NU || func_index == NU_NO_VARS)) - { - struct fmt_spec f = {FMT_F, 8, 2}; - - destvar->print = destvar->write = f; - } - } + else if (v->src->type == NUMERIC + || function->alpha_type == NUMERIC) + { + destvar = dict_create_var (agr->dict, dest[i], 0); + + if ((func_index == N + || func_index == N_NO_VARS + || func_index == NMISS) + && dict_get_weight (default_dict) != NULL) + { + static const struct fmt_spec f8_2 = {FMT_F, 8, 2}; + + destvar->print = destvar->write = f8_2; + } + else + destvar->print = destvar->write = function->format; + } + else + destvar = dict_create_var (agr->dict, dest[i], + v->src->width); } else { v->src = NULL; destvar = dict_create_var (agr->dict, dest[i], 0); @@ -568,8 +569,6 @@ parse_aggregate_functions (struct agr_proc *agr) destvar->label = dest_label[i]; dest_label[i] = NULL; } - else if (function->alpha_type == ALPHA) - destvar->print = destvar->write = function->format; v->dest = destvar; } diff --git a/tests/ChangeLog b/tests/ChangeLog index 5c7be719..fc770a1a 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,6 +1,10 @@ +Sun Feb 13 16:15:09 2005 Ben Pfaff + + * bugs/agg-crash-2.sh: Add new test for Bug #11955. + Fri Feb 11 23:27:08 2005 Ben Pfaff - * bugs/crosstabs-crash: Add new test for Bug #11916. + * bugs/crosstabs-crash.sh: Add new test for Bug #11916. Tue Jan 18 19:25:24 WST 2005 John Darrington diff --git a/tests/Makefile.am b/tests/Makefile.am index 75740471..f94d9b4d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -42,6 +42,7 @@ TESTS = \ command/use.sh \ command/weight.sh \ bugs/agg_crash.sh \ + bugs/agg-crash-2.sh \ bugs/alpha-freq.sh \ bugs/big-input.sh \ bugs/big-input-2.sh \ diff --git a/tests/bugs/agg-crash-2.sh b/tests/bugs/agg-crash-2.sh new file mode 100755 index 00000000..384c3c80 --- /dev/null +++ b/tests/bugs/agg-crash-2.sh @@ -0,0 +1,86 @@ +#!/bin/sh + +# This program tests for a bug which caused AGGREGATE to crash when +# the MAX function was used. + +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 <