Fix #include path resolution

It's pointless to search the current working directory because it's
either the same as the .dme directory and thus shouldn't supersede the
current file, or it isn't and nothing useful is likely to be found
there.

Fixes #111.
This commit is contained in:
Tad Hardesty 2019-11-09 21:34:19 -08:00
parent e6c132d12b
commit b1fd93f5c5

View file

@ -712,10 +712,11 @@ impl<'ctx> Preprocessor<'ctx> {
let path = PathBuf::from(path.replace("\\", "/"));
for candidate in vec![
self.env_file.parent().unwrap().join(&path),
// 1. relative to file in which `#include` appears.
self.include_stack.top_file_path().parent().unwrap().join(&path),
path.clone(),
].into_iter().rev() {
// 2. relative to root `.dme` file.
self.env_file.parent().unwrap().join(&path),
] {
if !candidate.exists() {
continue;
}