diff options
| author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-18 23:35:38 +0000 |
|---|---|---|
| committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-01-18 23:35:38 +0000 |
| commit | 8c2c2ebf385b7f3eda71c1a4200633bd9efaded3 (patch) | |
| tree | 76b1538a643854a256c353a21bfa432bd6439fe9 /ruby.c | |
| parent | f256840920c9dac73c05a34a3d5e1e3b6021acc2 (diff) | |
| download | ruby-8c2c2ebf385b7f3eda71c1a4200633bd9efaded3.tar.gz ruby-8c2c2ebf385b7f3eda71c1a4200633bd9efaded3.tar.xz ruby-8c2c2ebf385b7f3eda71c1a4200633bd9efaded3.zip | |
* parse.y (parser_prepare): get encoding from the first line.
[ruby-dev:33168]
* ruby.c (load_file): set encoding to input with set_encoding.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
| -rw-r--r-- | ruby.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -1038,6 +1038,7 @@ load_file(VALUE parser, const char *fname, int script, struct cmdline_options *o VALUE f; int line_start = 1; NODE *tree = 0; + rb_encoding *enc; if (!fname) rb_load_fail(fname); @@ -1151,10 +1152,16 @@ load_file(VALUE parser, const char *fname, int script, struct cmdline_options *o require_libraries(); /* Why here? unnatural */ } if (opt->enc_index >= 0) { - rb_enc_associate_index(f, opt->enc_index); + enc = rb_enc_from_index(opt->enc_index); } else if (f == rb_stdin) { - rb_enc_associate(f, rb_locale_encoding()); + enc = rb_locale_encoding(); + } + else { + enc = 0; + } + if (enc) { + rb_funcall(f, rb_intern("set_encoding"), 1, rb_enc_from_encoding(enc)); } tree = (NODE *)rb_parser_compile_file(parser, fname, f, line_start); if (script && rb_parser_end_seen_p(parser)) { |
