mirror of https://github.com/vitalif/openscad
bugfix: In MDI mode, the parser must know which file it compiles, not just the contents, for inluded files to be found. Made the parser Qt-dependant - oh well...
git-svn-id: http://svn.clifford.at/openscad/trunk@395 b57f626f-c46c-0410-a088-ec61d464b74cstl_dim
parent
17eb94bf67
commit
76f0b1119f
|
@ -23,12 +23,15 @@
|
|||
#include "openscad.h"
|
||||
#include "printutils.h"
|
||||
#include "parser_yacc.h"
|
||||
#include <QFileInfo>
|
||||
#include <QDir>
|
||||
|
||||
int lexerget_lineno(void);
|
||||
#ifdef __GNUC__
|
||||
static void yyunput(int, char*) __attribute__((unused));
|
||||
#endif
|
||||
extern const char *parser_input_buffer;
|
||||
extern const char *parser_source_path;
|
||||
|
||||
#define YY_INPUT(buf,result,max_size) { \
|
||||
if (yyin && yyin != stdin) { \
|
||||
|
@ -62,8 +65,10 @@ extern const char *parser_input_buffer;
|
|||
"<"[^ \t\n>]+">" {
|
||||
char *filename = strdup(yytext+1);
|
||||
filename[strlen(filename)-1] = 0;
|
||||
handle_dep(filename);
|
||||
yyin = fopen(filename, "r");
|
||||
QFileInfo finfo(QDir(parser_source_path), filename);
|
||||
|
||||
handle_dep(finfo.absoluteFilePath());
|
||||
yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r");
|
||||
if (!yyin) {
|
||||
PRINTF("WARNING: Can't open input file `%s'.", filename);
|
||||
} else {
|
||||
|
|
|
@ -530,7 +530,7 @@ void MainWindow::compile(bool procevents)
|
|||
|
||||
// Parse
|
||||
last_compiled_doc = editor->toPlainText();
|
||||
root_module = parse((last_compiled_doc + "\n" + commandline_commands).toAscii().data(), false);
|
||||
root_module = parse((last_compiled_doc + "\n" + commandline_commands).toAscii().data(), this->fileName.isEmpty() ? "" : QFileInfo(this->fileName).absolutePath().toLocal8Bit(), false);
|
||||
|
||||
// Error highlighting
|
||||
if (highlighter) {
|
||||
|
|
|
@ -181,6 +181,7 @@ int main(int argc, char **argv)
|
|||
ModuleInstantiation root_inst;
|
||||
AbstractNode *root_node;
|
||||
|
||||
QFileInfo fileInfo(filename);
|
||||
handle_dep(filename);
|
||||
FILE *fp = fopen(filename, "rt");
|
||||
if (!fp) {
|
||||
|
@ -195,12 +196,11 @@ int main(int argc, char **argv)
|
|||
text += buffer;
|
||||
}
|
||||
fclose(fp);
|
||||
root_module = parse((text+commandline_commands).toAscii().data(), false);
|
||||
root_module = parse((text+commandline_commands).toAscii().data(), fileInfo.absolutePath().toLocal8Bit(), false);
|
||||
}
|
||||
|
||||
QString original_path = QDir::currentPath();
|
||||
QFileInfo fileInfo(filename);
|
||||
QDir::setCurrent(fileInfo.dir().absolutePath());
|
||||
QDir::setCurrent(fileInfo.absolutePath());
|
||||
|
||||
AbstractNode::idx_counter = 1;
|
||||
root_node = root_module->evaluate(&root_ctx, &root_inst);
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#endif
|
||||
|
||||
|
||||
extern class AbstractModule *parse(const char *text, int debug);
|
||||
extern class AbstractModule *parse(const char *text, const char *path, int debug);
|
||||
extern int get_fragments_from_r(double r, double fn, double fs, double fa);
|
||||
|
||||
#include <QString>
|
||||
|
|
|
@ -504,12 +504,14 @@ void yyerror (char const *s)
|
|||
extern FILE *lexerin;
|
||||
extern const char *parser_input_buffer;
|
||||
const char *parser_input_buffer;
|
||||
const char *parser_source_path;
|
||||
|
||||
AbstractModule *parse(const char *text, int debug)
|
||||
AbstractModule *parse(const char *text, const char *path, int debug)
|
||||
{
|
||||
lexerin = NULL;
|
||||
parser_error_pos = -1;
|
||||
parser_input_buffer = text;
|
||||
parser_source_path = path;
|
||||
|
||||
module_stack.clear();
|
||||
module = new Module();
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
#include "dxfdata.h"
|
||||
#include "dxftess.h"
|
||||
#include "polyset.h"
|
||||
#include "export.h"
|
||||
#include "openscad.h" // get_fragments_from_r()
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
|
Loading…
Reference in New Issue