diff options
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 20 |
1 files changed, 10 insertions, 10 deletions
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; } |