diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-07 06:44:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-07 06:44:46 +0000 |
commit | cfa0035962f7c373ca612be5bee749803368fd5b (patch) | |
tree | 3b040a18394f2e81079d356f76c5a136b6986fcd /encoding.c | |
parent | f4ca906d5c3267c0f84db4c5780829783c71a8b6 (diff) | |
download | ruby-cfa0035962f7c373ca612be5bee749803368fd5b.tar.gz |
* encoding.c (rb_enc_set_index, rb_enc_associate_index): should
check if frozen.
* parse.y (rb_intern3), ruby.c (process_options, ruby_script):
defer freezing after associating encodings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'encoding.c')
-rw-r--r-- | encoding.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/encoding.c b/encoding.c index 95b2767911..0b6bf96bc5 100644 --- a/encoding.c +++ b/encoding.c @@ -685,8 +685,8 @@ rb_enc_get_index(VALUE obj) return i; } -void -rb_enc_set_index(VALUE obj, int idx) +static void +enc_set_index(VALUE obj, int idx) { if (idx < ENCODING_INLINE_MAX) { ENCODING_SET_INLINED(obj, idx); @@ -694,13 +694,20 @@ rb_enc_set_index(VALUE obj, int idx) } ENCODING_SET_INLINED(obj, ENCODING_INLINE_MAX); rb_ivar_set(obj, rb_id_encoding(), INT2NUM(idx)); - return; +} + +void +rb_enc_set_index(VALUE obj, int idx) +{ + rb_check_frozen(obj); + enc_set_index(obj, idx); } VALUE rb_enc_associate_index(VALUE obj, int idx) { /* enc_check_capable(obj);*/ + rb_check_frozen(obj); if (rb_enc_get_index(obj) == idx) return obj; if (SPECIAL_CONST_P(obj)) { @@ -710,7 +717,7 @@ rb_enc_associate_index(VALUE obj, int idx) !rb_enc_asciicompat(rb_enc_from_index(idx))) { ENC_CODERANGE_CLEAR(obj); } - rb_enc_set_index(obj, idx); + enc_set_index(obj, idx); return obj; } |