From: Ben Pfaff Date: Mon, 8 Jun 2009 04:57:36 +0000 (-0700) Subject: Fix handling of #! at beginning of PSPP syntax file; add regression test. X-Git-Tag: build37~75 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eccddce2d2e67e7ddcdbd93d969ef4c5b6efdb28;p=pspp-builds.git Fix handling of #! at beginning of PSPP syntax file; add regression test. Fixes bug #26518. Thanks to John Darrington for testing. --- diff --git a/src/language/syntax-file.c b/src/language/syntax-file.c index 678d2f51..0771ade3 100644 --- a/src/language/syntax-file.c +++ b/src/language/syntax-file.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2009 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -100,6 +100,7 @@ read_syntax_file (struct getl_interface *s, do { sfs->ln++; + ds_clear (line); if (!ds_read_line (line, sfs->syntax_file, SIZE_MAX)) { if (ferror (sfs->syntax_file)) diff --git a/tests/automake.mk b/tests/automake.mk index 0fa61752..7bfd77bf 100644 --- a/tests/automake.mk +++ b/tests/automake.mk @@ -134,6 +134,7 @@ dist_TESTS = \ tests/bugs/overwrite-special-file.sh \ tests/bugs/piechart.sh \ tests/bugs/random.sh \ + tests/bugs/shbang.sh \ tests/bugs/signals.sh \ tests/bugs/t-test-with-temp.sh \ tests/bugs/t-test.sh \ diff --git a/tests/bugs/shbang.sh b/tests/bugs/shbang.sh new file mode 100755 index 00000000..826d5dc4 --- /dev/null +++ b/tests/bugs/shbang.sh @@ -0,0 +1,87 @@ +#!/bin/sh + +# This program tests that PSPP ignores the first line of a PSPP syntax +# file that begins with #!, without issuing an error (bug #26518). + +TEMPDIR=/tmp/pspp-tst-$$ +TESTFILE=$TEMPDIR/`basename $0`.sps + +# ensure that top_srcdir and top_builddir are absolute +if [ -z "$top_srcdir" ] ; then top_srcdir=. ; fi +if [ -z "$top_builddir" ] ; then top_builddir=. ; fi +top_srcdir=`cd $top_srcdir; pwd` +top_builddir=`cd $top_builddir; pwd` + +PSPP=$top_builddir/src/ui/terminal/pspp + +STAT_CONFIG_PATH=$top_srcdir/config +export STAT_CONFIG_PATH + + +cleanup() +{ + if [ x"$PSPP_TEST_NO_CLEANUP" != x ] ; then + echo "NOT cleaning $TEMPDIR" + return ; + fi + 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 + +cat > $TESTFILE << EOF +#! $PSPP +DATA LIST LIST NOTABLE /a. +BEGIN DATA. +1 +2 +END DATA. +LIST. +EOF +if [ $? -ne 0 ] ; then no_result ; fi + + +activity="run program" +$SUPERVISOR $PSPP --testing-mode -e /dev/null $TESTFILE +if [ $? -ne 0 ] ; then fail ; fi + + +activity="compare output" +perl -pi -e 's/^\s*$//g' $TEMPDIR/pspp.list +diff -b -w $TEMPDIR/pspp.list - << EOF + a +-------- + 1.00 + 2.00 +EOF +if [ $? -ne 0 ] ; then fail ; fi + + +pass;