From b6280a0050a48b7317acb7c8935119fb012ef729 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 8 Dec 2007 19:10:58 +0000 Subject: * encoding.c (rb_enc_precise_mbclen): return needmore if underlying implementation returns a length longer than e-p. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- encoding.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'encoding.c') diff --git a/encoding.c b/encoding.c index e902f6db0..21b56f263 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) -- cgit