aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--TODO1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/cmdline.cpp5
-rw-r--r--src/error.cpp166
-rw-r--r--src/error.h168
-rw-r--r--src/expressions.cpp10
-rw-r--r--src/expressions.h4
-rw-r--r--src/main.cpp7
-rw-r--r--src/parser.cpp96
-rw-r--r--src/parser.h191
-rw-r--r--src/qregisters.cpp9
-rw-r--r--src/ring.cpp3
-rw-r--r--src/search.cpp1
-rw-r--r--src/spawn.cpp5
-rw-r--r--src/spawn.h2
15 files changed, 375 insertions, 294 deletions
diff --git a/TODO b/TODO
index ddb3437..902abec 100644
--- a/TODO
+++ b/TODO
@@ -41,7 +41,6 @@ Features:
like teco.ini is found): perhaps by introducing special characters
in the default SCITECOPATH or hardcoding the defaults
* automatic EOL detection of buffers; easy EOL setting
- * refactor State::Error into separate C file and namespace
Optimizations:
* prevent command-line flickering when using function key macros.
diff --git a/src/Makefile.am b/src/Makefile.am
index 53a2b85..60346bd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -20,6 +20,7 @@ EXTRA_DIST = gtk-info-popup.gob \
noinst_LIBRARIES = libsciteco-base.a
libsciteco_base_a_SOURCES = main.cpp sciteco.h \
+ error.cpp error.h \
cmdline.cpp cmdline.h \
undo.cpp undo.h \
expressions.cpp expressions.h \
diff --git a/src/cmdline.cpp b/src/cmdline.cpp
index e19b3c4..52427b8 100644
--- a/src/cmdline.cpp
+++ b/src/cmdline.cpp
@@ -37,6 +37,7 @@
#include "undo.h"
#include "symbols.h"
#include "spawn.h"
+#include "error.h"
#include "cmdline.h"
namespace SciTECO {
@@ -100,8 +101,8 @@ cmdline_keypress(gchar key)
cmdline_pos = repl_pos = r.pos;
macro_pc = r.pos-1;
continue;
- } catch (State::Error &error) {
- error.add_frame(new State::Error::ToplevelFrame());
+ } catch (Error &error) {
+ error.add_frame(new Error::ToplevelFrame());
error.display_short();
if (old_cmdline) {
diff --git a/src/error.cpp b/src/error.cpp
new file mode 100644
index 0000000..a76d0e1
--- /dev/null
+++ b/src/error.cpp
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2012-2014 Robin Haberkorn
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdarg.h>
+
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "sciteco.h"
+#include "qregisters.h"
+#include "interface.h"
+#include "cmdline.h"
+
+namespace SciTECO {
+
+ReplaceCmdline::ReplaceCmdline()
+{
+ QRegister *cmdline_reg = QRegisters::globals["\x1B"];
+
+ new_cmdline = cmdline_reg->get_string();
+ for (pos = 0; cmdline[pos] && cmdline[pos] == new_cmdline[pos]; pos++);
+ pos++;
+}
+
+Error::Frame *
+Error::QRegFrame::copy() const
+{
+ Frame *frame = new QRegFrame(name);
+
+ frame->pos = pos;
+ frame->line = line;
+ frame->column = column;
+
+ return frame;
+}
+
+void
+Error::QRegFrame::display(gint nr)
+{
+ interface.msg(Interface::MSG_INFO,
+ "#%d in Q-Register \"%s\" at %d (%d:%d)",
+ nr, name, pos, line, column);
+}
+
+Error::Frame *
+Error::FileFrame::copy() const
+{
+ Frame *frame = new FileFrame(name);
+
+ frame->pos = pos;
+ frame->line = line;
+ frame->column = column;
+
+ return frame;
+}
+
+void
+Error::FileFrame::display(gint nr)
+{
+ interface.msg(Interface::MSG_INFO,
+ "#%d in file \"%s\" at %d (%d:%d)",
+ nr, name, pos, line, column);
+}
+
+Error::Frame *
+Error::ToplevelFrame::copy() const
+{
+ Frame *frame = new ToplevelFrame;
+
+ frame->pos = pos;
+ frame->line = line;
+ frame->column = column;
+
+ return frame;
+}
+
+void
+Error::ToplevelFrame::display(gint nr)
+{
+ interface.msg(Interface::MSG_INFO,
+ "#%d in toplevel macro at %d (%d:%d)",
+ nr, pos, line, column);
+}
+
+Error::Error(const gchar *fmt, ...)
+ : frames(NULL), pos(0), line(0), column(0)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ description = g_strdup_vprintf(fmt, ap);
+ va_end(ap);
+}
+
+Error::Error(const Error &inst)
+ : description(g_strdup(inst.description)),
+ pos(inst.pos), line(inst.line), column(inst.column)
+{
+ /* shallow copy of the frames */
+ frames = g_slist_copy(inst.frames);
+
+ for (GSList *cur = frames; cur; cur = g_slist_next(cur)) {
+ Frame *frame = (Frame *)cur->data;
+ cur->data = frame->copy();
+ }
+}
+
+void
+Error::add_frame(Frame *frame)
+{
+ frame->pos = pos;
+ frame->line = line;
+ frame->column = column;
+
+ frames = g_slist_prepend(frames, frame);
+}
+
+void
+Error::display_short(void)
+{
+ interface.msg(Interface::MSG_ERROR,
+ "%s (at %d)", description, pos);
+}
+
+void
+Error::display_full(void)
+{
+ gint nr = 0;
+
+ interface.msg(Interface::MSG_ERROR, "%s", description);
+
+ frames = g_slist_reverse(frames);
+ for (GSList *cur = frames; cur; cur = g_slist_next(cur)) {
+ Frame *frame = (Frame *)cur->data;
+
+ frame->display(nr++);
+ }
+}
+
+Error::~Error()
+{
+ g_free(description);
+ for (GSList *cur = frames; cur; cur = g_slist_next(cur))
+ delete (Frame *)cur->data;
+ g_slist_free(frames);
+}
+
+} /* namespace SciTECO */
diff --git a/src/error.h b/src/error.h
new file mode 100644
index 0000000..2786929
--- /dev/null
+++ b/src/error.h
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2012-2014 Robin Haberkorn
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __ERROR_H
+#define __ERROR_H
+
+#include <exception>
+#include <typeinfo>
+
+#include <glib.h>
+#include <glib/gprintf.h>
+
+#include "sciteco.h"
+
+namespace SciTECO {
+
+/* thrown as exception, executed at cmdline macro level */
+class ReplaceCmdline {
+public:
+ gchar *new_cmdline;
+ gint pos;
+
+ ReplaceCmdline();
+};
+
+class Error {
+ gchar *description;
+ GSList *frames;
+
+public:
+ gint pos;
+ gint line, column;
+
+ class Frame {
+ public:
+ gint pos;
+ gint line, column;
+
+ virtual Frame *copy() const = 0;
+ virtual ~Frame() {}
+
+ virtual void display(gint nr) = 0;
+ };
+
+ class QRegFrame : public Frame {
+ gchar *name;
+
+ public:
+ QRegFrame(const gchar *_name)
+ : name(g_strdup(_name)) {}
+
+ Frame *copy() const;
+
+ ~QRegFrame()
+ {
+ g_free(name);
+ }
+
+ void display(gint nr);
+ };
+
+ class FileFrame : public Frame {
+ gchar *name;
+
+ public:
+ FileFrame(const gchar *_name)
+ : name(g_strdup(_name)) {}
+
+ Frame *copy() const;
+
+ ~FileFrame()
+ {
+ g_free(name);
+ }
+
+ void display(gint nr);
+ };
+
+ class ToplevelFrame : public Frame {
+ public:
+ Frame *copy() const;
+
+ void display(gint nr);
+ };
+
+ Error(const gchar *fmt, ...) G_GNUC_PRINTF(2, 3);
+ Error(const Error &inst);
+ ~Error();
+
+ void add_frame(Frame *frame);
+
+ void display_short(void);
+ void display_full(void);
+};
+
+class StdError : public Error {
+public:
+ StdError(const gchar *type, const std::exception &error)
+ : Error("%s: %s", type, error.what()) {}
+ StdError(const std::exception &error)
+ : Error("%s: %s", typeid(error).name(), error.what()) {}
+};
+
+class GlibError : public Error {
+public:
+ GlibError(const GError *gerror)
+ : Error("%s", gerror->message) {}
+};
+
+class SyntaxError : public Error {
+public:
+ SyntaxError(gchar chr)
+ : Error("Syntax error \"%c\" (%d)", chr, chr) {}
+};
+
+class ArgExpectedError : public Error {
+public:
+ ArgExpectedError(const gchar *cmd)
+ : Error("Argument expected for <%s>", cmd) {}
+ ArgExpectedError(gchar cmd)
+ : Error("Argument expected for <%c>", cmd) {}
+};
+
+class MoveError : public Error {
+public:
+ MoveError(const gchar *cmd)
+ : Error("Attempt to move pointer off page with <%s>",
+ cmd) {}
+ MoveError(gchar cmd)
+ : Error("Attempt to move pointer off page with <%c>",
+ cmd) {}
+};
+
+class RangeError : public Error {
+public:
+ RangeError(const gchar *cmd)
+ : Error("Invalid range specified for <%s>", cmd) {}
+ RangeError(gchar cmd)
+ : Error("Invalid range specified for <%c>", cmd) {}
+};
+
+class InvalidQRegError : public Error {
+public:
+ InvalidQRegError(const gchar *name, bool local = false)
+ : Error("Invalid Q-Register \"%s%s\"",
+ local ? "." : "", name) {}
+ InvalidQRegError(gchar name, bool local = false)
+ : Error("Invalid Q-Register \"%s%c\"",
+ local ? "." : "", name) {}
+};
+
+} /* namespace SciTECO */
+
+#endif
diff --git a/src/expressions.cpp b/src/expressions.cpp
index 5bad38a..f8a81da 100644
--- a/src/expressions.cpp
+++ b/src/expressions.cpp
@@ -23,7 +23,7 @@
#include "sciteco.h"
#include "undo.h"
-#include "parser.h" // State::Error
+#include "error.h"
#include "expressions.h"
namespace SciTECO {
@@ -137,11 +137,11 @@ Expressions::calc(void)
tecoInt vleft;
if (operators.peek() != OP_NUMBER)
- throw State::Error("Missing right operand");
+ throw Error("Missing right operand");
vright = pop_num();
op = pop_op();
if (operators.peek() != OP_NUMBER)
- throw State::Error("Missing left operand");
+ throw Error("Missing left operand");
vleft = pop_num();
switch (op) {
@@ -153,12 +153,12 @@ Expressions::calc(void)
break;
case OP_DIV:
if (!vright)
- throw State::Error("Division by zero");
+ throw Error("Division by zero");
result = vleft / vright;
break;
case OP_MOD:
if (!vright)
- throw State::Error("Remainder of division by zero");
+ throw Error("Remainder of division by zero");
result = vleft % vright;
break;
case OP_ADD:
diff --git a/src/expressions.h b/src/expressions.h
index 1e61ab8..8e690e8 100644
--- a/src/expressions.h
+++ b/src/expressions.h
@@ -21,7 +21,7 @@
#include <glib.h>
#include "undo.h"
-#include "parser.h" // State::Error
+#include "error.h"
namespace SciTECO {
@@ -87,7 +87,7 @@ public:
push(Type value, int index = 1)
{
if (items() == size)
- throw State::Error("Stack overflow");
+ throw Error("Stack overflow");
for (int i = -index + 1; i; i++)
top[i+1] = top[i];
diff --git a/src/main.cpp b/src/main.cpp
index 9300b40..ed46747 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -41,6 +41,7 @@
#include "qregisters.h"
#include "ring.h"
#include "undo.h"
+#include "error.h"
namespace SciTECO {
@@ -360,8 +361,8 @@ main(int argc, char **argv)
if (eval_macro) {
try {
Execute::macro(eval_macro, false);
- } catch (State::Error &error) {
- error.add_frame(new State::Error::ToplevelFrame());
+ } catch (Error &error) {
+ error.add_frame(new Error::ToplevelFrame());
throw; /* forward */
}
exit(EXIT_SUCCESS);
@@ -377,7 +378,7 @@ main(int argc, char **argv)
}
}
g_free(mung_file);
- } catch (State::Error &error) {
+ } catch (Error &error) {
error.display_full();
exit(EXIT_FAILURE);
} catch (...) {
diff --git a/src/parser.cpp b/src/parser.cpp
index 83638fc..24d48c2 100644
--- a/src/parser.cpp
+++ b/src/parser.cpp
@@ -19,7 +19,6 @@
#include "config.h"
#endif
-#include <stdarg.h>
#include <string.h>
#include <exception>
@@ -39,6 +38,7 @@
#include "search.h"
#include "spawn.h"
#include "cmdline.h"
+#include "error.h"
namespace SciTECO {
@@ -77,11 +77,11 @@ gchar escape_char = '\x1B';
/*
* handles all expected exceptions, converting them to
- * State::Error and preparing them for stack frame insertion
+ * SciTECO::Error and preparing them for stack frame insertion
*/
void
Execute::step(const gchar *macro, gint stop_pos)
- throw (State::Error, ReplaceCmdline)
+ throw (Error, ReplaceCmdline)
{
while (macro_pc < stop_pos) {
#ifdef DEBUG
@@ -97,13 +97,13 @@ Execute::step(const gchar *macro, gint stop_pos)
*/
try {
if (interface.is_interrupted())
- throw State::Error("Interrupted");
+ throw Error("Interrupted");
State::input(macro[macro_pc]);
} catch (std::exception &error) {
- throw State::StdError(error);
+ throw StdError(error);
}
- } catch (State::Error &error) {
+ } catch (Error &error) {
error.pos = macro_pc;
String::get_coord(macro, error.pos,
error.line, error.column);
@@ -114,7 +114,7 @@ Execute::step(const gchar *macro, gint stop_pos)
}
/*
- * may throw non State::Error exceptions which are not to be
+ * may throw non SciTECO::Error exceptions which are not to be
* associated with the macro invocation stack frame
*/
void
@@ -146,8 +146,8 @@ Execute::macro(const gchar *macro, bool locals)
try {
step(macro, strlen(macro));
if (Goto::skip_label) {
- State::Error error("Label \"%s\" not found",
- Goto::skip_label);
+ Error error("Label \"%s\" not found",
+ Goto::skip_label);
error.pos = strlen(macro);
String::get_coord(macro, error.pos,
error.line, error.column);
@@ -186,7 +186,7 @@ Execute::file(const gchar *filename, bool locals)
gchar *macro_str, *p;
if (!g_file_get_contents(filename, &macro_str, NULL, &gerror))
- throw State::GError(gerror);
+ throw GlibError(gerror);
/* only when executing files, ignore Hash-Bang line */
if (*macro_str == '#')
p = MAX(strchr(macro_str, '\r'), strchr(macro_str, '\n'))+1;
@@ -195,11 +195,11 @@ Execute::file(const gchar *filename, bool locals)
try {
macro(p, locals);
- } catch (State::Error &error) {
+ } catch (Error &error) {
error.pos += p - macro_str;
if (*macro_str == '#')
error.line++;
- error.add_frame(new State::Error::FileFrame(filename));
+ error.add_frame(new Error::FileFrame(filename));
g_free(macro_str);
throw; /* forward */
@@ -211,78 +211,6 @@ Execute::file(const gchar *filename, bool locals)
g_free(macro_str);
}
-ReplaceCmdline::ReplaceCmdline()
-{
- QRegister *cmdline_reg = QRegisters::globals["\x1B"];
-
- new_cmdline = cmdline_reg->get_string();
- for (pos = 0; cmdline[pos] && cmdline[pos] == new_cmdline[pos]; pos++);
- pos++;
-}
-
-State::Error::Error(const gchar *fmt, ...)
- : frames(NULL), pos(0), line(0), column(0)
-{
- va_list ap;
-
- va_start(ap, fmt);
- description = g_strdup_vprintf(fmt, ap);
- va_end(ap);
-}
-
-State::Error::Error(const Error &inst)
- : description(g_strdup(inst.description)),
- pos(inst.pos), line(inst.line), column(inst.column)
-{
- /* shallow copy of the frames */
- frames = g_slist_copy(inst.frames);
-
- for (GSList *cur = frames; cur; cur = g_slist_next(cur)) {
- Frame *frame = (Frame *)cur->data;
- cur->data = frame->copy();
- }
-}
-
-void
-State::Error::add_frame(Frame *frame)
-{
- frame->pos = pos;
- frame->line = line;
- frame->column = column;
-
- frames = g_slist_prepend(frames, frame);
-}
-
-void
-State::Error::display_short(void)
-{
- interface.msg(Interface::MSG_ERROR,
- "%s (at %d)", description, pos);
-}
-
-void
-State::Error::display_full(void)
-{
- gint nr = 0;
-
- interface.msg(Interface::MSG_ERROR, "%s", description);
-
- frames = g_slist_reverse(frames);
- for (GSList *cur = frames; cur; cur = g_slist_next(cur)) {
- Frame *frame = (Frame *)cur->data;
-
- frame->display(nr++);
- }
-}
-
-State::Error::~Error()
-{
- g_free(description);
- for (GSList *cur = frames; cur; cur = g_slist_next(cur))
- delete (Frame *)cur->data;
- g_slist_free(frames);
-}
-
State::State()
{
for (guint i = 0; i < G_N_ELEMENTS(transitions); i++)
diff --git a/src/parser.h b/src/parser.h
index 3505a0c..0c94ba0 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -18,13 +18,10 @@
#ifndef __PARSER_H
#define __PARSER_H
-#include <exception>
-#include <typeinfo>
-
#include <glib.h>
-#include <glib/gprintf.h>
#include "undo.h"
+#include "error.h"
#include "sciteco.h"
namespace SciTECO {
@@ -32,191 +29,7 @@ namespace SciTECO {
/* TECO uses only lower 7 bits for commands */
#define MAX_TRANSITIONS 127
-/* thrown as exception, executed at cmdline macro level */
-class ReplaceCmdline {
-public:
- gchar *new_cmdline;
- gint pos;
-
- ReplaceCmdline();
-};
-
class State {
-public:
- class Error {
- gchar *description;
- GSList *frames;
-
- public:
- gint pos;
- gint line, column;
-
- class Frame {
- public:
- gint pos;
- gint line, column;
-
- virtual Frame *copy() const = 0;
- virtual ~Frame() {}
-
- virtual void display(gint nr) = 0;
- };
-
- class QRegFrame : public Frame {
- gchar *name;
-
- public:
- QRegFrame(const gchar *_name)
- : name(g_strdup(_name)) {}
-
- Frame *
- copy() const
- {
- Frame *frame = new QRegFrame(name);
-
- frame->pos = pos;
- frame->line = line;
- frame->column = column;
-
- return frame;
- }
-
- ~QRegFrame()
- {
- g_free(name);
- }
-
- void
- display(gint nr)
- {
- interface.msg(Interface::MSG_INFO,
- "#%d in Q-Register \"%s\" at %d (%d:%d)",
- nr, name, pos, line, column);
- }
- };
-
- class FileFrame : public Frame {
- gchar *name;
-
- public:
- FileFrame(const gchar *_name)
- : name(g_strdup(_name)) {}
-
- Frame *
- copy() const
- {
- Frame *frame = new FileFrame(name);
-
- frame->pos = pos;
- frame->line = line;
- frame->column = column;
-
- return frame;
- }
-
- ~FileFrame()
- {
- g_free(name);
- }
-
- void
- display(gint nr)
- {
- interface.msg(Interface::MSG_INFO,
- "#%d in file \"%s\" at %d (%d:%d)",
- nr, name, pos, line, column);
- }
- };
-
- class ToplevelFrame : public Frame {
- public:
- Frame *
- copy() const
- {
- Frame *frame = new ToplevelFrame;
-
- frame->pos = pos;
- frame->line = line;
- frame->column = column;
-
- return frame;
- }
-
- void
- display(gint nr)
- {
- interface.msg(Interface::MSG_INFO,
- "#%d in toplevel macro at %d (%d:%d)",
- nr, pos, line, column);
- }
- };
-
- Error(const gchar *fmt, ...) G_GNUC_PRINTF(2, 3);
- Error(const Error &inst);
- ~Error();
-
- void add_frame(Frame *frame);
-
- void display_short(void);
- void display_full(void);
- };
-
- class StdError : public Error {
- public:
- StdError(const gchar *type, const std::exception &error)
- : Error("%s: %s", type, error.what()) {}
- StdError(const std::exception &error)
- : Error("%s: %s", typeid(error).name(), error.what()) {}
- };
-
- class GError : public Error {
- public:
- GError(const ::GError *gerror)
- : Error("%s", gerror->message) {}
- };
-
- class SyntaxError : public Error {
- public:
- SyntaxError(gchar chr)
- : Error("Syntax error \"%c\" (%d)", chr, chr) {}
- };
-
- class ArgExpectedError : public Error {
- public:
- ArgExpectedError(const gchar *cmd)
- : Error("Argument expected for <%s>", cmd) {}
- ArgExpectedError(gchar cmd)
- : Error("Argument expected for <%c>", cmd) {}
- };
-
- class MoveError : public Error {
- public:
- MoveError(const gchar *cmd)
- : Error("Attempt to move pointer off page with <%s>",
- cmd) {}
- MoveError(gchar cmd)
- : Error("Attempt to move pointer off page with <%c>",
- cmd) {}
- };
-
- class RangeError : public Error {
- public:
- RangeError(const gchar *cmd)
- : Error("Invalid range specified for <%s>", cmd) {}
- RangeError(gchar cmd)
- : Error("Invalid range specified for <%c>", cmd) {}
- };
-
- class InvalidQRegError : public Error {
- public:
- InvalidQRegError(const gchar *name, bool local = false)
- : Error("Invalid Q-Register \"%s%s\"",
- local ? "." : "", name) {}
- InvalidQRegError(gchar name, bool local = false)
- : Error("Invalid Q-Register \"%s%c\"",
- local ? "." : "", name) {}
- };
-
protected:
/* static transitions */
State *transitions[MAX_TRANSITIONS];
@@ -471,7 +284,7 @@ extern gchar escape_char;
namespace Execute {
void step(const gchar *macro, gint stop_pos)
- throw (State::Error, ReplaceCmdline);
+ throw (Error, ReplaceCmdline);
void macro(const gchar *macro, bool locals = true);
void file(const gchar *filename, bool locals = true);
}
diff --git a/src/qregisters.cpp b/src/qregisters.cpp
index aba5abf..fa95c80 100644
--- a/src/qregisters.cpp
+++ b/src/qregisters.cpp
@@ -35,6 +35,7 @@
#include "expressions.h"
#include "document.h"
#include "ring.h"
+#include "error.h"
#include "qregisters.h"
namespace SciTECO {
@@ -187,8 +188,8 @@ QRegister::execute(bool locals)
try {
Execute::macro(str, locals);
- } catch (State::Error &error) {
- error.add_frame(new State::Error::QRegFrame(name));
+ } catch (Error &error) {
+ error.add_frame(new Error::QRegFrame(name));
g_free(str);
throw; /* forward */
@@ -210,7 +211,7 @@ QRegister::load(const gchar *filename)
/* FIXME: prevent excessive allocations by reading file into buffer */
if (!g_file_get_contents(filename, &contents, &size, &gerror))
- throw State::GError(gerror);
+ throw GlibError(gerror);
edit();
string.reset();
@@ -434,7 +435,7 @@ done:
if (!reg) {
if (!initialize)
- throw State::InvalidQRegError(name, is_local);
+ throw InvalidQRegError(name, is_local);
reg = table.insert(name);
table.undo_remove(reg);
}
diff --git a/src/ring.cpp b/src/ring.cpp
index 19b494f..f7dc3bf 100644
--- a/src/ring.cpp
+++ b/src/ring.cpp
@@ -38,6 +38,7 @@
#include "parser.h"
#include "expressions.h"
#include "ring.h"
+#include "error.h"
#ifdef HAVE_WINDOWS_H
/* here it shouldn't cause conflicts with other headers */
@@ -134,7 +135,7 @@ Buffer::load(const gchar *filename)
GError *gerror = NULL;
if (!g_file_get_contents(filename, &contents, &size, &gerror))
- throw State::GError(gerror);
+ throw GlibError(gerror);
edit();
diff --git a/src/search.cpp b/src/search.cpp
index 999a71b..bd0802e 100644
--- a/src/search.cpp
+++ b/src/search.cpp
@@ -31,6 +31,7 @@
#include "ring.h"
#include "parser.h"
#include "search.h"
+#include "error.h"
namespace SciTECO {
diff --git a/src/spawn.cpp b/src/spawn.cpp
index fa199c6..9e8f620 100644
--- a/src/spawn.cpp
+++ b/src/spawn.cpp
@@ -28,6 +28,7 @@
#include "qregisters.h"
#include "ring.h"
#include "parser.h"
+#include "error.h"
#include "spawn.h"
namespace SciTECO {
@@ -350,7 +351,7 @@ StateExecuteCommand::done(const gchar *str)
goto gerror;
if (interface.is_interrupted())
- throw State::Error("Interrupted");
+ throw Error("Interrupted");
if (eval_colon())
expressions.push(SUCCESS);
@@ -360,7 +361,7 @@ StateExecuteCommand::done(const gchar *str)
gerror:
if (!eval_colon())
- throw GError(ctx.error);
+ throw GlibError(ctx.error);
/*
* If possible, encode process exit code
diff --git a/src/spawn.h b/src/spawn.h
index 9658d0d..5b5d822 100644
--- a/src/spawn.h
+++ b/src/spawn.h
@@ -42,7 +42,7 @@ public:
tecoInt from, to;
tecoInt start;
bool text_added;
- ::GError *error;
+ GError *error;
};
private: