In lexer.ll, assumptions about the depth of include_stack_ were hardwired
that only were valid for parsers started from the normal chain of input.
One consequence was that something like
#{ \book { \include "line-arrows.ly" } #}
worked even in safe mode (where \include should be prohibited) but
might complain about unexpected EOF. This commit adds a member
variable main_input_level to Lily_lexer for keeping track of when to
drop restrictions and deliver EOF in each parser separately.
SCM *lexval_;
Input *lexloc_;
bool is_main_input_;
+ vsize main_input_level_;
Sources *sources_;
<INITIAL,chords,lyrics,notes,figures>\\maininput {
- if (!is_main_input_ && include_stack_.size () == 1)
+ if (!is_main_input_)
{
start_main_input ();
+ main_input_level_ = include_stack_.size ();
is_main_input_ = true;
}
else
yylval = SCM_UNSPECIFIED;
if (is_main_input_)
{
- /* 2 = init.ly + current file.
- > because we're before closing, but is_main_input_ should
- reflect after.
- */
- is_main_input_ = include_stack_.size () > 2;
+ is_main_input_ = include_stack_.size () > main_input_level_;
+ if (!is_main_input_)
+ main_input_level_ = 0;
if (!close_input () || !is_main_input_)
/* Returns YY_NULL */
yyterminate ();
scopes_ = SCM_EOL;
error_level_ = 0;
is_main_input_ = false;
+ main_input_level_ = 0;
start_module_ = SCM_EOL;
extra_tokens_ = SCM_EOL;
smobify_self ();
error_level_ = 0;
is_main_input_ = src.is_main_input_;
+ main_input_level_ = 0;
extra_tokens_ = SCM_EOL;