aboutsummaryrefslogtreecommitdiffhomepage
path: root/parser.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-19 22:12:16 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-20 06:07:33 +0100
commit90f203bff189706c2dec34482475b89d0a232597 (patch)
treea13c16ca7f73b779f941e0543bcff81d97e84b4d /parser.cpp
parentb804417f36ef398f1223e439fd5ac9f2ade046eb (diff)
downloadsciteco-90f203bff189706c2dec34482475b89d0a232597.tar.gz
make goto tables local to macro invocation: they are declared on the C++ callstack since macro invocations result in nested macro_execute() calls
otherwise a macro could set labels with program counters which are invalid in other macros/the command line
Diffstat (limited to 'parser.cpp')
-rw-r--r--parser.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/parser.cpp b/parser.cpp
index 89486a1..25c940b 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -60,13 +60,18 @@ macro_execute(const gchar *macro) throw (State::Error)
}
}
+/*
+ * TODO: make this usable from other macro invocations as well
+ */
bool
file_execute(const gchar *filename)
{
gchar *macro, *p = NULL;
+ GotoTable file_goto_table;
macro_pc = 0;
States::current = &States::start;
+ goto_table = &file_goto_table;
if (!g_file_get_contents(filename, &macro, NULL, NULL))
return false;
@@ -84,6 +89,7 @@ file_execute(const gchar *filename)
macro_pc = 0;
States::current = &States::start;
+ goto_table = NULL;
return true;
}