* 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
This commit is contained in:
parent
8e4c6d8482
commit
ead329fd8e
@ -1,3 +1,10 @@
|
|||||||
|
Tue Dec 25 18:06:04 2007 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* 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.
|
||||||
|
|
||||||
Tue Dec 25 17:48:28 2007 Shugo Maeda <shugo@ruby-lang.org>
|
Tue Dec 25 17:48:28 2007 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* vm.c (rb_frame_method_id_and_class): new function to get the
|
* vm.c (rb_frame_method_id_and_class): new function to get the
|
||||||
|
@ -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 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))
|
if (MBCLEN_CHARFOUND(r))
|
||||||
return ONIGENC_MBC_TO_CODE(enc,(UChar*)p,(UChar*)e);
|
return ONIGENC_MBC_TO_CODE(enc,(UChar*)p,(UChar*)e);
|
||||||
else
|
else
|
||||||
|
3
string.c
3
string.c
@ -3025,7 +3025,8 @@ rb_str_inspect(VALUE str)
|
|||||||
|
|
||||||
p += n;
|
p += n;
|
||||||
if (c == '"'|| c == '\\' ||
|
if (c == '"'|| c == '\\' ||
|
||||||
(c == '#' && (cc = rb_enc_codepoint(p,pend,enc),
|
(c == '#' && p < pend &&
|
||||||
|
(cc = rb_enc_codepoint(p,pend,enc),
|
||||||
(cc == '$' || cc == '@' || cc == '{')))) {
|
(cc == '$' || cc == '@' || cc == '{')))) {
|
||||||
prefix_escape(result, c, enc);
|
prefix_escape(result, c, enc);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user