From 24a671e48f7b0391dab19a01fdad4d7aa6bb9783 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 2 Jan 2007 23:42:47 +0100 Subject: [PATCH] Use (ly:set-option 'safe #t) for setting safe behavior. - Add ly:all-options - Add be_safe_global to ly_set_option - Restore all ly:set-option after running file --- input/regression/safe.ly | 4 +++- lily/main.cc | 1 - lily/program-option.cc | 13 +++++++++++++ ly/init.ly | 2 +- scm/lily.scm | 42 ++++++++++++++++++++++++---------------- 5 files changed, 42 insertions(+), 20 deletions(-) diff --git a/input/regression/safe.ly b/input/regression/safe.ly index 88d54bd279..a04b1303cd 100644 --- a/input/regression/safe.ly +++ b/input/regression/safe.ly @@ -2,7 +2,9 @@ "expect-error" = ##t -#(ly:lexer-set-safe! (ly:parser-lexer parser)) +% Ugh - this affects other files too. +#(ly:set-option 'protected-scheme-parsing #t) +#(ly:set-option 'safe #t) "force-finish" = ##t diff --git a/lily/main.cc b/lily/main.cc index 5aba63d78d..b9e1ce28ea 100644 --- a/lily/main.cc +++ b/lily/main.cc @@ -566,7 +566,6 @@ parse_argv (int argc, char **argv) be_verbose_global = true; break; case 's': - be_safe_global = true; init_scheme_variables += "(cons \'safe #t)\n"; diff --git a/lily/program-option.cc b/lily/program-option.cc index 02213e4c71..8399cef9d5 100644 --- a/lily/program-option.cc +++ b/lily/program-option.cc @@ -73,6 +73,11 @@ void internal_set_option (SCM var, SCM val) parsed_objects_should_be_dead = to_boolean (val); val = scm_from_bool (parsed_objects_should_be_dead); } + else if (var == ly_symbol2scm ("safe")) + { + be_safe_global = to_boolean (val); + val = scm_from_bool (be_safe_global); + } else if (var == ly_symbol2scm ("old-relative")) { lily_1_8_relative = to_boolean (val); @@ -216,6 +221,13 @@ LY_DEFINE (ly_command_line_verbose_p, "ly:command-line-verbose?", 0, 0, 0, (), +LY_DEFINE (ly_all_option, "ly:all-options", + 0, 0, 0, (), + "Get all option settings in an alist.") +{ + return ly_hash2alist (option_hash); +} + LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var), "Get a global option setting.") @@ -226,6 +238,7 @@ LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var), } + bool get_program_option (const char *s) { diff --git a/ly/init.ly b/ly/init.ly index 091ae68194..2f718ed93d 100644 --- a/ly/init.ly +++ b/ly/init.ly @@ -15,7 +15,7 @@ #(define $defaultheader #f) #(define version-seen #f) #(define expect-error #f) - + #(use-modules (scm clip-region)) \maininput %% there is a problem at the end of the input file diff --git a/scm/lily.scm b/scm/lily.scm index 4c61a2757a..dfa5120c77 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -580,30 +580,38 @@ The syntax is the same as `define*-public'." (let* ((failed '()) (separate-logs (ly:get-option 'separate-log-files)) - (start-measurements (ly:get-option 'dump-profile)) + (do-measurements (ly:get-option 'dump-profile)) (handler (lambda (key failed-file) (set! failed (append (list failed-file) failed))))) (for-each (lambda (x) - - (gc) - (if start-measurements - (set! start-measurements (profile-measurements))) - - (if separate-logs - (ly:stderr-redirect (format "~a.log" (basename x ".ly")) "w")) + (let* + ((start-measurements (if do-measurements + (begin + (gc) + (profile-measurements)) + #f)) + (base (basename x ".ly")) + (all-settings (ly:all-options))) + + (if separate-logs + (ly:stderr-redirect (format "~a.log" base) "w")) - (lilypond-file handler x) - (if start-measurements - (dump-profile x start-measurements (profile-measurements))) + (lilypond-file handler x) + (if start-measurements + (dump-profile x start-measurements (profile-measurements))) - - (ly:clear-anonymous-modules) - (if (ly:get-option 'debug-gc) - (dump-gc-protects) - (if (= (random 40) 1) - (ly:reset-all-fonts)))) + (for-each + (lambda (s) + (ly:set-option (car s) (cdr s))) + all-settings) + + (ly:clear-anonymous-modules) + (if (ly:get-option 'debug-gc) + (dump-gc-protects) + (if (= (random 40) 1) + (ly:reset-all-fonts))))) files) -- 2.39.5