diff options
| -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));  }  /*! | 
