From 4589a627386d968ac6c2a02951ec6a55ece258f2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 8 Jan 2024 10:36:17 +0530 Subject: [PATCH] ... --- kitty/simd-string-impl.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kitty/simd-string-impl.h b/kitty/simd-string-impl.h index ccb0510a7..6d20a0147 100644 --- a/kitty/simd-string-impl.h +++ b/kitty/simd-string-impl.h @@ -156,8 +156,10 @@ FUNC(utf8_decode_to_esc)(UTF8Decoder *d, const uint8_t *src, size_t src_sz) { const integer_t vec_signed = add_epi8(vec, state); // needed because cmplt_epi8 works only on signed chars const integer_t bytes_indicating_start_of_two_byte_sequence = cmplt_epi8(set1_epi8(0xc0 - 1 - 0x80), vec_signed); - const unsigned num_of_bytes_to_first_non_ascii_byte = count_trailing_zeros(movemask_epi8(bytes_indicating_start_of_two_byte_sequence)); - if (num_of_bytes_to_first_non_ascii_byte >= src_sz) { // no bytes with high bit (0x80) set, so just plain ASCII + if ( + (unsigned)count_trailing_zeros(movemask_epi8(bytes_indicating_start_of_two_byte_sequence)) >= src_sz && + (unsigned)count_trailing_zeros(movemask_epi8(vec)) >= src_sz) + { // no bytes with high bit (0x80) set, so just plain ASCII FUNC(output_plain_ascii)(d, vec, src_sz); return sentinel_found; }