format: Improve error messages.
authorBen Pfaff <blp@cs.stanford.edu>
Wed, 21 Sep 2022 23:32:26 +0000 (16:32 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Wed, 21 Sep 2022 23:33:34 +0000 (16:33 -0700)
src/data/format.c
tests/language/data-io/data-list.at
tests/language/dictionary/formats.at

index 5b0242ab473153920ee26d1056d3d9e390790a3c..73e5dd60f4259df5932f60002a37a0c86c7225b0 100644 (file)
@@ -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;
index dbd5e1c8a636e215fd609d172babeafb9ce589f3..165b4df722ce413aeafcc7738d05e1ac645de4a0 100644 (file)
@@ -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).
       |                   ^~~~~~~"
 
index 9e9d171ae4e6caa4bd86c4af349b0b71f6952468..1abf8e00b6d625e15c419e690056ca1edbd2d024 100644 (file)
@@ -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).
       |            ^~~~"