Add ly:lexer-set-safe!, which sets safety for the rest of the file.
+++ /dev/null
-These examples test various non-typesetting things. Since they
-do not generate output, they are not in test/ or regression/
-
-Some (notably parse*.ly) are just error/warning generation tests
-and should remain here.
-
-Some (notably midi-*.ly) test midi output, which does not usually
-get tested in ../regression files.
-
+++ /dev/null
-\version "2.10.0"
-
-\header{
-
- texidoc = "This should not survive lilypond --safe-mode, and
- certainly not write /tmp/safe-guile.scm"
-
-}
-
-#(write "hallo" (open-file "/tmp/safe-guile.scm" "w"))
-
-\score{
- c''
-}
\ No newline at end of file
+++ /dev/null
-\version "2.10.0"
-
-\header{
-
- texidoc = "This should not survive lilypond --safe-mode"
-
-}
-
-\include "safe-ps.ly"
-
-\score{
- c''
-}
\ No newline at end of file
--- /dev/null
+\version "2.10.0"
+
+"expect-error" = ##t
+
+#(ly:lexer-set-safe! (ly:parser-lexer parser))
+
+"force-finish" = ##t
+
+\header{
+ texidoc = "This should not survive lilypond --safe-mode"
+
+ #(open-file "w")
+}
+
+
+#(open-file "/tmp/safe-guile.scm" "r")
+
+\include "this-should-fail.ly"
+
void *lexval;
Input *lexloc;
bool is_main_input_;
+ bool be_safe_;
Sources *sources_;
void parser_error (string);
void parser_error (Input const &, string);
void set_yydebug (bool);
+
+ SCM make_scope () const;
};
DECLARE_UNSMOB (Lily_parser, lily_parser);
}
<<EOF>> {
LexerError (_ ("EOF found inside a comment").c_str ());
- is_main_input_ = false;
+ is_main_input_ = false; // should be safe , can't have \include in --safe.
if (! close_input ())
yyterminate (); // can't move this, since it actually rets a YY_NULL
}
Input hi = here_input();
hi.step_forward ();
SCM sval = ly_parse_scm (hi.start (), &n, hi,
- be_safe_global && is_main_input_);
+ be_safe_ && is_main_input_);
if (sval == SCM_UNDEFINED)
{
#include "lily-lexer.hh"
LY_DEFINE(ly_lexer_keywords, "ly:lexer-keywords",
- 1,0,0, (SCM lexer),
+ 1, 0, 0, (SCM lexer),
"Return a list of (KEY . CODE) pairs, signifying the lilypond reserved words list.")
{
Lily_lexer * lex = Lily_lexer::unsmob (lexer);
return lex->keyword_list ();
}
+
+LY_DEFINE(ly_lexer_set_safe, "ly:lexer-set-safe!",
+ 1, 0, 0, (SCM lexer),
+ "Switch on safe mode for the rest of the file.")
+{
+ Lily_lexer * lex = Lily_lexer::unsmob (lexer);
+ SCM_ASSERT_TYPE(lex, lexer, SCM_ARG1, __FUNCTION__, "lily lexer");
+
+ lex->be_safe_ = true;
+ lex->allow_includes_ = false;
+
+ return SCM_UNSPECIFIED;
+}
self_scm ());
lexer_->main_input_name_ = "<string>";
- lexer_->is_main_input_ = true;
-
+ lexer_->is_main_input_ = true;
lexer_->new_input (lexer_->main_input_name_, ly_code, sources_);
SCM mod = lexer_->set_current_scope ();
{
SCM id = parser->lexer_->lookup_identifier ("$defaultheader");
if (!ly_is_module (id))
- id = ly_make_anonymous_module (be_safe_global);
+ id = parser->make_scope ();
else
{
- SCM nid = ly_make_anonymous_module (false);
- ly_module_copy(nid,id);
+ SCM nid = parser->make_scope ();
+ ly_module_copy (nid, id);
id = nid;
}
return id;
}
+
+SCM
+Lily_parser::make_scope () const
+{
+ return ly_make_anonymous_module (lexer_->be_safe_);
+}
#(if (and #t (defined? 'set-debug-cell-accesses!))
(set-debug-cell-accesses! 5000))
-#(define-public midi-debug #f)
-
-
-
-
\version "2.10.0"
\include "declarations-init.ly"