aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmdline.c2
-rw-r--r--src/goto-commands.c6
-rw-r--r--src/goto.c20
-rw-r--r--src/goto.h8
-rw-r--r--src/parser.c11
-rw-r--r--src/parser.h5
6 files changed, 26 insertions, 26 deletions
diff --git a/src/cmdline.c b/src/cmdline.c
index e402124..0d32513 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -87,7 +87,7 @@ teco_cmdline_insert(const gchar *data, gsize len, GError **error)
{
const teco_string_t src = {(gchar *)data, len};
teco_string_t old_cmdline = {NULL, 0};
- guint repl_pc = 0;
+ gsize repl_pc = 0;
teco_cmdline.machine.macro_pc = teco_cmdline.pc = teco_cmdline.effective_len;
diff --git a/src/goto-commands.c b/src/goto-commands.c
index bf80c0b..a8a9689 100644
--- a/src/goto-commands.c
+++ b/src/goto-commands.c
@@ -61,8 +61,8 @@ teco_state_label_input(teco_machine_main_t *ctx, gunichar chr, GError **error)
* on rubout.
* Otherwise, the label will be removed (PC == -1).
*/
- gint existing_pc = teco_goto_table_set(&ctx->goto_table, ctx->goto_label.data,
- ctx->goto_label.len, ctx->macro_pc);
+ gssize existing_pc = teco_goto_table_set(&ctx->goto_table, ctx->goto_label.data,
+ ctx->goto_label.len, ctx->macro_pc);
if (ctx->parent.must_undo)
teco_goto_table_undo_set(&ctx->goto_table, ctx->goto_label.data, ctx->goto_label.len, existing_pc);
@@ -119,7 +119,7 @@ teco_state_goto_done(teco_machine_main_t *ctx, const teco_string_t *str, GError
}
if (value == 0) {
- gint pc = teco_goto_table_find(&ctx->goto_table, label.data, label.len);
+ gssize pc = teco_goto_table_find(&ctx->goto_table, label.data, label.len);
if (pc >= 0) {
ctx->macro_pc = pc;
diff --git a/src/goto.c b/src/goto.c
index 281a9f5..65ee3ca 100644
--- a/src/goto.c
+++ b/src/goto.c
@@ -35,12 +35,12 @@
/** @extends teco_rb3str_head_t */
typedef struct {
teco_rb3str_head_t head;
- gint pc;
+ gsize pc;
} teco_goto_label_t;
/** @private @static @memberof teco_goto_label_t */
static teco_goto_label_t *
-teco_goto_label_new(const gchar *name, gsize len, gint pc)
+teco_goto_label_new(const gchar *name, gsize len, gsize pc)
{
teco_goto_label_t *label = g_new0(teco_goto_label_t, 1);
teco_string_init(&label->head.name, name, len);
@@ -79,10 +79,10 @@ teco_goto_table_dump(teco_goto_table_t *ctx)
#endif
/** @memberof teco_goto_table_t */
-gint
+gssize
teco_goto_table_remove(teco_goto_table_t *ctx, const gchar *name, gsize len)
{
- gint existing_pc = -1;
+ gssize existing_pc = -1;
teco_goto_label_t *label = (teco_goto_label_t *)teco_rb3str_find(&ctx->tree, TRUE, name, len);
if (label) {
@@ -95,7 +95,7 @@ teco_goto_table_remove(teco_goto_table_t *ctx, const gchar *name, gsize len)
}
/** @memberof teco_goto_table_t */
-gint
+gssize
teco_goto_table_find(teco_goto_table_t *ctx, const gchar *name, gsize len)
{
teco_goto_label_t *label = (teco_goto_label_t *)teco_rb3str_find(&ctx->tree, TRUE, name, len);
@@ -103,13 +103,13 @@ teco_goto_table_find(teco_goto_table_t *ctx, const gchar *name, gsize len)
}
/** @memberof teco_goto_table_t */
-gint
-teco_goto_table_set(teco_goto_table_t *ctx, const gchar *name, gsize len, gint pc)
+gssize
+teco_goto_table_set(teco_goto_table_t *ctx, const gchar *name, gsize len, gssize pc)
{
if (pc < 0)
return teco_goto_table_remove(ctx, name, len);
- gint existing_pc = -1;
+ gssize existing_pc = -1;
teco_goto_label_t *label = (teco_goto_label_t *)teco_rb3str_find(&ctx->tree, TRUE, name, len);
if (label) {
@@ -135,7 +135,7 @@ teco_goto_table_set(teco_goto_table_t *ctx, const gchar *name, gsize len, gint p
*/
typedef struct {
teco_goto_table_t *table;
- gint pc;
+ gssize pc;
gsize len;
gchar name[];
} teco_goto_table_undo_set_t;
@@ -153,7 +153,7 @@ teco_goto_table_undo_set_action(teco_goto_table_undo_set_t *ctx, gboolean run)
/** @memberof teco_goto_table_t */
void
-teco_goto_table_undo_set(teco_goto_table_t *ctx, const gchar *name, gsize len, gint pc)
+teco_goto_table_undo_set(teco_goto_table_t *ctx, const gchar *name, gsize len, gssize pc)
{
if (!ctx->must_undo)
return;
diff --git a/src/goto.h b/src/goto.h
index eeaa7cb..01f55ac 100644
--- a/src/goto.h
+++ b/src/goto.h
@@ -40,12 +40,12 @@ teco_goto_table_init(teco_goto_table_t *ctx, gboolean must_undo)
ctx->must_undo = must_undo;
}
-gint teco_goto_table_remove(teco_goto_table_t *ctx, const gchar *name, gsize len);
+gssize teco_goto_table_remove(teco_goto_table_t *ctx, const gchar *name, gsize len);
-gint teco_goto_table_find(teco_goto_table_t *ctx, const gchar *name, gsize len);
+gssize teco_goto_table_find(teco_goto_table_t *ctx, const gchar *name, gsize len);
-gint teco_goto_table_set(teco_goto_table_t *ctx, const gchar *name, gsize len, gint pc);
-void teco_goto_table_undo_set(teco_goto_table_t *ctx, const gchar *name, gsize len, gint pc);
+gssize teco_goto_table_set(teco_goto_table_t *ctx, const gchar *name, gsize len, gssize pc);
+void teco_goto_table_undo_set(teco_goto_table_t *ctx, const gchar *name, gsize len, gssize pc);
/** @memberof teco_goto_table_t */
static inline gboolean
diff --git a/src/parser.c b/src/parser.c
index 3c37f81..45e31cf 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -102,12 +102,6 @@ gboolean
teco_machine_main_step(teco_machine_main_t *ctx, const gchar *macro, gsize stop_pos, GError **error)
{
while (ctx->macro_pc < stop_pos) {
-#ifdef DEBUG
- g_printf("EXEC(%d): input='%c'/%x, state=%p, mode=%d\n",
- ctx->macro_pc, macro[ctx->macro_pc], macro[ctx->macro_pc],
- ctx->parent.current, ctx->mode);
-#endif
-
if (G_UNLIKELY(teco_interface_is_interrupted())) {
teco_error_interrupted_set(error);
goto error_attach;
@@ -123,6 +117,11 @@ teco_machine_main_step(teco_machine_main_t *ctx, const gchar *macro, gsize stop_
/* UTF-8 sequences are already validated */
gunichar chr = g_utf8_get_char(macro+ctx->macro_pc);
+#ifdef DEBUG
+ g_printf("EXEC(%d): input='%C' (U+%04" G_GINT32_MODIFIER "X), state=%p, mode=%d\n",
+ ctx->macro_pc, chr, chr, ctx->parent.current, ctx->mode);
+#endif
+
if (!teco_machine_input(&ctx->parent, chr, error))
goto error_attach;
diff --git a/src/parser.h b/src/parser.h
index 0303bae..7cc286e 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -38,7 +38,7 @@ typedef struct {
/** how many iterations are left */
teco_int_t counter;
/** Program counter of loop start command */
- guint pc : sizeof(guint)*8 - 1;
+ gsize pc : sizeof(gsize)*8 - 1;
/**
* Whether the loop represents an argument
* barrier or not (it "passes through"
@@ -432,7 +432,8 @@ typedef enum {
struct teco_machine_main_t {
teco_machine_t parent;
- gsize macro_pc;
+ /* signed because it is sometimes set to -1 for flow control */
+ gssize macro_pc;
/**
* Aliases bitfield with an integer.