]> granicus.if.org Git - onig/commitdiff
fix invalid applying to code range
authorK.Kosako <kosako@sofnec.co.jp>
Tue, 10 Sep 2019 06:40:24 +0000 (15:40 +0900)
committerK.Kosako <kosako@sofnec.co.jp>
Tue, 10 Sep 2019 06:40:24 +0000 (15:40 +0900)
src/regparse.c

index 91f692ae0cda14f4b4e5e42f9ab930ad209525b3..cdf4e0659c203fba9dccf7173dd5d9816b906a3c 100644 (file)
@@ -7773,7 +7773,8 @@ i_apply_case_fold(OnigCodePoint from, OnigCodePoint to[], int to_len, void* arg)
 #ifdef CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS
     if ((is_in != 0 && !IS_NCCLASS_NOT(cc)) ||
         (is_in == 0 &&  IS_NCCLASS_NOT(cc))) {
-      if (ONIGENC_MBC_MINLEN(env->enc) > 1 || *to >= SINGLE_BYTE_SIZE) {
+      if (ONIGENC_MBC_MINLEN(env->enc) > 1 ||
+          ONIGENC_CODE_TO_MBCLEN(env->enc, *to) != 1) {
         add_code_range(&(cc->mbuf), env, *to, *to);
       }
       else {
@@ -7782,7 +7783,8 @@ i_apply_case_fold(OnigCodePoint from, OnigCodePoint to[], int to_len, void* arg)
     }
 #else
     if (is_in != 0) {
-      if (ONIGENC_MBC_MINLEN(env->enc) > 1 || *to >= SINGLE_BYTE_SIZE) {
+      if (ONIGENC_MBC_MINLEN(env->enc) > 1 ||
+          ONIGENC_CODE_TO_MBCLEN(env->enc, *to) != 1) {
         if (IS_NCCLASS_NOT(cc)) clear_not_flag_cclass(cc, env->enc);
         add_code_range(&(cc->mbuf), env, *to, *to);
       }