aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/qreg-commands.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-12-06 17:20:52 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-12-06 17:20:52 +0300
commite5884ab2166ab5a03294baa54601b8785e6d9727 (patch)
tree0013120eed3e407cd047b734082d7011b9bab94f /src/qreg-commands.c
parentc4e73ae7ef24796cf1f24f0c30d93f2ab21a4572 (diff)
downloadsciteco-e5884ab2166ab5a03294baa54601b8785e6d9727.tar.gz
support the ::S anchored search (string comparison) command (and ::FD, ::FR, ::FS as well)
* The colon modifier can now occur 2 times. Specifying `@` more than once or `:` more than twice is an error now. * Commands do not check for excess colon modifiers - almost every command would have to check it. Instead, a double colon will simply behave like a single colon on most commands. * All search commands inherit the anchored semantics, but it's not very useful in some combinations like -::S, ::N or ::FK. That's why the `::` variants are not documented everywhere. * The lexer.checkheader macro could be simplified and should also be faster now, speeding up startup. Eventually this macro can be made superfluous, e.g. by using 1:FB or 0,1^Q::S.
Diffstat (limited to 'src/qreg-commands.c')
-rw-r--r--src/qreg-commands.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/qreg-commands.c b/src/qreg-commands.c
index c36a6b7..0a64b2f 100644
--- a/src/qreg-commands.c
+++ b/src/qreg-commands.c
@@ -256,7 +256,7 @@ teco_state_queryqreg_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg,
if (!teco_expressions_eval(FALSE, error))
return NULL;
- if (teco_machine_main_eval_colon(ctx)) {
+ if (teco_machine_main_eval_colon(ctx) > 0) {
/* Query Q-Register's existence or string size */
if (qreg) {
/* get_string() would return the size in bytes */
@@ -366,7 +366,7 @@ teco_state_setqregstring_nobuilding_done(teco_machine_main_t *ctx,
if (ctx->mode > TECO_MODE_NORMAL)
return &teco_state_start;
- gboolean colon_modified = teco_machine_main_eval_colon(ctx);
+ gboolean colon_modified = teco_machine_main_eval_colon(ctx) > 0;
if (!teco_expressions_eval(FALSE, error))
return NULL;
@@ -578,9 +578,9 @@ teco_state_setqreginteger_got_register(teco_machine_main_t *ctx, teco_qreg_t *qr
!qreg->vtable->set_integer(qreg, v, error))
return NULL;
- if (teco_machine_main_eval_colon(ctx))
+ if (teco_machine_main_eval_colon(ctx) > 0)
teco_expressions_push(TECO_SUCCESS);
- } else if (teco_machine_main_eval_colon(ctx)) {
+ } else if (teco_machine_main_eval_colon(ctx) > 0) {
teco_expressions_push(TECO_FAILURE);
} else {
teco_error_argexpected_set(error, "U");
@@ -653,7 +653,7 @@ teco_state_macro_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg,
if (ctx->mode > TECO_MODE_NORMAL)
return &teco_state_start;
- if (teco_machine_main_eval_colon(ctx)) {
+ if (teco_machine_main_eval_colon(ctx) > 0) {
/* don't create new local Q-Registers if colon modifier is given */
if (!teco_qreg_execute(qreg, ctx->qreg_table_locals, error))
return NULL;
@@ -710,7 +710,7 @@ teco_state_macrofile_done(teco_machine_main_t *ctx, const teco_string_t *str, GE
g_autofree gchar *filename = teco_file_expand_path(str->data);
- if (teco_machine_main_eval_colon(ctx)) {
+ if (teco_machine_main_eval_colon(ctx) > 0) {
/* don't create new local Q-Registers if colon modifier is given */
if (!teco_execute_file(filename, ctx->qreg_table_locals, error))
return NULL;
@@ -803,7 +803,7 @@ teco_state_copytoqreg_got_register(teco_machine_main_t *ctx, teco_qreg_t *qreg,
};
teco_interface_ssm(SCI_GETTEXTRANGEFULL, 0, (sptr_t)&range);
- if (teco_machine_main_eval_colon(ctx)) {
+ if (teco_machine_main_eval_colon(ctx) > 0) {
if (!qreg->vtable->append_string(qreg, str, len, error))
return NULL;
} else {