From ee5c3686e7634639ff3f4a85db83b868d4693711 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Wed, 21 Sep 2022 16:32:26 -0700 Subject: [PATCH] format: Improve error messages. --- src/data/format.c | 32 +++++++++++----------------- tests/language/data-io/data-list.at | 2 +- tests/language/dictionary/formats.at | 2 +- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/data/format.c b/src/data/format.c index 5b0242ab47..73e5dd60f4 100644 --- a/src/data/format.c +++ b/src/data/format.c @@ -410,42 +410,34 @@ fmt_check__ (const struct fmt_spec *spec, enum fmt_use use) return (use == FMT_FOR_INPUT ? xasprintf (ngettext ( "Input format %s specifies %d decimal place, " - "but the given width allows at most " - "%d decimals.", + "but width %d allows at most %d decimals.", "Input format %s specifies %d decimal places, " - "but the given width allows at most " - "%d decimals.", + "but width %d allows at most %d decimals.", spec->d), - str, spec->d, max_d) + str, spec->d, spec->w, max_d) : xasprintf (ngettext ( "Output format %s specifies %d decimal place, " - "but the given width allows at most " - "%d decimals.", + "but width %d allows at most %d decimals.", "Output format %s specifies %d decimal places, " - "but the given width allows at most " - "%d decimals.", + "but width %d allows at most %d decimals.", spec->d), - str, spec->d, max_d)); + str, spec->d, spec->w, max_d)); else return (use == FMT_FOR_INPUT ? xasprintf (ngettext ( "Input format %s specifies %d decimal place, " - "but the given width does not allow " - "for any decimals.", + "but width %d does not allow for any decimals.", "Input format %s specifies %d decimal places, " - "but the given width does not allow " - "for any decimals.", + "but width %d does not allow for any decimals.", spec->d), - str, spec->d) + str, spec->d, spec->w) : xasprintf (ngettext ( "Output format %s specifies %d decimal place, " - "but the given width does not allow " - "for any decimals.", + "but width %d does not allow for any decimals.", "Output format %s specifies %d decimal places, " - "but the given width does not allow " - "for any decimals.", + "but width %d does not allow for any decimals.", spec->d), - str, spec->d)); + str, spec->d, spec->w)); } return NULL; diff --git a/tests/language/data-io/data-list.at b/tests/language/data-io/data-list.at index dbd5e1c8a6..165b4df722 100644 --- a/tests/language/data-io/data-list.at +++ b/tests/language/data-io/data-list.at @@ -542,7 +542,7 @@ AT_CHECK([pspp --testing-mode -O format=csv insert.sps], [1], [dnl 28 | DATA LIST FIXED/x 1-5 (**). | ^~" -"data-list.sps:29.19-29.25: error: DATA LIST: Input format F1.5 specifies 5 decimal places, but the given width allows at most 1 decimals. +"data-list.sps:29.19-29.25: error: DATA LIST: Input format F1.5 specifies 5 decimal places, but width 1 allows at most 1 decimals. 29 | DATA LIST FIXED/x 1 (F,5). | ^~~~~~~" diff --git a/tests/language/dictionary/formats.at b/tests/language/dictionary/formats.at index 9e9d171ae4..1abf8e00b6 100644 --- a/tests/language/dictionary/formats.at +++ b/tests/language/dictionary/formats.at @@ -84,7 +84,7 @@ x,A1 y,A2 z,A3 -"formats.sps:2.12-2.15: error: FORMATS: Output format E6.1 specifies 1 decimal place, but the given width does not allow for any decimals. +"formats.sps:2.12-2.15: error: FORMATS: Output format E6.1 specifies 1 decimal place, but width 6 does not allow for any decimals. 2 | FORMATS a (E6.1). | ^~~~" -- 2.30.2