]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parse-scm.cc
* input/regression/bar-check-redefine.ly (pipeSymbol): new file.
[lilypond.git] / lily / parse-scm.cc
index f909b5aa2cc8772eff0a4407cf39977d66745797..c30547f71f92fcdd90421df9461331d8411c602c 100644 (file)
@@ -1,18 +1,17 @@
 #include <stdio.h>
 
+#include "ly-module.hh"
 #include "lily-guile.hh"
+#include "main.hh"
+#include "paper-book.hh"
 #include "parse-scm.hh"
 #include "string.hh"
 #include "source-file.hh"
 
-/*
-  Pass string to scm parser, evaluate one expression.
-  Return result value and #chars read.
-
-  Thanks to Gary Houston <ghouston@freewire.co.uk>
-
-  Need guile-1.3.4 (>1.3 anyway) for ftell on str ports -- jcn
-*/
+/* Pass string to scm parser, evaluate one expression.
+   Return result value and #chars read.
+   
+   Thanks to Gary Houston <ghouston@freewire.co.uk>  */
 SCM
 internal_ly_parse_scm (Parse_start * ps, bool safe)
 {
@@ -32,7 +31,13 @@ internal_ly_parse_scm (Parse_start * ps, bool safe)
     {
       if (safe)
        {
-         SCM safe_module = scm_primitive_eval (ly_symbol2scm ("safe-module"));
+         static SCM safe_module;
+         if (!safe_module)
+           {
+             safe_module = scm_primitive_eval (ly_symbol2scm ("safe-module"));
+             if (output_format_global == PAGE_LAYOUT)
+               ly_import_module (safe_module, scm_c_resolve_module ("lily"));
+           }
          answer = scm_eval (form, safe_module);
        }
       else
@@ -72,7 +77,8 @@ SCM
 parse_handler (void * data, SCM tag, SCM args)
 {
   Parse_start* ps = (Parse_start*) data;
-
+  (void) tag;                  // prevent warning
+  
   ps->start_location_.error (_("GUILE signaled an error for the expression beginning here"));
 
   if (scm_ilength (args) > 2)
@@ -105,19 +111,16 @@ protected_ly_parse_scm (Parse_start *ps, bool safe)
   return scm_internal_catch (ly_symbol2scm (READ_ERROR),
                             (safe ? &safe_catch_protected_parse_body
                              : catch_protected_parse_body),
-                            (void*)ps,
-                            &parse_handler, (void*)ps);
+                            (void*) ps,
+                            &parse_handler, (void*) ps);
 }
 
-bool  parse_protect_global  = true; 
+bool parse_protect_global = true; 
 
-/*
-  Try parsing. If failure, then return SCM_UNDEFINED.
- */
+/* Try parsing.  Upon failure return SCM_UNDEFINED. */
 SCM
 ly_parse_scm (char const* s, int *n, Input i, bool safe)
 {
-  
   Parse_start ps ;
   ps.str = s;
   ps.start_location_ = i;