+Sun Feb 13 16:11:13 2005 Ben Pfaff <blp@gnu.org>
+
+ 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 <blp@gnu.org>
Fix Bug #11916, which was confusing a variable's `index' member
lex_error (_("expecting `('"));
goto error;
}
- } else {
+ }
+ else
+ {
/* Parse list of source variables. */
{
int pv_opts = PV_NO_SCRATCH;
if (src)
{
- int output_width;
-
v->src = src[i];
if (src[i]->type == ALPHA)
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);
destvar->label = dest_label[i];
dest_label[i] = NULL;
}
- else if (function->alpha_type == ALPHA)
- destvar->print = destvar->write = function->format;
v->dest = destvar;
}
+Sun Feb 13 16:15:09 2005 Ben Pfaff <blp@gnu.org>
+
+ * bugs/agg-crash-2.sh: Add new test for Bug #11955.
+
Fri Feb 11 23:27:08 2005 Ben Pfaff <blp@gnu.org>
- * 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 <john@darrington.wattle.id.au>
--- /dev/null
+#!/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 <<EOF
+DATA LIST LIST /x (F8.2) y (a25).
+
+BEGIN DATA.
+87.50 foo
+87.34 bar
+1 bar
+END DATA.
+
+
+
+AGGREGATE /BREAK=y /x=MAX(x).
+LIST /x y.
+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|
+#========#======#
+|X |F8.2 |
+|Y |A25 |
++--------+------+
+
+ X Y
+-------- -------------------------
+ 87.34 bar
+ 87.50 foo
+EOF
+if [ $? -ne 0 ] ; then fail ; fi
+
+pass;