ruby-changes:3630
From: ko1@a...
Date: Sat, 19 Jan 2008 08:43:07 +0900 (JST)
Subject: [ruby-changes:3630] nobu - Ruby:r15119 (trunk): * parse.y (parser_prepare): get encoding from the first line.
nobu 2008-01-19 08:35:38 +0900 (Sat, 19 Jan 2008)
New Revision: 15119
Modified files:
trunk/ChangeLog
trunk/parse.y
trunk/ruby.c
Log:
* parse.y (parser_prepare): get encoding from the first line.
[ruby-dev:33168]
* ruby.c (load_file): set encoding to input with set_encoding.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ruby.c?r1=15119&r2=15118&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=15119&r2=15118&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15119&r2=15118&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 15118)
+++ ChangeLog (revision 15119)
@@ -1,3 +1,10 @@
+Sat Jan 19 08:35:36 2008 Nobuyoshi Nakada <nobu@r...>
+
+ * parse.y (parser_prepare): get encoding from the first line.
+ [ruby-dev:33168]
+
+ * ruby.c (load_file): set encoding to input with set_encoding.
+
Sat Jan 19 03:46:42 2008 Yukihiro Matsumoto <matz@r...>
* thread.c (thread_create_core): prohibit thread creation in the
Index: parse.y
===================================================================
--- parse.y (revision 15118)
+++ parse.y (revision 15119)
@@ -4764,7 +4764,6 @@
lex_gets = lex_get_str;
lex_gets_ptr = 0;
lex_input = s;
- parser->enc = rb_enc_get(s);
lex_pbeg = lex_p = lex_pend = 0;
compile_for_eval = rb_parse_in_eval();
@@ -5957,6 +5956,7 @@
return;
}
pushback(c);
+ parser->enc = rb_enc_get(lex_lastline);
}
#define IS_ARG() (lex_state == EXPR_ARG || lex_state == EXPR_CMDARG)
@@ -9689,9 +9689,6 @@
rb_str_append(fname2, fname);
}
parser_initialize(parser);
- if (parser->parser_lex_gets == lex_get_str) {
- parser->enc = rb_enc_get(src);
- }
parser->parser_ruby_sourcefile_string = fname2;
parser->parser_ruby_sourcefile = RSTRING_PTR(fname2)+1;
Index: ruby.c
===================================================================
--- ruby.c (revision 15118)
+++ ruby.c (revision 15119)
@@ -1038,6 +1038,7 @@
VALUE f;
int line_start = 1;
NODE *tree = 0;
+ rb_encoding *enc;
if (!fname)
rb_load_fail(fname);
@@ -1151,11 +1152,17 @@
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)) {
rb_define_global_const("DATA", f);
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/