#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)
{
{
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
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)
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;