aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/spawn.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-08-29 01:56:50 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-09-09 18:22:21 +0200
commit7c592561af3bbbad2eaf865247811ba2bd590c2e (patch)
tree75b27cf40fb9ba8d646eb00e05be5f91d116b493 /src/spawn.c
parentc71ed30cf0c554d288edfe87842082cc9ec393a7 (diff)
downloadsciteco-7c592561af3bbbad2eaf865247811ba2bd590c2e.tar.gz
Glyph to byte offset mapping is now using the line character index (refs #5)
* This works reasonably well unless lines are exceedingly long (as on a line we always count characters). The following test case is still slow (on Unicode buffers): 10000<@I/XX/> <%a-1:J;> While the following is now also fast: 10000<@I/X^J/> <%a-1:J;> * Commands with relative character offsets (C, R, A, D) have a special optimization where they always count characters beginning at dot, as long as the argument is now exceedingly large. This means they are fast even on exceedingly long lines. * The remaining commands (search, EC/EG, Xq) now accept glyph indexes.
Diffstat (limited to 'src/spawn.c')
-rw-r--r--src/spawn.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/spawn.c b/src/spawn.c
index 671f493..c1fb426 100644
--- a/src/spawn.c
+++ b/src/spawn.c
@@ -76,8 +76,8 @@ static struct {
GSource *stdin_src, *stdout_src;
gboolean interrupted;
- teco_int_t from, to;
- teco_int_t start;
+ gssize from, to;
+ gsize start;
gboolean text_added;
teco_eol_writer_t stdin_writer;
@@ -202,15 +202,17 @@ teco_state_execute_initial(teco_machine_main_t *ctx, GError **error)
break;
}
- default:
+ default: {
/* pipe and replace character range */
- if (!teco_expressions_pop_num_calc(&teco_spawn_ctx.to, 0, error) ||
- !teco_expressions_pop_num_calc(&teco_spawn_ctx.from, 0, error))
+ teco_int_t from, to;
+ if (!teco_expressions_pop_num_calc(&to, 0, error) ||
+ !teco_expressions_pop_num_calc(&from, 0, error))
return FALSE;
+ teco_spawn_ctx.from = teco_glyphs2bytes(from);
+ teco_spawn_ctx.to = teco_glyphs2bytes(to);
rc = teco_bool(teco_spawn_ctx.from <= teco_spawn_ctx.to &&
- teco_validate_pos(teco_spawn_ctx.from) &&
- teco_validate_pos(teco_spawn_ctx.to));
- break;
+ teco_spawn_ctx.from >= 0 && teco_spawn_ctx.to >= 0);
+ }
}
if (teco_is_failure(rc)) {