1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* encoding.c (rb_enc_codelen): raises invalid sequence exception

if ONIGENC_CODE_TO_MBCLEN() returns zero.  [ruby-dev:31661]

* encoding.c (rb_enc_mbclen): check invalid sequence.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13287 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-08-27 13:48:09 +00:00
parent a1a618ead1
commit 4461bd2f1f
3 changed files with 31 additions and 2 deletions

View file

@ -216,6 +216,26 @@ rb_enc_strlen(const char *p, const char *e, rb_encoding *enc)
return c;
}
int
rb_enc_mbclen(const char *p, rb_encoding *enc)
{
int n = ONIGENC_MBC_ENC_LEN(enc, (UChar*)p);
if (n == 0) {
rb_raise(rb_eArgError, "invalid mbstring sequence");
}
return n;
}
int
rb_enc_codelen(int c, rb_encoding *enc)
{
int n = ONIGENC_CODE_TO_MBCLEN(enc,c);
if (n == 0) {
rb_raise(rb_eArgError, "invalid mbstring sequence");
}
return n;
}
int
rb_enc_toupper(int c, rb_encoding *enc)
{