summaryrefslogtreecommitdiff
path: root/src/lexer.l
diff options
context:
space:
mode:
authorMarius Kintel <marius@kintel.net>2011-12-12 20:53:21 (GMT)
committerMarius Kintel <marius@kintel.net>2011-12-12 20:53:21 (GMT)
commit4251775d3b5fdec23761572313aa95e4f4543375 (patch)
treeb4b0110ae77c03629b7c34a9e2d95de60c4858d0 /src/lexer.l
parent67b2b8be1f89b79425cb5b2199e2890417d2e78b (diff)
bugfix: Make include also search librarydir
Diffstat (limited to 'src/lexer.l')
-rw-r--r--src/lexer.l58
1 files changed, 31 insertions, 27 deletions
diff --git a/src/lexer.l b/src/lexer.l
index 2760b07..c799028 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -200,35 +200,39 @@ QDir sourcepath()
return QDir(parser_source_path);
}
+/*
+ Rules for include <path/file>
+ 1) include <sourcepath/path/file>
+ 2) include <librarydir/path/file>
+ */
void includefile()
{
- if(filename.isEmpty())
- return;
-
- if(filepath.isEmpty()) {
- path_stack.push(sourcepath());
- } else {
- QFileInfo dirinfo(sourcepath(),filepath);
- path_stack.push(dirinfo.dir());
- filepath.clear();
- }
-
- QFileInfo finfo(sourcepath(), filename);
- if (!finfo.exists()) {
- finfo = QFileInfo(QDir(librarydir), filename);
- }
-
- handle_dep(finfo.absoluteFilePath().toStdString());
- yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r");
- if (!yyin) {
- PRINTA("WARNING: Can't open input file `%1'.", filename);
- path_stack.pop();
- return;
- }
- openfiles.append(yyin);
- filename.clear();
-
- yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE ));
+ if (filename.isEmpty()) return;
+
+ QDir dirinfo(sourcepath());
+ if (!filepath.isEmpty()) {
+ dirinfo.cd(filepath);
+ }
+
+ QFileInfo finfo(dirinfo, filename);
+ if (!finfo.exists()) {
+ finfo = QFileInfo(QFileInfo(QDir(librarydir), filepath).dir(), filename);
+ }
+
+ filepath.clear();
+ path_stack.push(dirinfo);
+
+ handle_dep(finfo.absoluteFilePath().toStdString());
+ yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r");
+ if (!yyin) {
+ PRINTA("WARNING: Can't open input file `%1'.", filename);
+ path_stack.pop();
+ return;
+ }
+ openfiles.append(yyin);
+ filename.clear();
+
+ yypush_buffer_state(yy_create_buffer(yyin, YY_BUF_SIZE));
}
/*!
contact: Jan Huwald // Impressum