aboutsummaryrefslogtreecommitdiffstats
path: root/encoding.c
diff options
context:
space:
mode:
Diffstat (limited to 'encoding.c')
-rw-r--r--encoding.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/encoding.c b/encoding.c
index 002c0c04fb..813b4b5062 100644
--- a/encoding.c
+++ b/encoding.c
@@ -738,8 +738,10 @@ rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
int n = ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e);
if (MBCLEN_CHARFOUND_P(n) && MBCLEN_CHARFOUND_LEN(n) <= e-p)
return MBCLEN_CHARFOUND_LEN(n);
- else
- return 1;
+ else {
+ int min = rb_enc_mbminlen(enc);
+ return min <= e-p ? min : e-p;
+ }
}
int