From 6dbf365f144df4a55294244b1a1cd6f679992456 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 19 Nov 2012 13:02:45 +0100 Subject: cleanup strings[0] before invoking done(): can only be a preliminary solution --- parser.cpp | 16 +++++++++------- qbuffers.cpp | 4 +++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/parser.cpp b/parser.cpp index 864eba0..049711f 100644 --- a/parser.cpp +++ b/parser.cpp @@ -13,7 +13,7 @@ #include "qbuffers.h" #include "parser.h" -#define DEBUG +//#define DEBUG gint macro_pc = 0; @@ -49,9 +49,9 @@ macro_execute(const gchar *macro) throw (State::Error) { while (macro[macro_pc]) { #ifdef DEBUG - g_printf("EXEC(%d): input='%c'/%x, state=%p\n", + g_printf("EXEC(%d): input='%c'/%x, state=%p, mode=%d\n", macro_pc, macro[macro_pc], macro[macro_pc], - States::current); + States::current, mode); #endif State::input(macro[macro_pc]); @@ -267,13 +267,15 @@ StateExpectString::custom(gchar chr) throw (Error) } if (g_ascii_toupper(chr) == escape_char) { - State *next = done(strings[0] ? : ""); + gchar *string = strings[0]; + undo.push_str(strings[0]); + strings[0] = NULL; + + State *next = done(string ? : ""); + g_free(string); undo.push_var(escape_char); escape_char = '\x1B'; - undo.push_str(strings[0]); - g_free(strings[0]); - strings[0] = NULL; undo.push_var(machine); machine.state = Machine::STATE_START; diff --git a/qbuffers.cpp b/qbuffers.cpp index 356823b..61eacd3 100644 --- a/qbuffers.cpp +++ b/qbuffers.cpp @@ -369,7 +369,7 @@ Ring::edit(const gchar *filename) * Execute file load hook * FIXME: should be configurable whether it is executed or not */ - //qregisters["0"]->execute(); + qregisters["0"]->execute(); return new_in_ring; } @@ -518,6 +518,8 @@ Ring::close(void) if (current) { current->edit(); + + qregisters["0"]->execute(); } else { edit(NULL); undo_close(); -- cgit v1.2.3