aboutsummaryrefslogtreecommitdiffhomepage
path: root/qbuffers.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 /qbuffers.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 'qbuffers.cpp')
-rw-r--r--qbuffers.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/qbuffers.cpp b/qbuffers.cpp
index 77fefd5..26e4599 100644
--- a/qbuffers.cpp
+++ b/qbuffers.cpp
@@ -18,6 +18,7 @@
#include "undo.h"
#include "parser.h"
#include "expressions.h"
+#include "goto.h"
#include "qbuffers.h"
namespace States {
@@ -142,6 +143,9 @@ QRegister::undo_edit(void)
void
QRegister::execute(void) throw (State::Error)
{
+ GotoTable *parent_goto_table = goto_table;
+ GotoTable macro_goto_table;
+
State *parent_state = States::current;
gint parent_pc = macro_pc;
gchar *str;
@@ -156,6 +160,7 @@ QRegister::execute(void) throw (State::Error)
macro_pc = 0;
str = get_string();
+ goto_table = &macro_goto_table;
try {
macro_execute(str);
@@ -163,12 +168,14 @@ QRegister::execute(void) throw (State::Error)
g_free(str);
macro_pc = parent_pc;
States::current = parent_state;
+ goto_table = parent_goto_table;
throw; /* forward */
}
g_free(str);
macro_pc = parent_pc;
States::current = parent_state;
+ goto_table = parent_goto_table;
}
bool