summaryrefslogtreecommitdiffhomepage
path: root/src/utf8code.c
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2022-11-29 20:31:04 +0100
committerTyge Lovset <[email protected]>2022-11-29 20:31:04 +0100
commitbc68ab7490aa70d547deb24a5d9c8d4df44d71c9 (patch)
tree3de072a89a60aa0c4048addf4b5338433f2d113c /src/utf8code.c
parent1e0f229b0b044f6df0d0084674f3cf0dc4f4d31d (diff)
downloadSTC-modified-bc68ab7490aa70d547deb24a5d9c8d4df44d71c9.tar.gz
STC-modified-bc68ab7490aa70d547deb24a5d9c8d4df44d71c9.zip
Fixed bug in utf8 case convertion.
Diffstat (limited to 'src/utf8code.c')
-rw-r--r--src/utf8code.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/utf8code.c b/src/utf8code.c
index b1534230..2b6e1739 100644
--- a/src/utf8code.c
+++ b/src/utf8code.c
@@ -156,9 +156,10 @@ cstr cstr_tocase(csview sv, int k) {
cstr out = cstr_null;
char *buf = cstr_reserve(&out, sv.size*3/2);
uint32_t cp; size_t sz = 0;
+ const char* end = sv.str + sv.size;
utf8_decode_t d = {.state=0};
- while (*sv.str) {
+ while (sv.str != end) {
do { utf8_decode(&d, (uint8_t)*sv.str++); } while (d.state);
if (d.codep < 128)
buf[sz++] = (char)fn_tocase[k].conv_asc((int)d.codep);