From d9b0a7c0fba0297b2b9afdc2a79603b8a7a314af Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Thu, 17 Sep 2009 00:09:33 -0700 Subject: [PATCH] Improve 'warning-as-error handling again 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 | 29 ++++++++++++++++++++--------- scm/lily.scm | 5 ----- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lily/general-scheme.cc b/lily/general-scheme.cc index 5d4901f7bf..740c2f349c 100644 --- a/lily/general-scheme.cc +++ b/lily/general-scheme.cc @@ -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 @@ -14,18 +14,19 @@ #include /* 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; } diff --git a/scm/lily.scm b/scm/lily.scm index 783679ca04..19b5104f4b 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -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) -- 2.39.2