diff --git a/ChangeLog b/ChangeLog index 28c8c73f22..1238e5bec1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,9 @@ -Sun Dec 9 03:29:02 2007 Tanaka Akira +Sun Dec 9 04:01:28 2007 Tanaka Akira * encoding.c (rb_enc_mbclen): return 1 if underlying implementation returns a length longer than e-p. + (rb_enc_precise_mbclen): return needmore if underlying + implementation returns a length longer than e-p. Sat Dec 8 17:59:40 2007 Tanaka Akira diff --git a/encoding.c b/encoding.c index e902f6db0e..21b56f2636 100644 --- a/encoding.c +++ b/encoding.c @@ -496,9 +496,13 @@ rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc) int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc) { + int n; if (e <= p) return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(1); - return ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e); + n = ONIGENC_PRECISE_MBC_ENC_LEN(enc, (UChar*)p, (UChar*)e); + if (e-p < n) + return ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE(n-(e-p)); + return n; } int rb_enc_get_ascii(const char *p, const char *e, rb_encoding *enc)