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

ruby-changes:3212

From: ko1@a...
Date: 25 Dec 2007 23:16:15 +0900
Subject: [ruby-changes:3212] nobu - Ruby:r14706 (trunk): * ruby.c (proc_options): encoding option in shbang and RUBYOPT did not

nobu	2007-12-25 23:16:03 +0900 (Tue, 25 Dec 2007)

  New Revision: 14706

  Modified files:
    trunk/ChangeLog
    trunk/ruby.c

  Log:
    * ruby.c (proc_options): encoding option in shbang and RUBYOPT did not
      work, do not store alloca()ed string in a parent scope struct.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ruby.c?r1=14706&r2=14705
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14706&r2=14705

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14705)
+++ ChangeLog	(revision 14706)
@@ -1,3 +1,8 @@
+Tue Dec 25 23:16:01 2007  Nobuyoshi Nakada  <nobu@r...>
+
+	* ruby.c (proc_options): encoding option in shbang and RUBYOPT did not
+	  work, do not store alloca()ed string in a parent scope struct.
+
 Tue Dec 25 22:56:52 2007  NAKAMURA Usaku  <usa@r...>
 
 	* win32/Makefile.sub (config.status): keep this file.
Index: ruby.c
===================================================================
--- ruby.c	(revision 14705)
+++ ruby.c	(revision 14706)
@@ -81,7 +81,6 @@
     int yydebug;
     char *script;
     VALUE e_script;
-    const char *enc_name;
     int enc_index;
 };
 
@@ -550,6 +549,7 @@
 {
     int argc0 = argc;
     const char *s;
+    const char *enc_name = 0;
 
     if (argc == 0)
 	return 0;
@@ -740,7 +740,7 @@
 		    break;
 		}
 		if (enc) {
-		    opt->enc_name = rb_enc_name(enc);
+		    opt->enc_index = rb_enc_find_index(rb_enc_name(enc));
 		}
 		s++;
 	    }
@@ -806,12 +806,16 @@
             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:
-		opt->enc_name = s;
+		if ((idx = rb_enc_find_index(s)) < 0) {
+		    rb_raise(rb_eRuntimeError, "unknown encoding name - %s", s);
+		}
+		opt->enc_index = idx;
 	    }
 	    else if (strncmp("encoding=", s, 9) == 0) {
 		if (!*(s += 9)) goto noencoding;
@@ -980,11 +984,6 @@
     ruby_init_gems(opt);
     parser = rb_parser_new();
     if (opt->yydebug) rb_parser_set_yydebug(parser, Qtrue);
-    if ((s = opt->enc_name) != 0) {
-	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

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