diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-08-02 13:16:16 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2025-08-02 13:16:16 +0300 |
commit | e46352bc614cf9777ca76deb47330fb408bc1a23 (patch) | |
tree | 2e900970b9eebbeb9bab12bef451a51a7f09ed13 /src/core-commands.c | |
parent | 963cd2db9b266f7521374adacb664ca8ec43d36b (diff) | |
download | sciteco-e46352bc614cf9777ca76deb47330fb408bc1a23.tar.gz |
fixed serious bug with certain alternative string termination chars in commands with multiple string arguments
* When `@`-modifying a command with several string arguments and choosing `{` as the alternative
string termination character, the parser would get totally confused.
Any sequence of `{` would be ignored and only the first non-`{` would become the termination character.
Consequently you also couldn't choose a new terminator after the closing `}`.
So even a documented code example from sciteco(7) wouldn't work.
The same was true when using $ (escape) or ^A as the alternative termination character.
* We can now correctly parse e.g. `@FR{foo}{bar}` or `@FR$foo$bar$` (even though the
latter one is quite pointless).
* has probably been broken forever (has been broken even before v2.0).
* Whitespace is now ignored in front of alternative termination characters as in TECO-64, so
we can also write `@S /foo/` or even
```
@^Um
{
!* blabla *!
}
```
I wanted to disallow whitespace termination characters, so the alternative would have been
to throw an error.
The new implementation at least adds some functionality.
* Avoid redundancies when parsing no-op characters via teco_is_noop().
I assume that this is inlined and drawn into any jump-table what would be
generated for the switch-statement in teco_state_start_input().
* Alternative termination characters are still case-folded, even if they are Unicode glyphs,
so `@IЖfooж` would work and insert `foo`.
This should perhaps be restricted to ANSI characters?
Diffstat (limited to 'src/core-commands.c')
-rw-r--r-- | src/core-commands.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/core-commands.c b/src/core-commands.c index c71ee95..f384272 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -722,24 +722,21 @@ teco_state_start_input(teco_machine_main_t *ctx, gunichar chr, GError **error) ['T'] = {&teco_state_start, teco_state_start_typeout} }; - switch (chr) { /* - * No-ops (same as TECO_NOOPS): + * Non-operational commands. * These are explicitly not handled in teco_state_control, * so that we can potentially reuse the upcaret notations like ^J. */ - case ' ': - case '\f': - case '\r': - case '\n': - case '\v': + if (teco_is_noop(chr)) { if (ctx->flags.modifier_at || (ctx->flags.mode == TECO_MODE_NORMAL && ctx->flags.modifier_colon)) { teco_error_modifier_set(error, chr); return NULL; } return &teco_state_start; + } + switch (chr) { /*$ 0 1 2 3 4 5 6 7 8 9 digit number * [n]0|1|2|3|4|5|6|7|8|9 -> n*Radix+X -- Append digit * |