From 442268285a5f8b1d53052b6c7b0566d9200e71c7 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sun, 1 Jun 2025 02:38:25 +0300 Subject: and now return -1 in case the index n is out of range * The old behavior of throwing an error was inherited from Video TECO. * The command is now more similar to TECO-11. * Since -1 is taken, invalid and incomplete UTF-8 byte sequences are now reported as -2/-3. I wasn't really able to provoke -3, though. --- src/core-commands.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'src/core-commands.c') diff --git a/src/core-commands.c b/src/core-commands.c index bb731a1..d2abe79 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -574,8 +574,6 @@ teco_state_start_print(teco_machine_main_t *ctx, GError **error) * This can be an ASCII or Unicode codepoint * depending on Scintilla's encoding of the current * buffer. - * Invalid Unicode byte sequences are reported as - * -1 or -2. * * - If is 0, return the of the character * pointed to by dot. @@ -586,12 +584,11 @@ teco_state_start_print(teco_machine_main_t *ctx, GError **error) * - If is omitted, the sign prefix is implied. * * If the position of the queried character is off-page, - * the command will yield an error. - * + * the command will return -1. * If the document is encoded as UTF-8 and there is - * an incomplete sequence at the requested position, - * -1 is returned. - * All other invalid Unicode sequences are returned as -2. + * an invalid byte sequence at the requested position, + * -2 is returned. + * Incomplete byte sequences are returned as -3. */ static void teco_state_start_get(teco_machine_main_t *ctx, GError **error) @@ -604,12 +601,8 @@ teco_state_start_get(teco_machine_main_t *ctx, GError **error) gssize get_pos = teco_interface_glyphs2bytes_relative(pos, v); sptr_t len = teco_interface_ssm(SCI_GETLENGTH, 0, 0); - if (get_pos < 0 || get_pos == len) { - teco_error_range_set(error, "A"); - return; - } - - teco_expressions_push(teco_interface_get_character(get_pos, len)); + teco_expressions_push(get_pos < 0 || get_pos == len + ? -1 : teco_interface_get_character(get_pos, len)); } static teco_state_t * -- cgit v1.2.3