From 63c2d707d2dc8f8b38c6162253751680b09bd514 Mon Sep 17 00:00:00 2001 From: "K.Kosako" Date: Sun, 28 Aug 2016 15:06:24 +0900 Subject: [PATCH] fix is_valid_mbc_string() in utf-16le --- src/utf16_le.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/utf16_le.c b/src/utf16_le.c index 4f0414e..89bc72f 100644 --- a/src/utf16_le.c +++ b/src/utf16_le.c @@ -61,9 +61,18 @@ utf16le_mbc_enc_len(const UChar* p) } static int -is_valid_mbc_string(const UChar* s, const UChar* end) +is_valid_mbc_string(const UChar* p, const UChar* end) { - return onigenc_length_check_is_valid_mbc_string(ONIG_ENCODING_UTF16_LE, s, end); + const UChar* end1 = end - 1; + + while (p < end1) { + p += utf16le_mbc_enc_len(p); + } + + if (p != end) + return FALSE; + else + return TRUE; } static int -- 2.40.0