pspp-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pspp-cvs] Changes to pspp/src/format.c


From: Ben Pfaff
Subject: [Pspp-cvs] Changes to pspp/src/format.c
Date: Tue, 01 Mar 2005 03:16:31 -0500

Index: pspp/src/format.c
diff -u pspp/src/format.c:1.7 pspp/src/format.c:1.8
--- pspp/src/format.c:1.7       Mon May 31 05:50:31 2004
+++ pspp/src/format.c   Tue Mar  1 08:16:15 2005
@@ -44,7 +44,7 @@
    in the current token on success or to a null pointer on
    failure. */
 int
-parse_format_specifier_name (const char **cp, int allow_xt)
+parse_format_specifier_name (const char **cp, enum fmt_parse_flags flags)
 {
   char *sp, *ep;
   int idx;
@@ -64,17 +64,19 @@
       /* Check format. */
       if (idx < FMT_NUMBER_OF_FORMATS)
         {
-          if (!allow_xt && (idx == FMT_T || idx == FMT_X)) 
+          if (!(flags & FMTP_ALLOW_XT) && (idx == FMT_T || idx == FMT_X)) 
             {
-              msg (SE, _("X and T format specifiers not allowed here."));
+              if (!(flags & FMTP_SUPPRESS_ERRORS))
+                msg (SE, _("X and T format specifiers not allowed here."));
               idx = -1; 
             }
         }
       else 
         {
           /* No match. */
-          msg (SE, _("%.*s is not a valid data format."),
-               (int) (ep - sp), ds_c_str (&tokstr));
+          if (!(flags & FMTP_SUPPRESS_ERRORS))
+            msg (SE, _("%.*s is not a valid data format."),
+                 (int) (ep - sp), ds_c_str (&tokstr));
           idx = -1; 
         }
     }
@@ -110,10 +112,10 @@
 }
 
 /* Checks whether SPEC is valid as an input format and returns
-   nonzero if so.  Otherwise, emits an error message and returns
-   zero. */
+   nonzero if so.  Otherwise, emits an error message (if
+   EMIT_ERROR is nonzero) and returns zero. */
 int
-check_input_specifier (const struct fmt_spec *spec)
+check_input_specifier (const struct fmt_spec *spec, int emit_error)
 {
   struct fmt_desc *f;
   char *str;
@@ -124,38 +126,42 @@
     return 1;
   if (f->cat & FCAT_OUTPUT_ONLY)
     {
-      msg (SE, _("Format %s may not be used as an input format."), f->name);
+      if (emit_error)
+        msg (SE, _("Format %s may not be used as an input format."), f->name);
       return 0;
     }
   if (spec->w < f->Imin_w || spec->w > f->Imax_w)
     {
-      msg (SE, _("Input format %s specifies a bad width %d.  "
-                "Format %s requires a width between %d and %d."),
-          str, spec->w, f->name, f->Imin_w, f->Imax_w);
+      if (emit_error)
+        msg (SE, _("Input format %s specifies a bad width %d.  "
+                   "Format %s requires a width between %d and %d."),
+             str, spec->w, f->name, f->Imin_w, f->Imax_w);
       return 0;
     }
   if ((f->cat & FCAT_EVEN_WIDTH) && spec->w % 2)
     {
-      msg (SE, _("Input format %s specifies an odd width %d, but "
-                "format %s requires an even width between %d and "
-                "%d."), str, spec->w, f->name, f->Imin_w, f->Imax_w);
+      if (emit_error)
+        msg (SE, _("Input format %s specifies an odd width %d, but "
+                   "format %s requires an even width between %d and "
+                   "%d."), str, spec->w, f->name, f->Imin_w, f->Imax_w);
       return 0;
     }
   if (f->n_args > 1 && (spec->d < 0 || spec->d > 16))
     {
-      msg (SE, _("Input format %s specifies a bad number of "
-                "implied decimal places %d.  Input format %s allows "
-                "up to 16 implied decimal places."), str, spec->d, f->name);
+      if (emit_error)
+        msg (SE, _("Input format %s specifies a bad number of "
+                   "implied decimal places %d.  Input format %s allows "
+                   "up to 16 implied decimal places."), str, spec->d, f->name);
       return 0;
     }
   return 1;
 }
 
 /* Checks whether SPEC is valid as an output format and returns
-   nonzero if so.  Otherwise, emits an error message and returns
-   zero. */
+   nonzero if so.  Otherwise, emits an error message (if
+   EMIT_ERROR is nonzero) and returns zero. */
 int
-check_output_specifier (const struct fmt_spec *spec)
+check_output_specifier (const struct fmt_spec *spec, int emit_error)
 {
   struct fmt_desc *f;
   char *str;
@@ -166,9 +172,10 @@
     return 1;
   if (spec->w < f->Omin_w || spec->w > f->Omax_w)
     {
-      msg (SE, _("Output format %s specifies a bad width %d.  "
-                "Format %s requires a width between %d and %d."),
-          str, spec->w, f->name, f->Omin_w, f->Omax_w);
+      if (emit_error)
+        msg (SE, _("Output format %s specifies a bad width %d.  "
+                   "Format %s requires a width between %d and %d."),
+             str, spec->w, f->name, f->Omin_w, f->Omax_w);
       return 0;
     }
   if (spec->d > 1
@@ -176,25 +183,28 @@
          || spec->type == FMT_DOLLAR)
       && spec->w < f->Omin_w + 1 + spec->d)
     {
-      msg (SE, _("Output format %s requires minimum width %d to allow "
-                "%d decimal places.  Try %s%d.%d instead of %s."),
-          f->name, f->Omin_w + 1 + spec->d, spec->d, f->name,
-          f->Omin_w + 1 + spec->d, spec->d, str);
+      if (emit_error)
+        msg (SE, _("Output format %s requires minimum width %d to allow "
+                   "%d decimal places.  Try %s%d.%d instead of %s."),
+             f->name, f->Omin_w + 1 + spec->d, spec->d, f->name,
+             f->Omin_w + 1 + spec->d, spec->d, str);
       return 0;
     }
   if ((f->cat & FCAT_EVEN_WIDTH) && spec->w % 2)
     {
-      msg (SE, _("Output format %s specifies an odd width %d, but "
-                "output format %s requires an even width between %d and "
-                "%d."), str, spec->w, f->name, f->Omin_w, f->Omax_w);
+      if (emit_error)
+        msg (SE, _("Output format %s specifies an odd width %d, but "
+                   "output format %s requires an even width between %d and "
+                   "%d."), str, spec->w, f->name, f->Omin_w, f->Omax_w);
       return 0;
     }
   if (f->n_args > 1 && (spec->d < 0 || spec->d > 16))
     {
-      msg (SE, _("Output format %s specifies a bad number of "
-                "implied decimal places %d.  Output format %s allows "
-                "a number of implied decimal places between 1 "
-                "and 16."), str, spec->d, f->name);
+      if (emit_error)
+        msg (SE, _("Output format %s specifies a bad number of "
+                   "implied decimal places %d.  Output format %s allows "
+                   "a number of implied decimal places between 1 "
+                   "and 16."), str, spec->d, f->name);
       return 0;
     }
   return 1;
@@ -316,7 +326,7 @@
    check_output_specifier() on the parsed format as
    necessary.  */
 int
-parse_format_specifier (struct fmt_spec *input, int allow_xt)
+parse_format_specifier (struct fmt_spec *input, enum fmt_parse_flags flags)
 {
   struct fmt_spec spec;
   struct fmt_desc *f;
@@ -326,10 +336,11 @@
 
   if (token != T_ID)
     {
-      msg (SE, _("Format specifier expected."));
+      if (!(flags & FMTP_SUPPRESS_ERRORS))
+        msg (SE, _("Format specifier expected."));
       return 0;
     }
-  type = parse_format_specifier_name (&cp, allow_xt);
+  type = parse_format_specifier_name (&cp, flags);
   if (type == -1)
     return 0;
   f = &formats[type];
@@ -337,8 +348,9 @@
   w = strtol (cp, &cp2, 10);
   if (cp2 == cp && type != FMT_X)
     {
-      msg (SE, _("Data format %s does not specify a width."),
-          ds_c_str (&tokstr));
+      if (!(flags & FMTP_SUPPRESS_ERRORS))
+        msg (SE, _("Data format %s does not specify a width."),
+             ds_c_str (&tokstr));
       return 0;
     }
 
@@ -354,7 +366,8 @@
 
   if (*cp)
     {
-      msg (SE, _("Data format %s is not valid."), ds_c_str (&tokstr));
+      if (!(flags & FMTP_SUPPRESS_ERRORS))
+        msg (SE, _("Data format %s is not valid."), ds_c_str (&tokstr));
       return 0;
     }
   lex_get ();




reply via email to

[Prev in Thread] Current Thread [Next in Thread]