diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-24 17:17:35 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-24 17:17:35 +0000 |
commit | 42eeb2c1b1788c5975d2a383c9b0c3ff2c90b6b8 (patch) | |
tree | f7ec1977a708ccfede53c8367c748ce2c88642e4 /string.c | |
parent | 4b265d3e7bbb508bd0f846491b64ca06970bae60 (diff) | |
download | ruby-42eeb2c1b1788c5975d2a383c9b0c3ff2c90b6b8.tar.gz |
* string.c (rb_str_delete_bang): should recalculate coderange.
[ruby-talk:329267]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -1255,7 +1255,12 @@ rb_string_value(volatile VALUE *ptr) { VALUE s = *ptr; if (TYPE(s) != T_STRING) { - s = rb_str_to_str(s); + if (SYMBOL_P(s)) { + s = rb_sym_to_s(s); + } + else { + s = rb_str_to_str(s); + } *ptr = s; } return s; @@ -5070,7 +5075,7 @@ rb_str_delete_bang(int argc, VALUE *argv, VALUE str) char *s, *send, *t; VALUE del = 0, nodel = 0; int modify = 0; - int i, ascompat; + int i, ascompat, cr; if (RSTRING_LEN(str) == 0 || !RSTRING_PTR(str)) return Qnil; if (argc < 1) { @@ -5088,6 +5093,7 @@ rb_str_delete_bang(int argc, VALUE *argv, VALUE str) ascompat = rb_enc_asciicompat(enc); s = t = RSTRING_PTR(str); send = RSTRING_END(str); + cr = ascompat ? ENC_CODERANGE_7BIT : ENC_CODERANGE_VALID; while (s < send) { unsigned int c; int clen; @@ -5112,12 +5118,14 @@ rb_str_delete_bang(int argc, VALUE *argv, VALUE str) else { if (t != s) rb_enc_mbcput(c, t, enc); t += clen; + if (cr == ENC_CODERANGE_7BIT) cr = ENC_CODERANGE_VALID; } s += clen; } } *t = '\0'; STR_SET_LEN(str, t - RSTRING_PTR(str)); + ENC_CODERANGE_SET(str, cr); if (modify) return str; return Qnil; |