diff --git a/src/lexer.l b/src/lexer.l index 9e8aaf85..932711ba 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -202,6 +202,7 @@ void includefile() yyin = fopen(finfo.absoluteFilePath().toLocal8Bit(), "r"); if (!yyin) { PRINTA("WARNING: Can't open input file `%1'.", filename); + path_stack.pop(); return; } filename.clear(); diff --git a/testdata/scad/include test6.scad b/testdata/scad/include test6.scad new file mode 100644 index 00000000..7a794560 --- /dev/null +++ b/testdata/scad/include test6.scad @@ -0,0 +1,4 @@ +module test6() +{ + echo("included from include test6.scad"); +} diff --git a/testdata/scad/include-test.scad b/testdata/scad/include-test.scad new file mode 100644 index 00000000..5db02d73 --- /dev/null +++ b/testdata/scad/include-test.scad @@ -0,0 +1,40 @@ +//Test that the entire path is pushed onto the stack upto the last '/' +include + +//Test that a non existent path/file doesn't screw things up +include + +//Test with empty path +include + +//Test without preceeding space +include + +//Test with other strange character that is allowed +include>>>>> + +//Test that filenames with spaces work +include + +//Test with empty file +include + +//Test with empty path and file +include + +//Test with empty +include <> + +module test1() +{ + test2(); + test3(); + test4(); + test5(); + test6(); + + //Just to give a top level object + sphere(1); +} + +test1(); diff --git a/testdata/scad/include-test5.scad b/testdata/scad/include-test5.scad new file mode 100644 index 00000000..4f6e6560 --- /dev/null +++ b/testdata/scad/include-test5.scad @@ -0,0 +1,4 @@ +module test5() +{ + echo("included from include-test5.scad"); +} diff --git a/testdata/scad/string-test.scad b/testdata/scad/string-test.scad new file mode 100644 index 00000000..5ec4cfb4 --- /dev/null +++ b/testdata/scad/string-test.scad @@ -0,0 +1 @@ +echo("The quick brown fox \tjumps \"over\" the lazy dog.\rThe quick brown fox.\nThe \\lazy\\ dog."); diff --git a/testdata/scad/sub1/sub2/sub3/include-test4.scad b/testdata/scad/sub1/sub2/sub3/include-test4.scad new file mode 100644 index 00000000..1cb7eab2 --- /dev/null +++ b/testdata/scad/sub1/sub2/sub3/include-test4.scad @@ -0,0 +1,4 @@ +module test4() +{ + echo("included from include-test4.scad"); +} diff --git a/testdata/scad/sub1/sub2/sub3/sub4/include-test2.scad b/testdata/scad/sub1/sub2/sub3/sub4/include-test2.scad new file mode 100644 index 00000000..9f4c9632 --- /dev/null +++ b/testdata/scad/sub1/sub2/sub3/sub4/include-test2.scad @@ -0,0 +1,10 @@ +//Test nested include +include + +//Test relative file location +include <../include-test4.scad> + +module test2 () +{ + echo("included from include-test2.scad"); +} diff --git a/testdata/scad/sub1/sub2/sub3/sub4/include-test3.scad b/testdata/scad/sub1/sub2/sub3/sub4/include-test3.scad new file mode 100644 index 00000000..2f67e933 --- /dev/null +++ b/testdata/scad/sub1/sub2/sub3/sub4/include-test3.scad @@ -0,0 +1,4 @@ +module test3() +{ + echo("included from include-test3.scad"); +}