From f843a090cdda120d58f968b7936bdcc53b61e323 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 20 Nov 2014 03:51:56 +0100 Subject: throw error when macro returns with an unterminated command it was not possible to inherit the parser state of the last command in a macro. However, it was possible to exit the macro when its last command was not properly terminated. There is no useful conscious application of this behaviour. * If something like an uncomplete E-Command was last in the macro, there was absolutely no effect. However this points to a macro programming error. * If the last command started a string parameter but did not terminate it, the command might be (partially) executed. However the State's done() method wasn't called, which means that some commands will not execute at all. Again there's no useful application of this. When on the other hand, the last command was not terminated by accident, this was not reported to the user. --- src/parser.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/parser.cpp') diff --git a/src/parser.cpp b/src/parser.cpp index 90447d4..0b11721 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -145,6 +145,7 @@ Execute::macro(const gchar *macro, bool locals) try { step(macro, strlen(macro)); + if (Goto::skip_label) { Error error("Label \"%s\" not found", Goto::skip_label); @@ -153,6 +154,18 @@ Execute::macro(const gchar *macro, bool locals) error.line, error.column); throw error; } + + if (States::current != &States::start) { + Error error("Unterminated command"); + /* + * can only happen if we returned because + * of macro end + */ + error.pos = strlen(macro); + String::get_coord(macro, error.pos, + error.line, error.column); + throw error; + } } catch (...) { g_free(Goto::skip_label); Goto::skip_label = NULL; -- cgit v1.2.3