зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
bf2d82b280
Коммит
a906fce838
|
@ -1,3 +1,7 @@
|
|||
Sun Feb 17 14:07:24 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* string.c (str_strlen): rb_enc_strlen doesn't fail.
|
||||
|
||||
Sun Feb 17 13:03:48 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* string.c (str_sublen): use rb_enc_strlen.
|
||||
|
|
10
string.c
10
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);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Загрузка…
Ссылка в новой задаче