mirror of https://github.com/KLayout/klayout.git
Fixed a few issues with the include implementation.
This commit is contained in:
parent
77799de043
commit
ad6809a084
|
|
@ -100,6 +100,29 @@ TEST(2_RubyInclude)
|
|||
EXPECT_EQ (console.text (), "Stop 1: m2.rb:2\nf: a_inc.rb:3\nStop 2: m2.rb:8\n");
|
||||
}
|
||||
|
||||
TEST(3_RubyInclude)
|
||||
{
|
||||
tl_assert (rba::RubyInterpreter::instance () != 0);
|
||||
|
||||
lym::Macro macro;
|
||||
|
||||
macro.set_file_path (tl::testsrc () + "/testdata/lym/m3.rb");
|
||||
macro.set_interpreter (lym::Macro::Ruby);
|
||||
macro.load ();
|
||||
|
||||
TestCollectorConsole console;
|
||||
rba::RubyInterpreter::instance ()->push_console (&console);
|
||||
try {
|
||||
EXPECT_EQ (macro.run (), 0);
|
||||
rba::RubyInterpreter::instance ()->remove_console (&console);
|
||||
} catch (...) {
|
||||
rba::RubyInterpreter::instance ()->remove_console (&console);
|
||||
throw;
|
||||
}
|
||||
|
||||
EXPECT_EQ (console.text (), "An error in " + tl::testsrc () + "/testdata/lym/b_inc.rb:3\n");
|
||||
}
|
||||
|
||||
TEST(11_DRCBasic)
|
||||
{
|
||||
tl_assert (rba::RubyInterpreter::instance () != 0);
|
||||
|
|
|
|||
|
|
@ -162,7 +162,11 @@ IncludeExpander::from_string (const std::string &s)
|
|||
|
||||
tl::Extractor ex (s.c_str ());
|
||||
|
||||
if (ex.test ("@")) {
|
||||
if (*ex == '"' || *ex == '\'') {
|
||||
|
||||
ex.read_quoted (ie.m_sections [1].first);
|
||||
|
||||
} else if (ex.test ("@")) {
|
||||
|
||||
while (! ex.at_end ()) {
|
||||
|
||||
|
|
@ -182,8 +186,7 @@ IncludeExpander::from_string (const std::string &s)
|
|||
|
||||
} else {
|
||||
|
||||
ex.read_word_or_quoted (ie.m_sections [1].first, valid_fn_chars);
|
||||
ex.expect_end ();
|
||||
ie.m_sections [1].first = s;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -454,7 +454,14 @@ TextInputStream::get_line ()
|
|||
|
||||
while (! at_end ()) {
|
||||
char c = get_char ();
|
||||
if (c == '\n' || c == 0) {
|
||||
if (c == '\n') {
|
||||
// set at_end if there is nothing after this terminal LF -> this will avoid
|
||||
// emitting an empty dummy line as the last one
|
||||
if (peek_char () == 0) {
|
||||
m_at_end = true;
|
||||
}
|
||||
break;
|
||||
} else if (c == 0) {
|
||||
break;
|
||||
} else {
|
||||
m_line_buffer += c;
|
||||
|
|
@ -475,7 +482,6 @@ TextInputStream::get_char ()
|
|||
return 0;
|
||||
} else if (*c != '\r' && *c) {
|
||||
if (*c == '\n') {
|
||||
peek_char (); // sets at_end if there is no more character
|
||||
++m_next_line;
|
||||
}
|
||||
return *c;
|
||||
|
|
@ -490,7 +496,6 @@ TextInputStream::peek_char ()
|
|||
m_line = m_next_line;
|
||||
const char *c = m_stream.get (1);
|
||||
if (c == 0) {
|
||||
m_at_end = true;
|
||||
return 0;
|
||||
} else if (*c != '\r' && *c) {
|
||||
char cc = *c;
|
||||
|
|
|
|||
Loading…
Reference in New Issue