[前][次][番号順一覧][スレッド一覧]

ruby-changes:3742

From: ko1@a...
Date: Fri, 25 Jan 2008 16:11:32 +0900 (JST)
Subject: [ruby-changes:3742] nobu - Ruby:r15231 (trunk): * ruby.c (process_options, load_file, rb_load_file): propagates script

nobu	2008-01-25 16:11:18 +0900 (Fri, 25 Jan 2008)

  New Revision: 15231

  Modified files:
    trunk/ChangeLog
    trunk/ruby.c

  Log:
    * ruby.c (process_options, load_file, rb_load_file): propagates script
      encoding by -K to libraries.  [ruby-dev:33156]


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ruby.c?r1=15231&r2=15230&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15231&r2=15230&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15230)
+++ ChangeLog	(revision 15231)
@@ -1,3 +1,8 @@
+Fri Jan 25 16:11:16 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* ruby.c (process_options, load_file, rb_load_file): propagates script
+	  encoding by -K to libraries.  [ruby-dev:33156]
+
 Fri Jan 25 15:56:48 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* ruby.c (cmdline_arguments): split argc and argv from cmdline_options.
Index: ruby.c
===================================================================
--- ruby.c	(revision 15230)
+++ ruby.c	(revision 15231)
@@ -881,6 +881,8 @@
     return i;
 }
 
+static int src_encoding_index = -1; /* TODO: VM private */
+
 static VALUE
 process_options(VALUE arg)
 {
@@ -1000,6 +1002,7 @@
     }
     if (opt->src.enc.name != 0) {
 	opt->src.enc.index = opt_enc_index(opt->src.enc.name);
+	src_encoding_index = opt->src.enc.index;
     }
     if (opt->ext.enc.index >= 0) {
 	enc = rb_enc_from_index(opt->ext.enc.index);
@@ -1181,6 +1184,7 @@
 	    rb_io_ungetc(f, INT2FIX('#'));
 	    if (no_src_enc && opt->src.enc.name) {
 		opt->src.enc.index = opt_enc_index(opt->src.enc.name);
+		src_encoding_index = opt->src.enc.index;
 	    }
 	    if (no_ext_enc && opt->ext.enc.name) {
 		opt->ext.enc.index = opt_enc_index(opt->ext.enc.name);
@@ -1224,6 +1228,7 @@
     struct cmdline_options opt;
 
     MEMZERO(&opt, opt, 1);
+    opt.src.enc.index = src_encoding_index;
     return load_file(rb_parser_new(), fname, 0, &opt);
 }
 
@@ -1455,7 +1460,7 @@
     args.argc = argc;
     args.argv = argv;
     args.opt = &opt;
-    opt.src.enc.index = -1;
+    opt.src.enc.index = src_encoding_index;
     opt.ext.enc.index = -1;
     tree = (NODE *)rb_vm_call_cfunc(rb_vm_top_self(),
 				    process_options, (VALUE)&args,

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]