]> git.donarmstrong.com Git - lilypond.git/commitdiff
Use (ly:set-option 'safe #t) for setting safe behavior.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 2 Jan 2007 22:42:47 +0000 (23:42 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 2 Jan 2007 22:42:47 +0000 (23:42 +0100)
- Add ly:all-options
- Add be_safe_global to ly_set_option
- Restore all ly:set-option after running file

input/regression/safe.ly
lily/main.cc
lily/program-option.cc
ly/init.ly
scm/lily.scm

index 88d54bd279be9587090cf3f97469bdb84f351711..a04b1303cd79a5573ad3bceb534bc84785502c58 100644 (file)
@@ -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  
 
index 5aba63d78d255a480a88ed7cf9e5f777d82901bd..b9e1ce28ea591c42843a9a99beba7b06b7d5d81f 100644 (file)
@@ -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";
 
index 02213e4c71a68d1cfdddc2276e7e1b35580f36bd..8399cef9d5f042d2c269ba21b9e7ffc29780fabc 100644 (file)
@@ -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)
 {
index 091ae681949b403568838ad94af089a4bca5ca61..2f718ed93d1efcd1965646ecc0146ec9162af7dc 100644 (file)
@@ -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
index 4c61a2757ae453a8021d7db8c3955d4b40abc342..dfa5120c7766f32fe3347a5d8d13bd0ae3d1f6d0 100644 (file)
@@ -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)