summaryrefslogtreecommitdiff
path: root/ruby.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-23 01:42:53 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-23 01:42:53 +0000
commit4bc9096b23e29b02f46100462b3e38c9d5e73b4c (patch)
tree1fc57383541bde18a7dbe61dfd67abd8e9cb22cf /ruby.c
parent3493a66ec6d7e391f94a9ca819936a4342cc3427 (diff)
* ruby.c (process_options): encoding set by command line option takes
priority over the encoding in the source, as the primary encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby.c')
-rw-r--r--ruby.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/ruby.c b/ruby.c
index 8b14419e76..8fa0c445b5 100644
--- a/ruby.c
+++ b/ruby.c
@@ -843,6 +843,7 @@ process_options(VALUE arg)
char **argv = opt->argv;
NODE *tree = 0;
VALUE parser;
+ VALUE encoding;
const char *s;
int i = proc_options(argc, argv, opt);
@@ -970,7 +971,13 @@ process_options(VALUE arg)
}
}
- rb_set_primary_encoding(rb_parser_encoding(parser));
+ if (opt->enc_index >= 0) {
+ encoding = rb_enc_from_encoding(rb_enc_from_index(opt->enc_index));
+ }
+ else {
+ encoding = rb_parser_encoding(parser);
+ }
+ rb_set_primary_encoding(encoding);
return (VALUE)tree;
}