summaryrefslogtreecommitdiff
path: root/src/lexer.l
diff options
context:
space:
mode:
authorDon Bright <hugh.m.bright@gmail.com>2012-05-28 16:48:46 (GMT)
committerDon Bright <hugh.m.bright@gmail.com>2012-05-28 16:48:46 (GMT)
commitdd2002a81673b3875ce8c4e8a61cb10278c4eb03 (patch)
tree7aaadf1c9b12cd37a7a913d3e76256f6406fa939 /src/lexer.l
parent4381762f5aa2e6a56258618e585e1510ead88684 (diff)
parent67eb2ebe90447e966dc1e08b91c43d937c521583 (diff)
Tidy up code. Generate proper test png images. Merge branch 'master' into caliston1.
Conflicts: src/PolySetCGALEvaluator.cc
Diffstat (limited to 'src/lexer.l')
-rw-r--r--src/lexer.l19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/lexer.l b/src/lexer.l
index 5644ded..188046f 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -30,6 +30,7 @@
#include "printutils.h"
#include "parsersettings.h"
#include "parser_yacc.h"
+#include "module.h"
#include <assert.h>
#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
@@ -52,7 +53,8 @@ int lexerget_lineno(void);
static void yyunput(int, char*) __attribute__((unused));
#endif
extern const char *parser_input_buffer;
-extern const char *parser_source_path;
+extern std::string parser_source_path;
+extern Module *currmodule;
#define YY_INPUT(buf,result,max_size) { \
if (yyin && yyin != stdin) { \
@@ -119,9 +121,12 @@ use[ \t\r\n>]*"<" { BEGIN(cond_use); }
usepath = boosty::absolute(fs::path(get_librarydir()) / filename);
}
}
- handle_dep(usepath.string());
- parserlval.text = strdup(usepath.string().c_str());
- return TOK_USE;
+ /* Only accept regular files which exists */
+ if (usepath.has_parent_path() && fs::exists(usepath)) {
+ handle_dep(usepath.string());
+ parserlval.text = strdup(usepath.string().c_str());
+ return TOK_USE;
+ }
}
}
@@ -215,8 +220,10 @@ void includefile()
filepath.clear();
path_stack.push_back(finfo.parent_path());
- handle_dep(boosty::absolute(finfo).string());
- yyin = fopen(boosty::absolute(finfo).string().c_str(), "r");
+ std::string fullname = boosty::absolute(finfo).string();
+ handle_dep(fullname);
+ currmodule->registerInclude(fullname);
+ yyin = fopen(fullname.c_str(), "r");
if (!yyin) {
PRINTB("WARNING: Can't open input file '%s'.", filename);
path_stack.pop_back();
contact: Jan Huwald // Impressum