From: Ben Pfaff Date: Mon, 16 Apr 2007 00:14:08 +0000 (+0000) Subject: * recode.c (enlarge_dst_widths): Source isn't null-terminated, so X-Git-Tag: v0.6.0~493 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99a5b68989da0422d7bcfa5992e2670c0f284a49;p=pspp-builds.git * recode.c (enlarge_dst_widths): Source isn't null-terminated, so don't pretend it is. (var_is_num_missing): MISSING should include system-missing values too. * automake.mk: Add recode.sh to tests. * tests/xforms/recode.sh: New test. --- diff --git a/src/language/xforms/ChangeLog b/src/language/xforms/ChangeLog index a0952205..461d36dd 100644 --- a/src/language/xforms/ChangeLog +++ b/src/language/xforms/ChangeLog @@ -1,3 +1,10 @@ +2007-04-15 Ben Pfaff + + * recode.c (enlarge_dst_widths): Source isn't null-terminated, so + don't pretend it is. + (var_is_num_missing): MISSING should include system-missing values + too. + Thu Feb 1 16:51:16 2007 Ben Pfaff * recode.c (find_src_numeric): Handle MAP_SYSMIS case, which was diff --git a/src/language/xforms/recode.c b/src/language/xforms/recode.c index 18f72443..e7fa44d3 100644 --- a/src/language/xforms/recode.c +++ b/src/language/xforms/recode.c @@ -509,7 +509,7 @@ enlarge_dst_widths (struct recode_trns *trns) if (!out->copy_input && out->width < max_dst_width) { char *s = pool_alloc_unaligned (trns->pool, max_dst_width + 1); - str_copy_rpad (s, max_dst_width + 1, out->value.c); + buf_copy_rpad (s, max_dst_width + 1, out->value.c, out->width); out->value.c = s; } } @@ -554,7 +554,7 @@ find_src_numeric (struct recode_trns *trns, double value, const struct variable match = value == in->x.f; break; case MAP_MISSING: - match = var_is_num_missing (v, value, MV_USER); + match = var_is_num_missing (v, value, MV_ANY); break; case MAP_RANGE: match = value >= in->x.f && value <= in->y.f; @@ -636,9 +636,9 @@ recode_trns_proc (void *trns_, struct ccase *c, casenumber case_idx UNUSED) const struct map_out *out; if (trns->src_type == VAR_NUMERIC) - out = find_src_numeric (trns, src_data->f, src_var); + out = find_src_numeric (trns, src_data->f, src_var); else - out = find_src_string (trns, src_data->s, var_get_width (src_var)); + out = find_src_string (trns, src_data->s, var_get_width (src_var)); if (trns->dst_type == VAR_NUMERIC) { diff --git a/tests/ChangeLog b/tests/ChangeLog index 66e793d1..1c8eff1f 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,9 @@ +2007-04-15 Ben Pfaff + + * automake.mk: Add recode.sh to tests. + + * tests/xforms/recode.sh: New test. + 2007-04-03 Ben Pfaff John McCabe-Dansted diff --git a/tests/automake.mk b/tests/automake.mk index 51bf743f..61410d6d 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -118,6 +118,7 @@ dist_TESTS = \ tests/bugs/print-crash.sh \ tests/bugs/keep-all.sh \ tests/xforms/casefile.sh \ + tests/xforms/recode.sh \ tests/stats/descript-basic.sh \ tests/stats/descript-missing.sh \ tests/stats/descript-mean-bug.sh \ diff --git a/tests/xforms/recode.sh b/tests/xforms/recode.sh new file mode 100755 index 00000000..9a4da517 --- /dev/null +++ b/tests/xforms/recode.sh @@ -0,0 +1,263 @@ +#!/bin/sh + +# This program tests the RECODE command + +TEMPDIR=/tmp/pspp-tst-$$ +TESTFILE=$TEMPDIR/`basename $0`.sps + + +# ensure that top_builddir are absolute +if [ -z "$top_builddir" ] ; then top_builddir=. ; fi +if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi +top_builddir=`cd $top_builddir; pwd` +PSPP=$top_builddir/src/ui/terminal/pspp + +# ensure that top_srcdir is absolute +top_srcdir=`cd $top_srcdir; pwd` + +STAT_CONFIG_PATH=$top_srcdir/config +export STAT_CONFIG_PATH + +LANG=C +export LANG + +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 <