diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-25 09:07:32 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-12-25 09:07:32 +0000 |
commit | ead329fd8ea6f0ecf11c6ec98e073eed6fe2810c (patch) | |
tree | 058477d4c73b52a1dee3635363c5a947a54c7b5d /encoding.c | |
parent | 8e4c6d848216495cf4ddde1aae52f9ac3c0c0801 (diff) | |
download | ruby-ead329fd8ea6f0ecf11c6ec98e073eed6fe2810c.tar.gz |
* string.c (rb_str_inspect): don't call rb_enc_codepoint with empty
string. fix '#'.inspect.
* encoding.c (rb_enc_codepoint): raise on empty string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/encoding.c b/encoding.c index cfa49a5122..ee0fdadb39 100644 --- a/encoding.c +++ b/encoding.c @@ -662,7 +662,10 @@ rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc) int rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc) { - int r = rb_enc_precise_mbclen(p, e, enc); + int r; + if (e <= p) + rb_raise(rb_eArgError, "empty string"); + r = rb_enc_precise_mbclen(p, e, enc); if (MBCLEN_CHARFOUND(r)) return ONIGENC_MBC_TO_CODE(enc,(UChar*)p,(UChar*)e); else |