From: Ben Pfaff Date: Fri, 8 Apr 2011 03:53:18 +0000 (-0700) Subject: FREQUENCIES: Fix crash when median and histogram both requested. X-Git-Tag: v0.7.8~86 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe8b4cd515f1a3e91240901a4f6546c655df348f;p=pspp-builds.git FREQUENCIES: Fix crash when median and histogram both requested. Thanks to Benoit Flippen for reporting this bug. --- diff --git a/src/language/stats/frequencies.q b/src/language/stats/frequencies.q index c00e645f..9bc2f73e 100644 --- a/src/language/stats/frequencies.q +++ b/src/language/stats/frequencies.q @@ -1047,7 +1047,7 @@ dump_statistics (const struct frq_proc *frq, const struct var_freqs *vf, tab_double (t, 2, 0, TAB_NONE, ft->valid_cases, wfmt); tab_double (t, 2, 1, TAB_NONE, ft->total_cases - ft->valid_cases, wfmt); - for (i = 0; i < frq->n_percentiles; i++, r++) + for (i = 0; i < frq->n_percentiles; i++) { struct percentile *pc = &frq->percentiles[i]; @@ -1065,6 +1065,7 @@ dump_statistics (const struct frq_proc *frq, const struct var_freqs *vf, tab_fixed (t, 1, r, TAB_LEFT, pc->p * 100, 3, 0); tab_double (t, 2, r, TAB_NONE, pc->value, var_get_print_format (vf->var)); + r++; } tab_title (t, "%s", var_to_string (vf->var)); diff --git a/tests/language/stats/frequencies.at b/tests/language/stats/frequencies.at index 8aaba06c..86cfd6e5 100644 --- a/tests/language/stats/frequencies.at +++ b/tests/language/stats/frequencies.at @@ -70,7 +70,7 @@ Total,,4,100.0,100.0, AT_CLEANUP # Tests for a bug where PSPP would crash when a FREQUENCIES command -# was used with the HTML output driver.. +# was used with the HTML output driver. AT_SETUP([FREQUENCIES HTML output crash]) AT_DATA([frequencies.sps], [data list free /v1 v2. @@ -105,7 +105,7 @@ AT_CHECK([test -s pspp.html]) AT_CLEANUP # Tests for a bug which crashed PSPP when a piechart with too many -# segments was requested.. +# segments was requested. AT_SETUP([FREQUENCIES pie chart crash]) AT_DATA([frequencies.sps], [data list list /x * w *. @@ -149,8 +149,33 @@ FREQUENCIES ]) AT_CLEANUP +# Tests for a bug which crashed PSPP when the median and a histogram +# were both requested. +AT_SETUP([FREQUENCIES median with histogram crash]) +AT_DATA([frequencies.sps], [dnl +data list list notable /x. +begin data. +1 +end data. + +frequencies /x /histogram /STATISTICS=median. +]) +AT_CHECK([pspp -O format=csv frequencies.sps], [0], [dnl +Table: x +Value Label,Value,Frequency,Percent,Valid Percent,Cum Percent +,1.00,1,100.00,100.00,100.00 +Total,,1,100.0,100.0, + +Table: x +N,Valid,1 +,Missing,0 +S.E. Kurt,,.00 +,50 (Median),1.00 +]) +AT_CLEANUP + # Tests for a bug which caused FREQUENCIES following TEMPORARY to -# crash (bug #11492).. +# crash (bug #11492). AT_SETUP([FREQUENCIES crash after TEMPORARY]) AT_DATA([frequencies.sps], [DATA LIST LIST /SEX (A1) X *.