@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> }.
/* 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;
}
/* 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
return too_many_errors;
}
+void
+msg_ui_disable_warnings (bool x)
+{
+ warnings_off = x;
+}
+
+
void
msg_ui_reset_counts (void)
{
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);
{
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));
}
}
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 */
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