]> granicus.if.org Git - onig/commitdiff
reimplement mbc_to_code() in utf-8
authorK.Kosako <kkosako0@gmail.com>
Sun, 28 Aug 2016 09:33:52 +0000 (18:33 +0900)
committerK.Kosako <kkosako0@gmail.com>
Sun, 28 Aug 2016 09:33:52 +0000 (18:33 +0900)
src/utf8.c

index e1b563ffbcdf72df3fd8038477f3cc11005d81fb..219b7eacead089c0db79becd6d68c33527b66d8e 100644 (file)
@@ -121,7 +121,9 @@ mbc_to_code(const UChar* p, const UChar* end)
   int c, len;
   OnigCodePoint n;
 
-  len = enclen_end(ONIG_ENCODING_UTF8, p, end);
+  len = mbc_enc_len(p);
+  if (len > end - p) len = end - p;
+
   c = *p++;
   if (len > 1) {
     len--;