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

ruby-changes:3325

From: ko1@a...
Date: 31 Dec 2007 23:58:15 +0900
Subject: [ruby-changes:3325] nobu - Ruby:r14820 (trunk): * ruby.c (proc_options, process_options): delays finding encoding

nobu	2007-12-31 23:57:46 +0900 (Mon, 31 Dec 2007)

  New Revision: 14820

  Modified files:
    trunk/ruby.c

  Log:
    * ruby.c (proc_options, process_options): delays finding encoding
      until load_path is set.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ruby.c?r1=14820&r2=14819

Index: ruby.c
===================================================================
--- ruby.c	(revision 14819)
+++ ruby.c	(revision 14820)
@@ -81,6 +81,7 @@
     int yydebug;
     char *script;
     VALUE e_script;
+    VALUE enc_name;
     int enc_index;
 };
 
@@ -723,7 +724,7 @@
 		    break;
 		}
 		if (enc) {
-		    opt->enc_index = rb_enc_find_index(rb_enc_name(enc));
+		    opt->enc_name = rb_str_new2(rb_enc_name(enc));
 		}
 		s++;
 	    }
@@ -789,16 +790,12 @@
             else if (strcmp("disable-gems", s) == 0)
 		opt->disable_gems = 1;
 	    else if (strcmp("encoding", s) == 0) {
-		int idx;
 		if (!--argc || !(s = *++argv)) {
 		  noencoding:
 		    rb_raise(rb_eRuntimeError, "missing argument for --encoding");
 		}
 	      encoding:
-		if ((idx = rb_enc_find_index(s)) < 0) {
-		    rb_raise(rb_eRuntimeError, "unknown encoding name - %s", s);
-		}
-		opt->enc_index = idx;
+		opt->enc_name = rb_str_new2(s);
 	    }
 	    else if (strncmp("encoding=", s, 9) == 0) {
 		if (!*(s += 9)) goto noencoding;
@@ -967,6 +964,12 @@
     ruby_init_gems(opt);
     parser = rb_parser_new();
     if (opt->yydebug) rb_parser_set_yydebug(parser, Qtrue);
+    if (opt->enc_name != 0) {
+	s = RSTRING_PTR(opt->enc_name);
+	if ((opt->enc_index = rb_enc_find_index(s)) < 0) {
+	    rb_raise(rb_eRuntimeError, "unknown encoding name - %s", s);
+	}
+    }
     if (opt->e_script) {
 	if (opt->enc_index >= 0)
 	    rb_enc_associate_index(opt->e_script, opt->enc_index);

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

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