diff options
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | src/expressions.cpp | 22 | ||||
-rw-r--r-- | src/expressions.h | 14 | ||||
-rw-r--r-- | src/goto.cpp | 5 | ||||
-rw-r--r-- | src/main.cpp | 2 | ||||
-rw-r--r-- | src/parser.cpp | 34 | ||||
-rw-r--r-- | src/parser.h | 10 | ||||
-rw-r--r-- | src/qregisters.cpp | 10 | ||||
-rw-r--r-- | src/qregisters.h | 14 | ||||
-rw-r--r-- | src/ring.cpp | 10 | ||||
-rw-r--r-- | src/ring.h | 6 | ||||
-rw-r--r-- | src/sciteco.h | 15 | ||||
-rw-r--r-- | src/search.cpp | 4 |
13 files changed, 84 insertions, 68 deletions
diff --git a/configure.ac b/configure.ac index ffdebcb..49963c7 100644 --- a/configure.ac +++ b/configure.ac @@ -159,6 +159,12 @@ AC_ARG_WITH(default-scitecopath, [DEFAULT_SCITECOPATH=$withval], [DEFAULT_SCITECOPATH=$scitecolibdir]) AC_SUBST(DEFAULT_SCITECOPATH) +AC_ARG_WITH(teco-integer, + AS_HELP_STRING([--with-teco-integer=SIZE], + [Storage size of TECO integers in bits [default=64]]), + [TECO_INTEGER=$withval], [TECO_INTEGER=64]) +AC_DEFINE_UNQUOTED(TECO_INTEGER, $TECO_INTEGER, [Storage size of TECO integers]) + AC_ARG_ENABLE(bootstrap, AS_HELP_STRING([--enable-bootstrap], [Bootstrap using sciteco-minimal, diff --git a/src/expressions.cpp b/src/expressions.cpp index 8b5453f..7975d10 100644 --- a/src/expressions.cpp +++ b/src/expressions.cpp @@ -41,8 +41,8 @@ Expressions::set_radix(gint r) radix = r; } -gint64 -Expressions::push(gint64 number) +tecoInt +Expressions::push(tecoInt number) { while (operators.items() && operators.peek() == OP_NEW) pop_op(); @@ -58,10 +58,10 @@ Expressions::push(gint64 number) return numbers.push(number); } -gint64 +tecoInt Expressions::pop_num(int index) { - gint64 n = 0; + tecoInt n = 0; pop_op(); if (numbers.items() > 0) { @@ -72,8 +72,8 @@ Expressions::pop_num(int index) return n; } -gint64 -Expressions::pop_num_calc(int index, gint64 imply) +tecoInt +Expressions::pop_num_calc(int index, tecoInt imply) { eval(); if (num_sign < 0) @@ -82,10 +82,10 @@ Expressions::pop_num_calc(int index, gint64 imply) return args() > 0 ? pop_num(index) : imply; } -gint64 +tecoInt Expressions::add_digit(gchar digit) { - gint64 n = args() > 0 ? pop_num() : 0; + tecoInt n = args() > 0 ? pop_num() : 0; return push(n*radix + (n < 0 ? -1 : 1)*(digit - '0')); } @@ -125,11 +125,11 @@ Expressions::pop_op(int index) void Expressions::calc(void) { - gint64 result; + tecoInt result; - gint64 vright = pop_num(); + tecoInt vright = pop_num(); Operator op = pop_op(); - gint64 vleft = pop_num(); + tecoInt vleft = pop_num(); switch (op) { case OP_POW: for (result = 1; vright--; result *= vleft); break; diff --git a/src/expressions.h b/src/expressions.h index 8676a2e..48ce6ee 100644 --- a/src/expressions.h +++ b/src/expressions.h @@ -149,7 +149,7 @@ public: }; private: - ValueStack<gint64> numbers; + ValueStack<tecoInt> numbers; ValueStack<Operator> operators; public: @@ -161,22 +161,22 @@ public: gint radix; void set_radix(gint r); - gint64 push(gint64 number); + tecoInt push(tecoInt number); - inline gint64 + inline tecoInt peek_num(int index = 1) { return numbers.peek(index); } - gint64 pop_num(int index = 1); - gint64 pop_num_calc(int index, gint64 imply); - inline gint64 + tecoInt pop_num(int index = 1); + tecoInt pop_num_calc(int index, tecoInt imply); + inline tecoInt pop_num_calc(int index = 1) { return pop_num_calc(index, num_sign); } - gint64 add_digit(gchar digit); + tecoInt add_digit(gchar digit); Operator push(Operator op); Operator push_calc(Operator op); diff --git a/src/goto.cpp b/src/goto.cpp index 55c1ec7..4fed38b 100644 --- a/src/goto.cpp +++ b/src/goto.cpp @@ -142,7 +142,7 @@ StateLabel::custom(gchar chr) throw (Error) State * StateGotoCmd::done(const gchar *str) throw (Error) { - gint64 value; + tecoInt value; gchar **labels; BEGIN_EXEC(&States::start); @@ -150,7 +150,8 @@ StateGotoCmd::done(const gchar *str) throw (Error) value = expressions.pop_num_calc(); labels = g_strsplit(str, ",", -1); - if (value > 0 && value <= g_strv_length(labels) && *labels[value-1]) { + if (value > 0 && value <= (tecoInt)g_strv_length(labels) && + *labels[value-1]) { gint pc = Goto::table->find(labels[value-1]); if (pc >= 0) { diff --git a/src/main.cpp b/src/main.cpp index 9979ee8..3e6cedb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -48,7 +48,7 @@ #endif namespace Flags { - gint64 ed = 0; + tecoInt ed = 0; } static gchar *eval_macro = NULL; diff --git a/src/parser.cpp b/src/parser.cpp index 46bea77..729e718 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -458,9 +458,9 @@ StateStart::StateStart() : State() } void -StateStart::insert_integer(gint64 v) +StateStart::insert_integer(tecoInt v) { - gchar buf[64+1]; /* maximum length if radix = 2 */ + gchar buf[sizeof(tecoInt)*8+1]; /* maximum length if radix = 2 */ gchar *p = buf + sizeof(buf); *--p = '\0'; @@ -483,12 +483,12 @@ StateStart::insert_integer(gint64 v) undo.push_msg(SCI_UNDO); } -gint64 +tecoInt StateStart::read_integer(void) { uptr_t pos = interface.ssm(SCI_GETCURRENTPOS); gchar c = (gchar)interface.ssm(SCI_GETCHARAT, pos); - gint64 v = 0; + tecoInt v = 0; gint sign = 1; if (c == '-') { @@ -513,7 +513,7 @@ StateStart::read_integer(void) } tecoBool -StateStart::move_chars(gint64 n) +StateStart::move_chars(tecoInt n) { sptr_t pos = interface.ssm(SCI_GETCURRENTPOS); @@ -526,7 +526,7 @@ StateStart::move_chars(gint64 n) } tecoBool -StateStart::move_lines(gint64 n) +StateStart::move_lines(tecoInt n) { sptr_t pos = interface.ssm(SCI_GETCURRENTPOS); sptr_t line = interface.ssm(SCI_LINEFROMPOSITION, pos) + n; @@ -540,7 +540,7 @@ StateStart::move_lines(gint64 n) } tecoBool -StateStart::delete_words(gint64 n) +StateStart::delete_words(tecoInt n) { sptr_t pos, size; @@ -593,7 +593,7 @@ StateStart::delete_words(gint64 n) State * StateStart::custom(gchar chr) throw (Error, ReplaceCmdline) { - gint64 v; + tecoInt v; tecoBool rc; /* @@ -739,7 +739,7 @@ StateStart::custom(gchar chr) throw (Error, ReplaceCmdline) } } else { BEGIN_EXEC(this); - gint64 loop_pc, loop_cnt; + tecoInt loop_pc, loop_cnt; expressions.discard_args(); g_assert(expressions.pop_op() == Expressions::OP_LOOP); @@ -973,13 +973,13 @@ StateStart::custom(gchar chr) throw (Error, ReplaceCmdline) case '=': BEGIN_EXEC(this); - interface.msg(Interface::MSG_USER, "%" G_GINT64_FORMAT, + interface.msg(Interface::MSG_USER, "%" TECO_INTEGER_FORMAT, expressions.pop_num_calc()); break; case 'K': case 'D': { - gint64 from, len; + tecoInt from, len; BEGIN_EXEC(this); expressions.eval(); @@ -1002,7 +1002,7 @@ StateStart::custom(gchar chr) throw (Error, ReplaceCmdline) from -= len; } } else { - gint64 to = expressions.pop_num(); + tecoInt to = expressions.pop_num(); from = expressions.pop_num(); len = to - from; rc = TECO_BOOL(len >= 0 && Validate::pos(from) && @@ -1071,7 +1071,7 @@ StateFCommand::custom(gchar chr) throw (Error) break; case '>': { - gint64 loop_pc, loop_cnt; + tecoInt loop_pc, loop_cnt; BEGIN_EXEC(&States::start); /* FIXME: what if in brackets? */ @@ -1128,7 +1128,7 @@ StateCondCommand::StateCondCommand() : State() State * StateCondCommand::custom(gchar chr) throw (Error) { - gint64 value = 0; + tecoInt value = 0; bool result; switch (mode) { @@ -1324,8 +1324,8 @@ StateECommand::custom(gchar chr) throw (Error) if (!expressions.args()) { expressions.push(Flags::ed); } else { - gint64 on = expressions.pop_num_calc(); - gint64 off = expressions.pop_num_calc(1, ~(gint64)0); + tecoInt on = expressions.pop_num_calc(); + tecoInt off = expressions.pop_num_calc(1, ~(tecoInt)0); undo.push_var(Flags::ed); Flags::ed = (Flags::ed & ~off) | on; @@ -1364,7 +1364,7 @@ StateScintilla_symbols::done(const gchar *str) throw (Error) undo.push_var(scintilla_message); if (*str) { gchar **symbols = g_strsplit(str, ",", -1); - gint64 v; + tecoInt v; if (!symbols[0]) goto cleanup; diff --git a/src/parser.h b/src/parser.h index da9bfee..e3c810c 100644 --- a/src/parser.h +++ b/src/parser.h @@ -199,13 +199,13 @@ public: StateStart(); private: - void insert_integer(gint64 v); - gint64 read_integer(void); + void insert_integer(tecoInt v); + tecoInt read_integer(void); - tecoBool move_chars(gint64 n); - tecoBool move_lines(gint64 n); + tecoBool move_chars(tecoInt n); + tecoBool move_lines(tecoInt n); - tecoBool delete_words(gint64 n); + tecoBool delete_words(tecoInt n); State *custom(gchar chr) throw (Error, ReplaceCmdline); }; diff --git a/src/qregisters.cpp b/src/qregisters.cpp index 69b3ea9..17be046 100644 --- a/src/qregisters.cpp +++ b/src/qregisters.cpp @@ -224,10 +224,10 @@ QRegister::load(const gchar *filename) return true; } -gint64 +tecoInt QRegisterBufferInfo::get_integer(void) { - gint64 id = 1; + tecoInt id = 1; if (!ring.current) return 0; @@ -568,7 +568,7 @@ StateSetQRegInteger::got_register(QRegister ®) throw (Error) State * StateIncreaseQReg::got_register(QRegister ®) throw (Error) { - gint64 res; + tecoInt res; BEGIN_EXEC(&States::start); @@ -593,7 +593,7 @@ StateMacro::got_register(QRegister ®) throw (Error, ReplaceCmdline) State * StateCopyToQReg::got_register(QRegister ®) throw (Error) { - gint64 from, len; + tecoInt from, len; Sci_TextRange tr; BEGIN_EXEC(&States::start); @@ -614,7 +614,7 @@ StateCopyToQReg::got_register(QRegister ®) throw (Error) len *= -1; } } else { - gint64 to = expressions.pop_num(); + tecoInt to = expressions.pop_num(); from = expressions.pop_num(); if (!Validate::pos(from) || !Validate::pos(to)) diff --git a/src/qregisters.h b/src/qregisters.h index 05a56ae..c212fc9 100644 --- a/src/qregisters.h +++ b/src/qregisters.h @@ -38,7 +38,7 @@ class QRegisterData { protected: - gint64 integer; + tecoInt integer; TECODocument string; public: @@ -49,8 +49,8 @@ public: QRegisterData() : integer(0), must_undo(true) {} - virtual gint64 - set_integer(gint64 i) + virtual tecoInt + set_integer(tecoInt i) { return integer = i; } @@ -60,7 +60,7 @@ public: if (must_undo) undo.push_var(integer); } - virtual gint64 + virtual tecoInt get_integer(void) { return integer; @@ -123,14 +123,14 @@ class QRegisterBufferInfo : public QRegister { public: QRegisterBufferInfo() : QRegister("*") {} - gint64 - set_integer(gint64 v) + tecoInt + set_integer(tecoInt v) { return v; } void undo_set_integer(void) {} - gint64 get_integer(void); + tecoInt get_integer(void); void set_string(const gchar *str) {} void undo_set_string(void) {} diff --git a/src/ring.cpp b/src/ring.cpp index 138714f..33d8293 100644 --- a/src/ring.cpp +++ b/src/ring.cpp @@ -190,7 +190,7 @@ Ring::find(const gchar *filename) } Buffer * -Ring::find(gint64 id) +Ring::find(tecoInt id) { Buffer *cur; @@ -226,7 +226,7 @@ Ring::is_any_dirty(void) } bool -Ring::edit(gint64 id) +Ring::edit(tecoInt id) { Buffer *buffer = find(id); @@ -581,20 +581,20 @@ StateEditFile::do_edit(const gchar *filename) throw (Error) } void -StateEditFile::do_edit(gint64 id) throw (Error) +StateEditFile::do_edit(tecoInt id) throw (Error) { if (ring.current) ring.undo_edit(); else /* QRegisters::current != NULL */ QRegisters::undo_edit(); if (!ring.edit(id)) - throw Error("Invalid buffer id %" G_GINT64_FORMAT, id); + throw Error("Invalid buffer id %" TECO_INTEGER_FORMAT, id); } void StateEditFile::initial(void) throw (Error) { - gint64 id = expressions.pop_num_calc(1, -1); + tecoInt id = expressions.pop_num_calc(1, -1); allowFilename = true; @@ -185,12 +185,12 @@ public: } Buffer *find(const gchar *filename); - Buffer *find(gint64 id); + Buffer *find(tecoInt id); void dirtify(void); bool is_any_dirty(void); - bool edit(gint64 id); + bool edit(tecoInt id); void edit(const gchar *filename); inline void undo_edit(void) @@ -220,7 +220,7 @@ private: bool allowFilename; void do_edit(const gchar *filename) throw (Error); - void do_edit(gint64 id) throw (Error); + void do_edit(tecoInt id) throw (Error); void initial(void) throw (Error); State *done(const gchar *str) throw (Error); diff --git a/src/sciteco.h b/src/sciteco.h index e40b6f4..f22842c 100644 --- a/src/sciteco.h +++ b/src/sciteco.h @@ -24,13 +24,24 @@ #include "interface.h" +#if TECO_INTEGER == 32 +typedef gint32 tecoInt; +#define TECO_INTEGER_FORMAT G_GINT32_FORMAT +#elif TECO_INTEGER == 64 +typedef gint64 tecoInt; +#define TECO_INTEGER_FORMAT G_GINT64_FORMAT +#else +#error Invalid TECO integer storage size +#endif +typedef tecoInt tecoBool; + namespace Flags { enum { ED_HOOKS = (1 << 5), ED_FNKEYS = (1 << 6) }; - extern gint64 ed; + extern tecoInt ed; } extern sig_atomic_t sigint_occurred; @@ -43,8 +54,6 @@ extern sig_atomic_t sigint_occurred; #define CTL_ECHO(C) ((C) | 0x40) #define CTL_KEY(C) ((C) & ~0x40) -typedef gint64 tecoBool; - #define SUCCESS (-1) #define FAILURE (0) #define TECO_BOOL(X) ((X) ? SUCCESS : FAILURE) diff --git a/src/search.cpp b/src/search.cpp index a56ce17..38aa011 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -54,7 +54,7 @@ namespace States { void StateSearch::initial(void) throw (Error) { - gint64 v1, v2; + tecoInt v1, v2; undo.push_var(parameters); @@ -473,7 +473,7 @@ StateSearch::done(const gchar *str) throw (Error) void StateSearchAll::initial(void) throw (Error) { - gint64 v1, v2; + tecoInt v1, v2; undo.push_var(parameters); |