From: Ben Pfaff Date: Fri, 5 Aug 2022 21:13:33 +0000 (-0700) Subject: improve error messages for scale variable summaries X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d5c2d3bfc735ab94d9eb405bdc4feea0fd8cf3e3;hp=f40b7409b8599cc090c82fc3101bb40ead146eef;p=pspp improve error messages for scale variable summaries --- diff --git a/src/language/stats/ctables.c b/src/language/stats/ctables.c index 13fe3b467b..3e370b8276 100644 --- a/src/language/stats/ctables.c +++ b/src/language/stats/ctables.c @@ -6496,15 +6496,21 @@ cmd_ctables (struct lexer *lexer, struct dataset *ds) if (n_summaries > 1) { msg (SE, _("Summaries may appear only on one axis.")); - if (summaries[PIVOT_AXIS_ROW]) - msg_at (SN, summaries[PIVOT_AXIS_ROW]->loc, - _("This variable on the rows axis has a summary.")); - if (summaries[PIVOT_AXIS_COLUMN]) - msg_at (SN, summaries[PIVOT_AXIS_COLUMN]->loc, - _("This variable on the columns axis has a summary.")); - if (summaries[PIVOT_AXIS_LAYER]) - msg_at (SN, summaries[PIVOT_AXIS_LAYER]->loc, - _("This variable on the layers axis has a summary.")); + for (enum pivot_axis_type a = 0; a < PIVOT_N_AXES; a++) + if (summaries[a]) + { + msg_at (SN, summaries[a]->loc, + a == PIVOT_AXIS_ROW + ? _("This variable on the rows axis has a summary.") + : a == PIVOT_AXIS_COLUMN + ? _("This variable on the columns axis has a summary.") + : _("This variable on the layers axis has a summary.")); + if (scales[a]) + msg_at (SN, summaries[a]->loc, + _("This is a scale variable, so it always has a " + "summary even if the syntax does not explicitly " + "specify one.")); + } goto error; } for (enum pivot_axis_type a = 0; a < PIVOT_N_AXES; a++) diff --git a/tests/language/stats/ctables.at b/tests/language/stats/ctables.at index 0eb8760a58..e9ab6d2187 100644 --- a/tests/language/stats/ctables.at +++ b/tests/language/stats/ctables.at @@ -648,6 +648,11 @@ variable must be specified. ctables.sps:23: error: CTABLES: Summaries may appear only on one axis. +ctables.sps:23.50-23.54: note: CTABLES: This variable on the layers axis has a +summary. + 23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT]. + | ^~~~~ + ctables.sps:23.16-23.20: note: CTABLES: This variable on the rows axis has a summary. 23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT]. @@ -658,10 +663,10 @@ summary. 23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT]. | ^~~~~ -ctables.sps:23.50-23.54: note: CTABLES: This variable on the layers axis has a -summary. +ctables.sps:23.33-23.37: note: CTABLES: This is a scale variable, so it always +has a summary even if the syntax does not explicitly specify one. 23 | CTABLES /TABLE qn113 [COUNT] BY qn114 [COUNT] BY qn116 [COUNT]. - | ^~~~~ + | ^~~~~ ]]) AT_CLEANUP @@ -2529,3 +2534,14 @@ s&../../..&MM/DD/YY&'], [0], [dnl Generated HH:MM:SS on MM/DD/YY ]) AT_CLEANUP + +AT_SETUP([CTABLES summary functions]) +AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .]) +AT_DATA([ctables.sps], +[[GET 'nhtsa.sav'. +CTABLES + /TABLE region > qnd5 + qnd6_1 BY qnd7a + agegroup BY qns3a[COUNT, ROWPCT, COLPCT, SUBTABLEPCT] + /SLABELS POSITION=ROW. +]]) +AT_CHECK([pspp ctables.sps --table-look="$builddir"/all-layers.stt -O box=unicode -O width=120], [0], []) +AT_CLEANUP