This finally makes that option apply to ALL warnings, and it considerably cleans up the error/warning functions.
#define LOGLEVEL_DEBUG (LOGLEVEL_INFO | LOG_DEBUG)
extern int loglevel;
+extern bool warning_as_error;
+
/* output messages, in decreasing order of importance */
void error (string s, string location = ""); // Fatal error, exits lilypond!
/* Define the loglevel (default is INFO) */
int loglevel = LOGLEVEL_INFO;
+bool warning_as_error = false;
bool
is_loglevel (int level)
void
programming_error (string s, string location)
{
- if (is_expected (s)) {
+ if (is_expected (s))
print_message (LOG_DEBUG, location, _f ("suppressed programming error: %s", s) + "\n");
- } else {
- print_message (LOG_ERROR, location, _f ("programming error: %s", s) + "\n");
- print_message (LOG_ERROR, location, _ ("continuing, cross fingers") + "\n");
- }
+ else if (warning_as_error)
+ error (s, location);
+ else
+ {
+ print_message (LOG_ERROR, location, _f ("programming error: %s", s) + "\n");
+ print_message (LOG_ERROR, location, _ ("continuing, cross fingers") + "\n");
+ }
}
/* Display a non-fatal error message, don't exit. */
{
if (is_expected (s))
print_message (LOG_DEBUG, location, _f ("suppressed error: %s", s) + "\n");
- else {
+ else if (warning_as_error)
+ error (s, location);
+ else
print_message (LOG_ERROR, location, _f ("error: %s", s) + "\n");
- }
}
/* Display a warning message. */
{
if (is_expected (s))
print_message (LOG_DEBUG, location, _f ("suppressed warning: %s", s) + "\n");
- else {
- // TODO: Add warning-as-error check here
+ else if (warning_as_error)
+ error (s, location);
+ else
print_message (LOG_WARN, location, _f ("warning: %s", s) + "\n");
- }
}
/* Display a success message. */
void
Input::programming_error (string s) const
{
- if (get_program_option ("warning-as-error"))
- ::error (message_string (s), message_location ());
- else
- ::programming_error (message_string (s), message_location ());
+ ::programming_error (message_string (s), message_location ());
}
void
void
Input::warning (string s) const
{
- if (get_program_option ("warning-as-error"))
- ::non_fatal_error (message_string (s), message_location ());
- else
- ::warning (message_string (s), message_location ());
+ ::warning (message_string (s), message_location ());
}
void
val = val_scm_bool;
}
else if (varstr == "warning-as-error")
- val = val_scm_bool;
+ {
+ /* warning_as_error is defined in flower/warn.cc */
+ warning_as_error = valbool;
+ val = val_scm_bool;
+ }
else if (varstr == "music-strings-to-paths")
{
music_strings_to_paths = valbool;
{
LY_ASSERT_TYPE (scm_is_string, str, 1);
str = scm_simple_format (SCM_BOOL_F, str, rest);
-
- if (get_program_option ("warning-as-error"))
- error (ly_scm2string (str));
- else
- programming_error (ly_scm2string (str));
-
+ programming_error (ly_scm2string (str));
return SCM_UNSPECIFIED;
}
{
LY_ASSERT_TYPE (scm_is_string, str, 1);
str = scm_simple_format (SCM_BOOL_F, str, rest);
-
- if (get_program_option ("warning-as-error"))
- error (ly_scm2string (str));
- else
- warning (ly_scm2string (str));
-
+ warning (ly_scm2string (str));
return SCM_UNSPECIFIED;
}
LY_ASSERT_TYPE (scm_is_string, location, 1);
LY_ASSERT_TYPE (scm_is_string, str, 2);
str = scm_simple_format (SCM_BOOL_F, str, rest);
-
- if (get_program_option ("warning-as-error"))
- error (ly_scm2string (str), ly_scm2string (location));
- else
- warning (ly_scm2string (str), ly_scm2string (location));
-
+ warning (ly_scm2string (str), ly_scm2string (location));
return SCM_UNSPECIFIED;
}