From 4251775d3b5fdec23761572313aa95e4f4543375 Mon Sep 17 00:00:00 2001 From: Marius Kintel Date: Mon, 12 Dec 2011 21:53:21 +0100 Subject: bugfix: Make include also search librarydir 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 + 1) include + 2) include + */ 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)); } /*! -- cgit v0.10.1