summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c>2010-02-01 03:11:29 (GMT)
committerkintel <kintel@b57f626f-c46c-0410-a088-ec61d464b74c>2010-02-01 03:11:29 (GMT)
commit76f0b1119f1be174ce7adbb1458d2d9a3fa30d22 (patch)
tree0c30a8720e8fd56a6a051ec3a2d2d3f61307b7e1 /src
parent17eb94bf67ae55fb3f649d99790593907b7820b0 (diff)
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-ec61d464b74c
Diffstat (limited to 'src')
-rw-r--r--src/lexer.l9
-rw-r--r--src/mainwin.cc2
-rw-r--r--src/openscad.cc6
-rw-r--r--src/openscad.h2
-rw-r--r--src/parser.y4
-rw-r--r--src/projection.cc2
6 files changed, 15 insertions, 10 deletions
diff --git a/src/lexer.l b/src/lexer.l
index c9e9332..2130948 100644
--- a/src/lexer.l
+++ b/src/lexer.l
@@ -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 {
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 9ed008a..58c539d 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -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) {
diff --git a/src/openscad.cc b/src/openscad.cc
index a86b3c0..f5bf77f 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -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);
diff --git a/src/openscad.h b/src/openscad.h
index 5e2f19c..25480bb 100644
--- a/src/openscad.h
+++ b/src/openscad.h
@@ -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>
diff --git a/src/parser.y b/src/parser.y
index 91d49cf..8d986fe 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -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();
diff --git a/src/projection.cc b/src/projection.cc
index ba8c520..3f67d21 100644
--- a/src/projection.cc
+++ b/src/projection.cc
@@ -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>
contact: Jan Huwald // Impressum