From a906fce838e51ddaa6c1b22162959968bc77a30c Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 17 Feb 2008 05:08:43 +0000 Subject: [PATCH] * string.c (str_strlen): rb_enc_strlen doesn't fail. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ string.c | 10 ++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index b37fc4652e..3802e1a2fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun Feb 17 14:07:24 2008 Tanaka Akira + + * string.c (str_strlen): rb_enc_strlen doesn't fail. + Sun Feb 17 13:03:48 2008 Tanaka Akira * string.c (str_sublen): use rb_enc_strlen. diff --git a/string.c b/string.c index aef3d1896c..c9e3562af2 100644 --- a/string.c +++ b/string.c @@ -622,7 +622,6 @@ rb_enc_strlen(const char *p, const char *e, rb_encoding *enc) static long str_strlen(VALUE str, rb_encoding *enc) { - long len; const char *p, *e; if (single_byte_optimizable(str)) return RSTRING_LEN(str); @@ -632,7 +631,7 @@ str_strlen(VALUE str, rb_encoding *enc) #ifdef NONASCII_MASK if (ENC_CODERANGE(str) == ENC_CODERANGE_VALID && enc == rb_utf8_encoding()) { - len = 0; + long len = 0; if (sizeof(long) * 2 < e - p) { const unsigned long *s, *t; const VALUE lowbits = sizeof(unsigned long) - 1; @@ -661,13 +660,8 @@ str_strlen(VALUE str, rb_encoding *enc) } return len; } - else #endif - len = rb_enc_strlen(p, e, enc); - if (len < 0) { - rb_raise(rb_eArgError, "invalid mbstring sequence"); - } - return len; + return rb_enc_strlen(p, e, enc); } /*