aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/qreg.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/qreg.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/qreg.c')
-rw-r--r--src/qreg.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/qreg.c b/src/qreg.c
index 8990210..9695f64 100644
--- a/src/qreg.c
+++ b/src/qreg.c
@@ -239,18 +239,12 @@ teco_qreg_plain_get_character(teco_qreg_t *qreg, teco_int_t position,
sptr_t len = teco_view_ssm(teco_qreg_view, SCI_GETLENGTH, 0, 0);
gssize off = teco_view_glyphs2bytes(teco_qreg_view, position);
- gboolean ret = off >= 0 && off != len;
- if (!ret)
- g_set_error(error, TECO_ERROR, TECO_ERROR_RANGE,
- "Position %" TECO_INT_FORMAT " out of range", position);
- /* make sure we still restore the current Q-Register */
- else
- *chr = teco_view_get_character(teco_qreg_view, off, len);
+ *chr = off >= 0 && off != len ? teco_view_get_character(teco_qreg_view, off, len) : -1;
if (teco_qreg_current)
teco_doc_edit(&teco_qreg_current->string, 0);
- return ret;
+ return TRUE;
}
static teco_int_t
@@ -527,9 +521,8 @@ teco_qreg_external_get_character(teco_qreg_t *qreg, teco_int_t position,
return FALSE;
if (position < 0 || position >= g_utf8_strlen(str.data, str.len)) {
- g_set_error(error, TECO_ERROR, TECO_ERROR_RANGE,
- "Position %" TECO_INT_FORMAT " out of range", position);
- return FALSE;
+ *chr = -1;
+ return TRUE;
}
const gchar *p = g_utf8_offset_to_pointer(str.data, position);