Skip to content

Commit 2bfee1e

Browse files
cosmo0920edsiper
authored andcommitted
Restore the previous behavior for enclen
To fix testcases failures. Signed-off-by: Hiroshi Hatake <hatake@calyptia.com>
1 parent 04d3232 commit 2bfee1e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

regexec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3092,7 +3092,8 @@ match_at(regex_t* reg, const UChar* str, const UChar* end,
30923092
}
30933093
else {
30943094
STACK_PUSH_ALT(p + addr, s, sprev, pkeep); /* Push possible point. */
3095-
n = enclen(encode, s, end);
3095+
/* For approximating enclen. Strict version of enclen does not work here. */
3096+
n = enclen_approximate(encode, s, end);
30963097
STACK_PUSH_ABSENT_POS(absent, ABSENT_END_POS); /* Save the original pos. */
30973098
STACK_PUSH_ALT(selfp, s + n, s, pkeep); /* Next iteration. */
30983099
STACK_PUSH_ABSENT;

regparse.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4659,7 +4659,15 @@ parse_char_class(Node** np, Node** asc_np, OnigToken* tok, UChar** src, UChar* e
46594659
goto err;
46604660
}
46614661

4662-
len = enclen(env->enc, buf, buf + i);
4662+
if (env->enc == ONIG_ENCODING_EUC_JP ||
4663+
env->enc == ONIG_ENCODING_SJIS) {
4664+
/* Strict version of enclen does not handle invalid single code
4665+
* point for SJIS and EUC-JP...*/
4666+
len = enclen_approximate(env->enc, buf, buf + i);
4667+
}
4668+
else {
4669+
len = enclen(env->enc, buf, buf + i);
4670+
}
46634671
if (i < len) {
46644672
r = ONIGERR_TOO_SHORT_MULTI_BYTE_STRING;
46654673
goto err;

0 commit comments

Comments
 (0)