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

ruby-changes:3737

From: ko1@a...
Date: Fri, 25 Jan 2008 13:18:31 +0900 (JST)
Subject: [ruby-changes:3737] usa - Ruby:r15226 (trunk): * ruby.c (proc_options, process_options, load_file): shouldn't effect

usa	2008-01-25 13:18:14 +0900 (Fri, 25 Jan 2008)

  New Revision: 15226

  Modified files:
    trunk/ChangeLog
    trunk/ruby.c

  Log:
    * ruby.c (proc_options, process_options, load_file): shouldn't effect
      --encoding to script encoding. [ruby-dev:33169]
    


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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15225)
+++ ChangeLog	(revision 15226)
@@ -1,3 +1,8 @@
+Fri Jan 25 13:15:23 2008  NAKAMURA Usaku  <usa@r...>
+
+	* ruby.c (proc_options, process_options, load_file): shouldn't effect
+	  --encoding to script encoding. [ruby-dev:33169]
+
 Fri Jan 25 10:31:58 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* */*.bat: set svn:mime-type to text/batch.
Index: ruby.c
===================================================================
--- ruby.c	(revision 15225)
+++ ruby.c	(revision 15226)
@@ -80,8 +80,12 @@
     int yydebug;
     char *script;
     VALUE e_script;
-    VALUE enc_name;
-    int enc_index;
+    struct {
+	struct {
+	    VALUE name;
+	    int index;
+	} enc;
+    } src, ext;
 };
 
 static NODE *load_file(VALUE, const char *, int, struct cmdline_options *);
@@ -723,7 +727,8 @@
 		    break;
 		}
 		if (enc_name) {
-		    opt->enc_name = rb_str_new2(enc_name);
+		    opt->src.enc.name = rb_str_new2(enc_name);
+		    opt->ext.enc.name = opt->src.enc.name;
 		}
 		s++;
 	    }
@@ -794,7 +799,7 @@
 		    rb_raise(rb_eRuntimeError, "missing argument for --encoding");
 		}
 	      encoding:
-		opt->enc_name = rb_str_new2(s);
+		opt->ext.enc.name = rb_str_new2(s);
 	    }
 	    else if (strncmp("encoding=", s, 9) == 0) {
 		if (!*(s += 9)) goto noencoding;
@@ -888,7 +893,8 @@
     argv += i;
 
     if (rb_safe_level() == 0 && (s = getenv("RUBYOPT"))) {
-	VALUE enc_name = opt->enc_name;
+	VALUE src_enc_name = opt->src.enc.name;
+	VALUE ext_enc_name = opt->ext.enc.name;
 
 	while (ISSPACE(*s))
 	    s++;
@@ -924,7 +930,10 @@
 		s = moreswitches(s, opt);
 	    }
 	}
-	if (enc_name) opt->enc_name = enc_name;
+	if (src_enc_name)
+	    opt->src.enc.name = src_enc_name;
+	if (ext_enc_name)
+	    opt->ext.enc.name = ext_enc_name;
     }
 
     if (opt->version) {
@@ -981,12 +990,15 @@
     ruby_init_gems(opt);
     parser = rb_parser_new();
     if (opt->yydebug) rb_parser_set_yydebug(parser, Qtrue);
-    if (opt->enc_name != 0) {
-	opt->enc_index = opt_enc_index(opt->enc_name);
+    if (opt->ext.enc.name != 0) {
+	opt->ext.enc.index = opt_enc_index(opt->ext.enc.name);
     }
-    if (opt->enc_index >= 0) {
-	enc = rb_enc_from_index(opt->enc_index);
+    if (opt->src.enc.name != 0) {
+	opt->src.enc.index = opt_enc_index(opt->src.enc.name);
     }
+    if (opt->ext.enc.index >= 0) {
+	enc = rb_enc_from_index(opt->ext.enc.index);
+    }
     else {
 	enc = rb_locale_encoding();
     }
@@ -1065,7 +1077,8 @@
 	VALUE c = 1;		/* something not nil */
 	VALUE line;
 	char *p;
-	int no_enc = !opt->enc_name;
+	int no_src_enc = !opt->src.enc.name;
+	int no_ext_enc = !opt->ext.enc.name;
 
 	if (opt->xflag) {
 	    forbid_setid("-x");
@@ -1142,20 +1155,28 @@
 		rb_io_ungetc(f, c);
 	    }
 	    rb_io_ungetc(f, INT2FIX('#'));
-	    if (no_enc && opt->enc_name) {
-		opt->enc_index = opt_enc_index(opt->enc_name);
+	    if (no_src_enc && opt->src.enc.name) {
+		opt->src.enc.index = opt_enc_index(opt->src.enc.name);
 	    }
+	    if (no_ext_enc && opt->ext.enc.name) {
+		opt->ext.enc.index = opt_enc_index(opt->ext.enc.name);
+	    }
 	}
 	else if (!NIL_P(c)) {
 	    rb_io_ungetc(f, c);
 	}
 	require_libraries();	/* Why here? unnatural */
     }
-    if (opt->enc_index >= 0) {
-	enc = rb_enc_from_index(opt->enc_index);
+    if (opt->src.enc.index >= 0) {
+	enc = rb_enc_from_index(opt->src.enc.index);
     }
     else if (f == rb_stdin) {
-	enc = rb_locale_encoding();
+	if (opt->ext.enc.index >= 0) {
+	    enc = rb_enc_from_index(opt->ext.enc.index);
+	}
+	else {
+	    enc = rb_locale_encoding();
+	}
     }
     else {
 	enc = 0;
@@ -1408,7 +1429,8 @@
     rb_argv0 = rb_progname;
     opt.argc = argc;
     opt.argv = argv;
-    opt.enc_index = -1;
+    opt.src.enc.index = -1;
+    opt.ext.enc.index = -1;
     tree = (NODE *)rb_vm_call_cfunc(rb_vm_top_self(),
 				    process_options, (VALUE)&opt,
 				    0, rb_progname);

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

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