summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-11 19:41:22 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-01-11 19:41:22 +0000
commit1c1e850274be79f620f1d8c1dd40ccea50c2a9c8 (patch)
treef921b2660ac1566b1b11b647ab5677b01c33d318
parentd6574e5901dd6619c309f998e5afe383cc9371b7 (diff)
downloadruby-1c1e850274be79f620f1d8c1dd40ccea50c2a9c8.tar.gz
ruby-1c1e850274be79f620f1d8c1dd40ccea50c2a9c8.tar.xz
ruby-1c1e850274be79f620f1d8c1dd40ccea50c2a9c8.zip
* ruby.c (process_options): -e'script' is locale encoding by default.
(load_file): ruby script from stdin is locale encoding by default. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14998 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ruby.c16
2 files changed, 13 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 5e05641d2..9326f8e36 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Jan 12 04:38:38 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * ruby.c (process_options): -e'script' is locale encoding by default.
+ (load_file): ruby script from stdin is locale encoding by default.
+
Sat Jan 12 04:31:59 2008 NARUSE, Yui <naruse@ruby-lang.org>
* ext/nkf/nkf-utf8/nkf.c: fix bug: -m was -m0.
diff --git a/ruby.c b/ruby.c
index dd0f4b669..5bb0065fe 100644
--- a/ruby.c
+++ b/ruby.c
@@ -984,9 +984,14 @@ process_options(VALUE arg)
if (opt->enc_name != 0) {
opt->enc_index = opt_enc_index(opt->enc_name);
}
+ if (opt->enc_index >= 0) {
+ enc = rb_enc_from_index(opt->enc_index);
+ }
+ else {
+ enc = rb_locale_encoding();
+ }
if (opt->e_script) {
- if (opt->enc_index >= 0)
- rb_enc_associate_index(opt->e_script, opt->enc_index);
+ rb_enc_associate(opt->e_script, enc);
require_libraries();
tree = rb_parser_compile_string(parser, opt->script, opt->e_script, 1);
}
@@ -1021,12 +1026,6 @@ process_options(VALUE arg)
}
}
- if (opt->enc_index >= 0) {
- enc = rb_enc_from_index(opt->enc_index);
- }
- else {
- enc = rb_locale_encoding();
- }
rb_enc_set_default_external(rb_enc_from_encoding(enc));
return (VALUE)tree;
@@ -1153,6 +1152,7 @@ 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);
+ else rb_enc_associate(f, rb_locale_encoding());
tree = (NODE *)rb_parser_compile_file(parser, fname, f, line_start);
if (script && rb_parser_end_seen_p(parser)) {
rb_define_global_const("DATA", f);