]> git.donarmstrong.com Git - lilypond.git/commitdiff
Improve 'warning-as-error handling again
authorPatrick McCarty <pnorcks@gmail.com>
Thu, 17 Sep 2009 07:09:33 +0000 (00:09 -0700)
committerPatrick McCarty <pnorcks@gmail.com>
Fri, 18 Sep 2009 01:55:15 +0000 (18:55 -0700)
Currently, on the Scheme side, ly:warning and ly:programming-error are
redefined to ly:error.  This works, but if the user wants to override
this setting in an LY file, he will not be able to.

This commit moves the handling for the callbacks to C++, thus permitting
users to override -dwarning-as-error in LY files for calls to ly:warning
and ly:programming-error.

lily/general-scheme.cc
scm/lily.scm

index 5d4901f7bf82c65818cfc593e0648c64c60fa852..740c2f349c1ff379dab805caf5818e365fbfb36f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  lily-guile.cc -- implement assorted Guile bindings
+  general-scheme.cc -- implement assorted Guile bindings
 
   source file of the GNU LilyPond music typesetter
 
 #include <cstring>  /* memset */
 using namespace std;
 
+#include "dimensions.hh"
+#include "file-name.hh"
+#include "file-path.hh"
 #include "international.hh"
 #include "libc-extension.hh"
 #include "lily-guile.hh"
-#include "misc.hh"
-#include "warn.hh"
-#include "version.hh"
-#include "dimensions.hh"
 #include "main.hh"
-#include "file-path.hh"
+#include "misc.hh"
+#include "program-option.hh"
 #include "relocate.hh"
-#include "file-name.hh"
 #include "string-convert.hh"
+#include "version.hh"
+#include "warn.hh"
 
 LY_DEFINE (ly_start_environment, "ly:start-environment",
           0, 0, 0, (),
@@ -123,7 +124,12 @@ 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);
-  programming_error (ly_scm2string (str));
+
+  if (get_program_option ("warning-as-error"))
+    error (ly_scm2string (str));
+  else
+    programming_error (ly_scm2string (str));
+
   return SCM_UNSPECIFIED;
 }
 
@@ -134,7 +140,12 @@ LY_DEFINE (ly_warning, "ly:warning",
 {
   LY_ASSERT_TYPE (scm_is_string, str, 1);
   str = scm_simple_format (SCM_BOOL_F, str, rest);
-  warning (ly_scm2string (str));
+
+  if (get_program_option ("warning-as-error"))
+    error (ly_scm2string (str));
+  else
+    warning (ly_scm2string (str));
+
   return SCM_UNSPECIFIED;
 }
 
index 783679ca046cef7a6bccc05014b0b5be662a9cf2..19b5104f4b876932c82f186a38c0031766b5a27a 100644 (file)
@@ -229,11 +229,6 @@ messages into errors.")
 (if (ly:get-option 'trace-scheme-coverage)
     (coverage:enable))
 
-(if (ly:get-option 'warning-as-error)
-    (begin
-      (set! ly:warning ly:error)
-      (set! ly:programming-error ly:error)))
-
 (define-public parser #f)