]> git.donarmstrong.com Git - lilypond.git/commitdiff
Warnings: Move all warning-as-error handling to warn.cc
authorReinhold Kainhofer <reinhold@kainhofer.com>
Wed, 28 Sep 2011 10:39:12 +0000 (12:39 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 14 Nov 2011 21:09:58 +0000 (22:09 +0100)
This finally makes that option apply to ALL warnings, and it considerably cleans up the error/warning functions.

flower/include/warn.hh
flower/warn.cc
lily/input.cc
lily/program-option-scheme.cc
lily/warn-scheme.cc

index f17bef2804b734c395a01a0e78ebc11e9bb3e65e..959a55629188fa00ef00dc27bce4552e39baa2b6 100644 (file)
@@ -41,6 +41,8 @@
 #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!
index af16f20bebe0dd347253e775493fe9b61bd82ba6..8cdfcb6b998870c4d208a2a5d69dd4b6be6e251c 100644 (file)
@@ -40,6 +40,7 @@ using namespace std;
 
 /* Define the loglevel (default is INFO) */
 int loglevel = LOGLEVEL_INFO;
+bool warning_as_error = false;
 
 bool
 is_loglevel (int level)
@@ -188,12 +189,15 @@ error (string s, string location)
 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.  */
@@ -202,9 +206,10 @@ non_fatal_error (string s, string location)
 {
   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. */
@@ -213,10 +218,10 @@ warning (string s, string location)
 {
   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.  */
index 28923f49481efd792eb93a9e67d210ec8b970820..9ba376763861cbd58fbff6d3dadf7a216bdbdabd 100644 (file)
@@ -103,10 +103,7 @@ Input::error (string s) const
 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
@@ -118,10 +115,7 @@ Input::non_fatal_error (string s) const
 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
index 2c3d60dc8792ebf0f34d9ca01a55f0c7b17e0c82..2d65001a1452b8667b2c405fd3715aa8b5eff828 100644 (file)
@@ -123,7 +123,11 @@ internal_set_option (SCM var,
       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;
index 2f7a1af611f0f442c7577b589f010130a3dab27e..3b917b760e05da92beb3445cbd562927df302a78 100644 (file)
@@ -49,12 +49,7 @@ LY_DEFINE (ly_programming_error, "ly:programming-error",
 {
   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;
 }
 
@@ -65,12 +60,7 @@ LY_DEFINE (ly_warning, "ly:warning",
 {
   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;
 }
 
@@ -129,12 +119,7 @@ LY_DEFINE (ly_warning_located, "ly:warning-located",
   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;
 }