aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core-commands.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-06-01 02:38:25 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-06-01 03:06:13 +0300
commit442268285a5f8b1d53052b6c7b0566d9200e71c7 (patch)
tree90fb62e9157445aebc2253ece0ec96b0934d1932 /src/core-commands.c
parent6e3da17a2fae11af9ae00d9b59bd0d752022e16b (diff)
downloadsciteco-442268285a5f8b1d53052b6c7b0566d9200e71c7.tar.gz
<nA> and <nQq> 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.
Diffstat (limited to 'src/core-commands.c')
-rw-r--r--src/core-commands.c19
1 files changed, 6 insertions, 13 deletions
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 <code> or Unicode codepoint
* depending on Scintilla's encoding of the current
* buffer.
- * Invalid Unicode byte sequences are reported as
- * -1 or -2.
*
* - If <n> is 0, return the <code> of the character
* pointed to by dot.
@@ -586,12 +584,11 @@ teco_state_start_print(teco_machine_main_t *ctx, GError **error)
* - If <n> 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 *