diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-08-28 00:03:04 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-08-28 00:03:04 +0200 |
commit | fdc185b8faaae44d67f85d2c5a9b9fa48d3e2859 (patch) | |
tree | 8a3553c4a1642588f8cdf739f035a99a0467b68e /src/core-commands.c | |
parent | 94d12185d873c1808b902e010d305835fbb085f1 (diff) | |
download | sciteco-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/core-commands.c')
-rw-r--r-- | src/core-commands.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/core-commands.c b/src/core-commands.c index d959f10..52059a8 100644 --- a/src/core-commands.c +++ b/src/core-commands.c @@ -1029,7 +1029,8 @@ teco_state_start_get(teco_machine_main_t *ctx, GError **error) teco_error_range_set(error, "A"); return; } - teco_expressions_push(teco_interface_ssm(SCI_GETCHARAT, v, 0)); + /* internally, the character is casted to signed char */ + teco_expressions_push((guchar)teco_interface_ssm(SCI_GETCHARAT, v, 0)); } static teco_state_t * @@ -1764,7 +1765,7 @@ static teco_state_t * teco_state_ascii_input(teco_machine_main_t *ctx, gchar chr, GError **error) { if (ctx->mode == TECO_MODE_NORMAL) - teco_expressions_push(chr); + teco_expressions_push((guchar)chr); return &teco_state_start; } |