SET MXWARNS = 0 to be interpreted as unlimited. 20100822040502/pspp 20100823040503/pspp
authorJohn Darrington <john@darrington.wattle.id.au>
Sun, 22 Aug 2010 10:36:37 +0000 (12:36 +0200)
committerJohn Darrington <john@darrington.wattle.id.au>
Sun, 22 Aug 2010 10:36:37 +0000 (12:36 +0200)
This change introduces a special meaning to the
value of zero for the MXWARNS settings.  When
a zero value is set.  A single warning will be
emitted informing the user that the setting is
in effect.  Thereafter no warning will be emitted.
All warning situations will be ignored.

doc/utilities.texi
src/data/settings.c
src/libpspp/message.c
src/libpspp/message.h
tests/language/utilities/set.at

index fabec248b6aed6f894ea3afdd11ddf4243fe22a0..6b248e621fe9766dd5df0eeec079b9420bfa31c1 100644 (file)
@@ -525,7 +525,11 @@ command file.  The default is 50.
 
 @item MXWARNS
 The maximum number of warnings + errors before PSPP halts processing the
-current command file.  The default is 100.
+current command file.  
+The special value of zero means that all warning situations should be ignored.
+No warnings will be issued, except a single initial warning advising the user
+that warnings will not be given.
+The default value is 100.
 
 @item PROMPT
 The command prompt.  The default is @samp{PSPP> }.
index d95e3a14076a140d848d8ccad45c73e767592d47..10b20f8a352b9b83eec4307c41696f1a180a56bf 100644 (file)
@@ -364,11 +364,31 @@ settings_get_max_messages (enum msg_severity severity)
 
 /* Sets the maximum number of messages to show of the given SEVERITY before
    aborting to MAX.  (The value for MSG_S_WARNING is interpreted as maximum
-   number of warnings and errors combined.) */
+   number of warnings and errors combined.)  In addition, in the case of 
+   warnings the special value of zero indicates that no warnings are to be
+   issued. 
+*/
 void
 settings_set_max_messages (enum msg_severity severity, int max)
 {
   assert (severity < MSG_N_SEVERITIES);
+
+  if (severity == MSG_S_WARNING)
+    {
+      if ( max == 0)
+       {
+         msg (MW,
+              _("MXWARNS set to zero.  No further warnings will be given even when potentially problematic situations are encountered."));
+         msg_ui_disable_warnings (true);
+       }
+      else if ( the_settings.max_messages [MSG_S_WARNING] == 0)
+       {
+         msg_ui_disable_warnings (false);
+         the_settings.max_messages[MSG_S_WARNING] = max;
+         msg (MW, _("Warnings re-enabled. %d warnings will be issued before aborting syntax processing."), max);
+       }
+    }
+
   the_settings.max_messages[severity] = max;
 }
 
index 0d226a1732ed45a2825ac02ce263780f769947ee..4ba8a8f7aca966e5add8671fa31dbd178abfc387 100644 (file)
@@ -156,6 +156,9 @@ static bool too_many_errors;
 /* True after the maximum number of notes has been exceeded. */
 static bool too_many_notes;
 
+/* True iff warnings have been explicitly disabled (MXWARNS = 0) */
+static bool warnings_off = false;
+
 /* Checks whether we've had so many errors that it's time to quit
    processing this syntax file. */
 bool
@@ -164,6 +167,13 @@ msg_ui_too_many_errors (void)
   return too_many_errors;
 }
 
+void
+msg_ui_disable_warnings (bool x)
+{
+  warnings_off = x;
+}
+
+
 void
 msg_ui_reset_counts (void)
 {
@@ -195,12 +205,17 @@ submit_note (char *s)
   free (s);
 }
 
+
+
 static void
 process_msg (const struct msg *m)
 {
   int n_msgs, max_msgs;
 
-  if (too_many_errors || (too_many_notes && m->severity == MSG_S_NOTE))
+
+  if (too_many_errors
+      || (too_many_notes && m->severity == MSG_S_NOTE)
+      || (warnings_off && m->severity == MSG_S_WARNING) )
     return;
 
   msg_handler (m);
@@ -223,10 +238,10 @@ process_msg (const struct msg *m)
         {
           too_many_errors = true;
           if (m->severity == MSG_S_WARNING)
-            submit_note (xasprintf (_("Warnings (%d) exceed limit (%d)."),
+            submit_note (xasprintf (_("Warnings (%d) exceed limit (%d).  Syntax processing will be halted."),
                                     n_msgs, max_msgs));
           else
-            submit_note (xasprintf (_("Errors (%d) exceed limit (%d)."),
+            submit_note (xasprintf (_("Errors (%d) exceed limit (%d).  Syntax processing will be halted."),
                                     n_msgs, max_msgs));
         }
     }
index cf297ae324babc5bbbd9ee26cc3e5bb17b6f1cb5..bdd27a5e72faac5cc52ee2e85bbd8a992a7c6912 100644 (file)
@@ -108,12 +108,14 @@ void msg_disable (void);
 void msg_push_msg_locator (const struct msg_locator *);
 void msg_pop_msg_locator (const struct msg_locator *);
 
+bool msg_ui_too_many_errors (void);
+void msg_ui_reset_counts (void);
+bool msg_ui_any_errors (void);
+void msg_ui_disable_warnings (bool);
+
 
 /* Used in panic situations only. */
 void request_bug_report_and_abort (const char *msg) NO_RETURN;
 
-bool msg_ui_too_many_errors (void);
-void msg_ui_reset_counts (void);
-bool msg_ui_any_errors (void);
 
 #endif /* message.h */
index 851642ebdcb36cdc57ecd9a6e8e0eb291c94bb28..e1b92573f31e910e32540d3846d54e85fdf21a05 100644 (file)
@@ -20,3 +20,75 @@ Variable,N,Mean,Std Dev,Minimum,Maximum
 x,3,2.00,1.00,1.00,3.00
 ])
 AT_CLEANUP
+
+
+
+AT_SETUP([SET MXWARNS])
+dnl Make sure that syntax processing stops and that
+dnl a warning is issued when the MXWARNS figure is
+dnl exceeded.
+AT_DATA([set.pspp], [dnl
+set mxwarns=2.
+data list notable list /x (f8.2) y (f8.2).
+begin data
+1 2
+3 r
+5 x
+q 8
+9 9
+3 x
+w w
+end data.
+
+comment The following line should not be executed.
+list.
+])
+
+AT_CHECK([pspp -O format=csv set.pspp], [0], [dnl
+"set.pspp:5: warning: (column 3, F field) Field contents are not numeric."
+
+"set.pspp:6: warning: (column 3, F field) Field contents are not numeric."
+
+"set.pspp:7: warning: (column 1, F field) Field contents are not numeric."
+
+note: Warnings (3) exceed limit (2).  Syntax processing will be halted.
+])
+
+AT_CLEANUP
+
+
+
+
+AT_SETUP([SET MXWARNS special case zero])
+dnl Make sure that MXWARNS interprets zero as infinity.
+AT_DATA([mxwarns.pspp], [dnl
+set mxwarns=0.
+data list notable list /x (f8.2) y (f8.2) z *.
+begin data
+1 2 3
+3 r 3
+5 x 3
+q 8 4
+9 9 4
+3 x 4
+w w 4
+end data.
+
+list.
+])
+
+AT_CHECK([pspp -O format=csv mxwarns.pspp], [0],
+[warning: MXWARNS set to zero.  No further warnings will be given even when potentially problematic situations are encountered.
+
+Table: Data List
+x,y,z
+1.00,2.00,3.00
+3.00,.  ,3.00
+5.00,.  ,3.00
+.  ,8.00,4.00
+9.00,9.00,4.00
+3.00,.  ,4.00
+.  ,.  ,4.00
+])
+
+AT_CLEANUP