diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-16 04:32:09 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-07-16 04:32:09 +0000 |
commit | 241b1e6324112ef83bb0ddf614345ae39b0bf3c3 (patch) | |
tree | f191d4cce16f9569263ed4fae1f800eac65a7be5 | |
parent | 3495f2b87ac5be47433a34c08e2efd9732edb3a1 (diff) |
encoding.c: revert r41964
* encoding.c (enc_set_index): since r41967, old terminator is dealt
with in str_fill_term(). should not consider it here because this
function is called before any encoding is set.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | encoding.c | 20 |
2 files changed, 16 insertions, 13 deletions
@@ -1,3 +1,9 @@ +Tue Jul 16 13:32:06 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * encoding.c (enc_set_index): since r41967, old terminator is dealt + with in str_fill_term(). should not consider it here because this + function is called before any encoding is set. + Tue Jul 16 11:12:03 2013 Masaki Matsushita <glass.saga@gmail.com> * proc.c (rb_block_arity): raise ArgumentError if no block given. @@ -121,9 +127,6 @@ Mon Jul 15 02:21:39 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> * encoding.c (enc_inspect): use PRIsVALUE to preserve the result encoding. - * encoding.c (enc_set_index): deal with terminator so that - rb_enc_set_index also works. - Sun Jul 14 23:21:47 2013 Tanaka Akira <akr@fsij.org> * configure.in: Check __builtin_popcountl, __builtin_bswap32 and diff --git a/encoding.c b/encoding.c index 075c1abd65..7304a37877 100644 --- a/encoding.c +++ b/encoding.c @@ -752,14 +752,8 @@ rb_enc_get_index(VALUE obj) } static void -enc_set_index(VALUE obj, int oldidx, int idx, rb_encoding *enc) +enc_set_index(VALUE obj, int idx) { - int termlen = rb_enc_mbminlen(enc); - int oldtermlen = rb_enc_mbminlen(rb_enc_from_index(oldidx)); - - if (oldtermlen < termlen && RB_TYPE_P(obj, T_STRING)) { - rb_str_fill_terminator(obj, termlen); - } if (idx < ENCODING_INLINE_MAX) { ENCODING_SET_INLINED(obj, idx); return; @@ -772,14 +766,15 @@ void rb_enc_set_index(VALUE obj, int idx) { rb_check_frozen(obj); - enc_set_index(obj, ENCODING_GET(obj), idx, must_encindex(idx)); + must_encindex(idx); + enc_set_index(obj, idx); } VALUE rb_enc_associate_index(VALUE obj, int idx) { rb_encoding *enc; - int oldidx; + int oldidx, oldtermlen, termlen; /* enc_check_capable(obj);*/ rb_check_frozen(obj); @@ -794,7 +789,12 @@ rb_enc_associate_index(VALUE obj, int idx) !rb_enc_asciicompat(enc)) { ENC_CODERANGE_CLEAR(obj); } - enc_set_index(obj, oldidx, idx, enc); + termlen = rb_enc_mbminlen(enc); + oldtermlen = rb_enc_mbminlen(rb_enc_from_index(oldidx)); + if (oldtermlen < termlen && RB_TYPE_P(obj, T_STRING)) { + rb_str_fill_terminator(obj, termlen); + } + enc_set_index(obj, idx); return obj; } |