]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/parse-scm.cc
Uniformize, internalize.
[lilypond.git] / lily / parse-scm.cc
index 5189f3247915697961a6f5a22e61fabbc8c59180..6c29677348409332ece79ba4e09c55aba4c1f05e 100644 (file)
@@ -3,18 +3,15 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 2004--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
+#include "parse-scm.hh"
 
-#include <stdio.h>
+#include <cstdio>
 
-#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.
 SCM
 internal_ly_parse_scm (Parse_start * ps)
 {
-  Source_file *sf =ps->start_location_.source_file_;
+  Source_file *sf = ps->start_location_.source_file_;
   SCM port = sf->get_port ();
 
-  int off = ps->start_location_.defined_str0_ - sf->to_str0 ();
+  int off = ps->start_location_.start_ - sf->to_str0 ();
   
   scm_seek (port, scm_long2num (off), scm_long2num (SEEK_SET));
   SCM from = scm_ftell (port);
@@ -38,9 +35,16 @@ internal_ly_parse_scm (Parse_start * ps)
   /* Read expression from port.  */
   if (!SCM_EOF_OBJECT_P (form = scm_read (port)))
     {
-      SCM function = ly_scheme_function ("make-safe-lilypond-module");
       if (ps->safe_)
-       answer = scm_eval (form, function);
+       {
+         static SCM module = SCM_BOOL_F;
+         if (module == SCM_BOOL_F)
+           {
+             SCM function = ly_lily_module_constant ("make-safe-lilypond-module");
+             module = scm_call_0 (function);
+           }
+         answer = scm_eval (form, module);
+       }
       else
        answer = scm_primitive_eval (form);
     }
@@ -77,7 +81,7 @@ parse_handler (void *data, SCM tag, SCM args)
   ps->start_location_.error (_("GUILE signaled an error for the expression beginning here"));
 
   if (scm_ilength (args) > 2)
-    scm_display_error_message (ly_cadr (args), ly_caddr (args), scm_current_error_port ());
+    scm_display_error_message (scm_cadr (args), scm_caddr (args), scm_current_error_port ());
 
   /*
     The following is a kludge; we should probably search for