diff options
author | Marius Kintel <marius@kintel.net> | 2011-12-19 14:41:11 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-12-19 14:41:11 (GMT) |
commit | 87ce149df2581361e8975bd1a0addf2b6ef61e3d (patch) | |
tree | c68db815a72cc767b6d51be0a57e9946c5f0a619 /src/lexer.l | |
parent | ba1f0b7489dd5fa9bdc8c44068040f13113b40d0 (diff) | |
parent | 638743e2201c6869b48857dd2db5ec01df665162 (diff) |
Merge branch 'master' into boost_filesystem
Conflicts:
boost.pri
tests/CMakeLists.txt
Diffstat (limited to 'src/lexer.l')
-rw-r--r-- | src/lexer.l | 58 |
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)); } /*! |