summaryrefslogtreecommitdiff
path: root/src/lexer.l
diff options
context:
space:
mode:
authordon bright <hugh.m.bright@gmail.com>2013-01-28 02:42:20 (GMT)
committerdon bright <hugh.m.bright@gmail.com>2013-01-28 02:42:20 (GMT)
commit1e64dddf1ea30282c89de7f35854a68614234652 (patch)
tree165d37c1c66f6ff79d48c74794238b3f0bed09da /src/lexer.l
parent5c779159c208ca3d88c88479ab29f9cd66574859 (diff)
parentd0856efe6da545693f9c50a8a2514a9f999ab5ef (diff)
Merge branch 'master' of github.com:openscad/openscad into issue159
Diffstat (limited to 'src/lexer.l')
-rw-r--r--src/lexer.l11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/lexer.l b/src/lexer.l
index 1e3bd5b..63b0047 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -80,6 +80,7 @@ void includefile();
fs::path sourcepath();
std::vector<fs::path> path_stack;
std::vector<FILE*> openfiles;
+std::vector<std::string> openfilenames;
std::string filename;
std::string filepath;
@@ -142,6 +143,7 @@ use[ \t\r\n>]*"<" { BEGIN(cond_use); }
assert(!openfiles.empty());
fclose(openfiles.back());
openfiles.pop_back();
+ openfilenames.pop_back();
}
yypop_buffer_state();
if (!YY_CURRENT_BUFFER)
@@ -227,10 +229,15 @@ void includefile()
PRINTB("WARNING: Can't find 'include' file '%s'.", filename);
}
+ std::string fullname = boosty::absolute(finfo).string();
+ // Detect circular includes
+ BOOST_FOREACH(std::string &s, openfilenames) {
+ if (s == fullname) return;
+ }
+
filepath.clear();
path_stack.push_back(finfo.parent_path());
- std::string fullname = boosty::absolute(finfo).string();
handle_dep(fullname);
currmodule->registerInclude(fullname);
yyin = fopen(fullname.c_str(), "r");
@@ -240,6 +247,7 @@ void includefile()
return;
}
openfiles.push_back(yyin);
+ openfilenames.push_back(fullname);
filename.clear();
yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE));
@@ -253,5 +261,6 @@ void lexerdestroy()
{
BOOST_FOREACH (FILE *f, openfiles) fclose(f);
openfiles.clear();
+ openfilenames.clear();
path_stack.clear();
}
contact: Jan Huwald // Impressum