From d5fec27d8e1fe31c38b199c1803db9dbdfaa7da7 Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 1 Mar 2008 01:02:30 +0000 Subject: [PATCH] * string.c (rb_str_coderange_scan_restartable): should not return offset in the middle of a character. * string.c (rb_str_coderange_scan_restartable): should not return invalid cr value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ string.c | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7189913f6b..0236af24a7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Mar 1 10:01:30 2008 Yukihiro Matsumoto + + * string.c (rb_str_coderange_scan_restartable): should not return + offset in the middle of a character. + + * string.c (rb_str_coderange_scan_restartable): should not return + invalid cr value. + Sat Mar 1 09:36:08 2008 Yukihiro Matsumoto * sprintf.c (rb_str_format): "%#.0o" should keep prefix where diff --git a/string.c b/string.c index ee8641e9b2..e8a34b7de0 100644 --- a/string.c +++ b/string.c @@ -224,8 +224,8 @@ rb_str_coderange_scan_restartable(const char *s, const char *e, rb_encoding *enc while (p < e) { int ret = rb_enc_precise_mbclen(p, e, enc); if (!MBCLEN_CHARFOUND_P(ret)) { - *cr = MBCLEN_INVALID_P(ret) ? ENC_CODERANGE_BROKEN: ret; - return e - s; + *cr = MBCLEN_INVALID_P(ret) ? ENC_CODERANGE_BROKEN: ENC_CODERANGE_UNKNOWN; + return p - s; } p += MBCLEN_CHARFOUND_LEN(ret); if (p < e) { @@ -243,7 +243,7 @@ rb_str_coderange_scan_restartable(const char *s, const char *e, rb_encoding *enc while (p < e) { int ret = rb_enc_precise_mbclen(p, e, enc); if (!MBCLEN_CHARFOUND_P(ret)) { - *cr = MBCLEN_INVALID_P(ret) ? ENC_CODERANGE_BROKEN: ret; + *cr = MBCLEN_INVALID_P(ret) ? ENC_CODERANGE_BROKEN: ENC_CODERANGE_UNKNOWN; return p - s; } p += MBCLEN_CHARFOUND_LEN(ret);