From e46352bc614cf9777ca76deb47330fb408bc1a23 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 2 Aug 2025 13:16:16 +0300 Subject: fixed serious bug with certain alternative string termination chars in commands with multiple string arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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? --- tests/testsuite.at | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tests/testsuite.at') diff --git a/tests/testsuite.at b/tests/testsuite.at index 428757c..15fb810 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -118,6 +118,9 @@ AT_SETUP([String arguments]) TE_CHECK([[Ifoo^Q]]TE_ESCAPE[[(0/0)]]TE_ESCAPE, 0, ignore, ignore) TE_CHECK([[@I"foo^Q"(0/0)"]], 0, ignore, ignore) TE_CHECK([[@I{foo{bar}foo^Q{(0/0)}]], 0, ignore, ignore) +TE_CHECK([[@^Ua + {12345} :Qa-5"N(0/0)']], 0, ignore, ignore) +TE_CHECK([[@I/X/ H@FR{X}/12345/ Z-5"N(0/0)']], 0, ignore, ignore) TE_CHECK([[@Ia^EQa(0/0)a]], 0, ignore, ignore) # Video-TECO-like syntax - might change in the future TE_CHECK([[@I/^E<65>^E<0x41>^E<0101>/ <-A:; -A-^^A"N(0/0)' R>]], 0, ignore, ignore) -- cgit v1.2.3