From 17e898abae3983e28021b0988d2fdf88365261f8 Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Wed, 31 Dec 2008 21:50:54 +1100 Subject: [PATCH] Make relative-includes configurable with a -d option. --- lily/includable-lexer.cc | 7 +++++-- lily/include/includable-lexer.hh | 1 + lily/include/lily-lexer.hh | 1 - lily/program-option-scheme.cc | 7 +++++++ scm/lily.scm | 2 ++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lily/includable-lexer.cc b/lily/includable-lexer.cc index 09b97da017..e241b66230 100644 --- a/lily/includable-lexer.cc +++ b/lily/includable-lexer.cc @@ -37,6 +37,8 @@ using namespace std; (yy_buffer_stack != 0 ? yy_buffer_stack[yy_buffer_stack_top] : 0) #endif +extern bool relative_includes; + Includable_lexer::Includable_lexer () { #if HAVE_FLEXLEXER_YY_CURRENT_BUFFER @@ -48,8 +50,9 @@ Includable_lexer::Includable_lexer () void Includable_lexer::new_input (string name, Sources *sources) { - string current_dir = include_stack_.size () ? - dir_name (include_stack_.back ()->name_string ()) : ""; + string current_dir = dir_name (main_input_name_); + if (relative_includes) + current_dir = include_stack_.size () ? dir_name (include_stack_.back ()->name_string ()) : ""; Source_file *file = sources->get_file (name, current_dir); if (!file) diff --git a/lily/include/includable-lexer.hh b/lily/include/includable-lexer.hh index 1e35012f33..f5d0d44a71 100644 --- a/lily/include/includable-lexer.hh +++ b/lily/include/includable-lexer.hh @@ -36,6 +36,7 @@ public: Includable_lexer (); ~Includable_lexer (); + string main_input_name_; /// store dependencies for Makefile stuff. vector file_name_strings_; diff --git a/lily/include/lily-lexer.hh b/lily/include/lily-lexer.hh index 83a9f89b93..284e5636c6 100644 --- a/lily/include/lily-lexer.hh +++ b/lily/include/lily-lexer.hh @@ -38,7 +38,6 @@ private: int hidden_state_; public: vector extra_token_types_; - string main_input_name_; void *lexval; Input *lexloc; bool is_main_input_; diff --git a/lily/program-option-scheme.cc b/lily/program-option-scheme.cc index 1dd74ff69e..d68af75ab1 100644 --- a/lily/program-option-scheme.cc +++ b/lily/program-option-scheme.cc @@ -23,6 +23,8 @@ bool debug_skylines; bool debug_property_callbacks; bool debug_page_breaking_scoring; +bool relative_includes; + /* Backwards compatibility. */ @@ -103,6 +105,11 @@ void internal_set_option (SCM var, SCM val) /* ignore input value. */ val = ly_string2scm (lilypond_datadir); } + else if (var == ly_symbol2scm ("relative-includes")) + { + relative_includes = to_boolean (val); + val = scm_from_bool (to_boolean (val)); + } scm_hashq_set_x (option_hash, var, val); diff --git a/scm/lily.scm b/scm/lily.scm index bddb9982a7..2c1eb188e6 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -80,6 +80,8 @@ on errors, and print a stack trace.") (resolution 101 "resolution for generating PNG bitmaps") (read-file-list #f "Read files to be processed from command line arguments") + (relative-includes #f "When processing an \\include command, look for the included file +relative to the current file (instead of the root file)") (safe #f "Run safely") (strict-infinity-checking #f "If yes, crash on encountering Inf/NaN.") -- 2.39.2