From 36acd35beab37125d4083d98feaebec1d945e9b4 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Thu, 11 Dec 2003 13:40:08 +0000 Subject: [PATCH] Fixed a bug apparent when using the FREQUENCIES command with the html driver --- src/ChangeLog | 7 ++++ src/frequencies.q | 3 ++ src/html.c | 23 +++++++------ src/som.c | 4 +-- src/str.c | 6 +++- src/tab.c | 1 + tests/Makefile.am | 2 +- tests/bugs/html-frequency.sh | 65 ++++++++++++++++++++++++++++++++++++ 8 files changed, 96 insertions(+), 15 deletions(-) create mode 100755 tests/bugs/html-frequency.sh diff --git a/src/ChangeLog b/src/ChangeLog index c3877c4a..dca50453 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ + +Thu Dec 11 21:38:24 WST 2003 John Darrington + + * Fixed a bug apparent when using the FREQUENCIES command with the + html driver. The html driver was incorrectly trying to display + empty cells. + Sun Jan 2 21:40:13 2000 Ben Pfaff * Makefile.am: Reorganized. Put locale dir in version.c instead diff --git a/src/frequencies.q b/src/frequencies.q index d40267e2..353c2be6 100644 --- a/src/frequencies.q +++ b/src/frequencies.q @@ -192,8 +192,11 @@ cmd_frequencies (void) int_pool = pool_create (); result = internal_cmd_frequencies (); pool_destroy (int_pool); + int_pool=0; pool_destroy (gen_pool); + gen_pool=0; free (v_variables); + v_variables=0; return result; } diff --git a/src/html.c b/src/html.c index c647f34b..cb4ae056 100644 --- a/src/html.c +++ b/src/html.c @@ -556,18 +556,19 @@ output_tab_table (struct outp_driver *this, struct tab_table *t) strcpy (cp, ">"); fputs (header, x->file.file); - { - char *s = ls_value (cc); - size_t l = ls_length (cc); - - while (l && isspace ((unsigned char) *s)) - { - l--; - s++; - } + if ( ! (*ct & TAB_EMPTY) ) + { + char *s = ls_value (cc); + size_t l = ls_length (cc); + + while (l && isspace ((unsigned char) *s)) + { + l--; + s++; + } - escape_string (x->file.file, s, l); - } + escape_string (x->file.file, s, l); + } fprintf (x->file.file, "\n", tag); } diff --git a/src/som.c b/src/som.c index dde12b5f..2c527c65 100644 --- a/src/som.c +++ b/src/som.c @@ -64,10 +64,10 @@ som_blank_line (void) } /* Driver. */ -struct outp_driver *d; +static struct outp_driver *d=0; /* Table. */ -struct som_table *t; +static struct som_table *t=0; /* Flags. */ static unsigned flags; diff --git a/src/str.c b/src/str.c index 4bf2d60c..0a9d0d0f 100644 --- a/src/str.c +++ b/src/str.c @@ -331,7 +331,11 @@ ds_end (const struct string *st) void ds_concat (struct string *st, const char *s) { - size_t s_len = strlen (s); + size_t s_len; + + if (!s) return; + + s_len = strlen (s); ds_extend (st, st->length + s_len); strcpy (st->string + st->length, s); st->length += s_len; diff --git a/src/tab.c b/src/tab.c index 412bb0ac..7fdc37d2 100644 --- a/src/tab.c +++ b/src/tab.c @@ -132,6 +132,7 @@ tab_destroy (struct tab_table *t) { assert (t != NULL); pool_destroy (t->container); + t->container=0; } /* Sets the width and height of a table, in columns and rows, diff --git a/tests/Makefile.am b/tests/Makefile.am index 1109a24f..652d517b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -3,7 +3,7 @@ bench: make BENCHMARK=1 check -TESTS = syntax +TESTS = syntax bugs/double-frequency.sh bugs/html-frequency.sh noinst_PROGRAMS = gengarbage diff --git a/tests/bugs/html-frequency.sh b/tests/bugs/html-frequency.sh new file mode 100755 index 00000000..9ef4a4af --- /dev/null +++ b/tests/bugs/html-frequency.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +# This program tests for a bug where pspp would crash +# when a FREQUENCIES command was used with the html +# driver. + + +TEMPDIR=/tmp/pspp-tst-$$ + +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 + +here=`pwd`; + +activity="create data" +cat << EOF > $TEMPDIR/ff.stat + +data list free /v1 v2. +begin data. +0 1 +2 3 +4 5 +3 4 +end data. + +frequencies v1 v2. +EOF +if [ $? -ne 0 ] ; then no_result ; fi + +cd $TEMPDIR + +activity="run data" +$here/../src/pspp -o html $TEMPDIR/ff.stat +if [ $? -ne 0 ] ; then fail ; fi + + +pass; -- 2.30.2