aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/qreg.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-08-28 00:03:04 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-08-28 00:03:04 +0200
commitfdc185b8faaae44d67f85d2c5a9b9fa48d3e2859 (patch)
tree8a3553c4a1642588f8cdf739f035a99a0467b68e /src/qreg.c
parent94d12185d873c1808b902e010d305835fbb085f1 (diff)
downloadsciteco-fdc185b8faaae44d67f85d2c5a9b9fa48d3e2859.tar.gz
fixed retrieval of characters with codes larger than 127 - always return unsigned integer
* SCI_GETCHARAT is internally casted to `char`, which may be signed. Characters > 127 therefore become negative and stay so when casted to sptr_t. We therefore cast it back to guchar (unsigned char). * The same is true whenever returning a string's character to SciTECO (teco_int_t) as our string type is `gchar *`. * <^^x> now also works for those characters. Eventually, the parser will probably become UTF8-aware and this will have to be done differently.
Diffstat (limited to 'src/qreg.c')
-rw-r--r--src/qreg.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/qreg.c b/src/qreg.c
index 96e4e20..f058aff 100644
--- a/src/qreg.c
+++ b/src/qreg.c
@@ -261,7 +261,8 @@ teco_qreg_plain_get_character(teco_qreg_t *qreg, guint position, GError **error)
teco_doc_edit(&qreg->string);
if (position < teco_view_ssm(teco_qreg_view, SCI_GETLENGTH, 0, 0))
- ret = teco_view_ssm(teco_qreg_view, SCI_GETCHARAT, position, 0);
+ /* internally, values are casted to signed char */
+ ret = (guchar)teco_view_ssm(teco_qreg_view, SCI_GETCHARAT, position, 0);
else
g_set_error(error, TECO_ERROR, TECO_ERROR_RANGE,
"Position %u out of range", position);
@@ -407,7 +408,7 @@ teco_qreg_external_get_character(teco_qreg_t *qreg, guint position, GError **err
return -1;
}
- return str.data[position];
+ return (guchar)str.data[position];
}
/**
@@ -510,7 +511,7 @@ teco_qreg_bufferinfo_get_character(teco_qreg_t *qreg, guint position, GError **e
return -1;
}
- return teco_ring_current->filename[position];
+ return (guchar)teco_ring_current->filename[position];
}
/** @static @memberof teco_qreg_t */