diff options
author | John Hodge <tpg@mutabah.net> | 2017-01-15 17:27:32 +0800 |
---|---|---|
committer | John Hodge <tpg@mutabah.net> | 2017-01-15 17:27:32 +0800 |
commit | 6013db4d24e59d4827bdc2188852d58867f1bed6 (patch) | |
tree | 133ac996c8c27b838a1fa6102aea5b2551f3dafb | |
parent | c10e5de8a6134068b2e0cfd119a7b5ee980214c9 (diff) | |
download | mrust-6013db4d24e59d4827bdc2188852d58867f1bed6.tar.gz |
Expand include! - Support for absolute paths
-rw-r--r-- | src/expand/include.cpp | 5 | ||||
-rw-r--r-- | src/parse/lex.cpp | 2 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/expand/include.cpp b/src/expand/include.cpp index c41cc03b..a6eb9fe1 100644 --- a/src/expand/include.cpp +++ b/src/expand/include.cpp @@ -30,7 +30,10 @@ namespace { ::std::string get_path_relative_to(const ::std::string& base_path, ::std::string path) { - if( base_path.size() == 0 ) { + if( path[0] == '/' ) { + return path; + } + else if( base_path.size() == 0 ) { return path; } else if( base_path[base_path.size()-1] == '/' ) { diff --git a/src/parse/lex.cpp b/src/parse/lex.cpp index 5657c908..4e5b4c2d 100644 --- a/src/parse/lex.cpp +++ b/src/parse/lex.cpp @@ -25,7 +25,7 @@ Lexer::Lexer(const ::std::string& filename): { if( !m_istream.is_open() ) { - throw ::std::runtime_error("Unable to open file"); + throw ::std::runtime_error("Unable to open file '" + filename + "'"); } // Consume the BOM if( this->getc_byte() == '\xef' ) |