]> granicus.if.org Git - onig/commitdiff
fix is_valid_mbc_string() in utf-16le
authorK.Kosako <kkosako0@gmail.com>
Sun, 28 Aug 2016 06:06:24 +0000 (15:06 +0900)
committerK.Kosako <kkosako0@gmail.com>
Sun, 28 Aug 2016 06:06:24 +0000 (15:06 +0900)
src/utf16_le.c

index 4f0414e50cc2b9209b138596f38358a8121e2c58..89bc72f05d49357a04e7db3369f15695703a3fe3 100644 (file)
@@ -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