summaryrefslogtreecommitdiff
path: root/src/lexer.l
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2013-05-25 21:45:13 (GMT)
committerMarius Kintel <marius@kintel.net>2013-05-25 21:45:13 (GMT)
commitcc6ac10e47ff67fd1d4f5fb8c61fea300f163b1d (patch)
tree2226c6c1ded88cde597a6a882894dd0ae8f50320 /src/lexer.l
parent9740232b080ac3d2fe87309fb51a892faf6ea913 (diff)
Search paths when looking for previously missing includes. Should provide most of what's needed for #364
Diffstat (limited to 'src/lexer.l')
-rw-r--r--src/lexer.l25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/lexer.l b/src/lexer.l
index 0084d93..bb1664e 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -113,8 +113,8 @@ use[ \t\r\n>]*"<" { BEGIN(cond_use); }
[^\t\r\n>]+ { filename = yytext; }
">" {
BEGIN(INITIAL);
- fs::path fullpath = find_valid_path( sourcepath(), filename, openfilenames );
- if ( fullpath.empty() ) {
+ fs::path fullpath = find_valid_path(sourcepath(), fs::path(filename), &openfilenames);
+ if (fullpath.empty()) {
PRINTB("WARNING: Can't open 'use' file '%s'.", filename);
} else {
handle_dep(fullpath.string());
@@ -200,22 +200,25 @@ void includefile()
PRINTB("lex includefile filename %s",filename.c_str());
PRINTB("lex includefile filepath %s",filepath.c_str());
PRINTB("lex includefile sourcepath %s",sourcepath().c_str());
- BOOST_FOREACH(std::string of, openfilenames ) {
+ BOOST_FOREACH(std::string of, openfilenames) {
PRINTB("lex includefile openfilename: %s",of);
}
- rootmodule->registerInclude(filename);
-
- fs::path fullpath = find_valid_path( sourcepath(), filename, openfilenames );
- if ( fullpath.empty() ) {
+ fs::path localpath = fs::path(filepath) / filename;
+ fs::path fullpath = find_valid_path(sourcepath(), localpath, &openfilenames);
+ if (!fullpath.empty()) {
+ rootmodule->registerInclude(boosty::stringy(localpath), boosty::stringy(fullpath));
+ }
+ else {
+ rootmodule->registerInclude(boosty::stringy(localpath), boosty::stringy(localpath));
PRINTB("WARNING: Can't open 'include' file '%s'.", filename);
- if (path_stack.size()>0) path_stack.pop_back();
+ if (path_stack.size() > 0) path_stack.pop_back();
return;
};
- PRINTB("lex fullpath %s",fullpath );
+ PRINTB("lex fullpath %s",fullpath);
- std::string fullname = boosty::stringy( fullpath );
- PRINTB("lex fullname %s",fullname );
+ std::string fullname = boosty::stringy(fullpath);
+ PRINTB("lex fullname %s",fullname);
filepath.clear();
path_stack.push_back(fullpath.parent_path());
contact: Jan Huwald // Impressum