From 7ebe8d20d7a31b86ee9fecaec9fd966ca2e2c4f3 Mon Sep 17 00:00:00 2001 From: matz Date: Sat, 1 Mar 2008 01:02:30 +0000 Subject: * 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: http://svn.ruby-lang.org/repos/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 7189913f6..0236af24a 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 ee8641e9b..e8a34b7de 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); -- cgit