summaryrefslogtreecommitdiffstats
path: root/encoding.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-22 06:52:54 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-22 06:52:54 +0000
commitedcae0237fef7ff8a5d524b80ff91c697843eb01 (patch)
treeed95702464f90d637072a7912e6ad681262b3d2d /encoding.c
parent6c614a086387f23fb3ad4367dd2572ae3a0983e7 (diff)
downloadruby-edcae0237fef7ff8a5d524b80ff91c697843eb01.tar.gz
ruby-edcae0237fef7ff8a5d524b80ff91c697843eb01.tar.xz
ruby-edcae0237fef7ff8a5d524b80ff91c697843eb01.zip
* encoding.c (rb_enc_mbclen): return minlen instead of 1 when
a character is not found properly. * string.c (rb_enc_strlen): round up string length with fixed multibyte encoding such as UTF-32. (rb_enc_strlen_cr): ditto. (rb_str_substr): fix substring with fixed multibyte encoding. (rb_str_justify): check number of characters. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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 002c0c04f..813b4b506 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