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

ruby-changes:6432

From: usa <ko1@a...>
Date: Tue, 8 Jul 2008 01:07:23 +0900 (JST)
Subject: [ruby-changes:6432] Ruby:r17948 (win32-unicode-test): * ruby.c (proc_options, process_options): now opt->e_script is an array

usa	2008-07-08 01:06:54 +0900 (Tue, 08 Jul 2008)

  New Revision: 17948

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=17948

  Log:
    * ruby.c (proc_options, process_options): now opt->e_script is an array
      of arrays. each arrays have two elements -- pos and string.
    

  Modified files:
    branches/win32-unicode-test/ChangeLog
    branches/win32-unicode-test/ruby.c

Index: win32-unicode-test/ChangeLog
===================================================================
--- win32-unicode-test/ChangeLog	(revision 17947)
+++ win32-unicode-test/ChangeLog	(revision 17948)
@@ -1,3 +1,8 @@
+Tue Jul  8 01:04:55 2008  NAKAMURA Usaku  <usa@r...>
+
+	* ruby.c (proc_options, process_options): now opt->e_script is an array
+	  of arrays. each arrays have two elements -- pos and string.
+
 Tue Jul  8 00:37:50 2008  NAKAMURA Usaku  <usa@r...>
 
 	* ruby.c (process_options): no need to call rb_w32_parse_cmdline() if
@@ -5,7 +10,7 @@
 
 Tue Jul  8 00:33:46 2008  NAKAMURA Usaku  <usa@r...>
 
-	* ruby.c (process_options): re-set e_script.
+	* ruby.c (proc_options, process_options): re-set e_script.
 
 Tue Jul  8 00:03:20 2008  NAKAMURA Usaku  <usa@r...>
 
Index: win32-unicode-test/ruby.c
===================================================================
--- win32-unicode-test/ruby.c	(revision 17947)
+++ win32-unicode-test/ruby.c	(revision 17948)
@@ -90,7 +90,6 @@
     const char *script;
     VALUE script_name;
     VALUE e_script;
-    VALUE e_script_pos;
     struct {
 	struct {
 	    VALUE name;
@@ -717,14 +716,12 @@
 		rb_raise(rb_eRuntimeError, "no code specified for -e");
 	    }
 	    if (!opt->e_script) {
-		opt->e_script = rb_str_new(0, 0);
+		opt->e_script = rb_ary_new();
 		if (opt->script == 0)
 		    opt->script = "-e";
-		opt->e_script_pos = rb_ary_new();
 	    }
-	    rb_str_cat2(opt->e_script, s);
-	    rb_str_cat2(opt->e_script, "\n");
-	    rb_ary_push(opt->e_script_pos, INT2FIX(argc0 - argc));
+	    rb_ary_push(opt->e_script,
+			rb_ary_new3(2, INT2FIX(argc0 - argc), rb_str_new2(s)));
 	    break;
 
 	  case 'r':
@@ -1104,13 +1101,11 @@
 #ifdef _WIN32
     if (enc != lenc &&
 	(argc = rb_w32_parse_cmdline(&argv, rb_enc_name(enc))) != 0) {
-	if (opt->e_script && opt->e_script_pos) {
-	    opt->e_script = rb_str_new(0, 0);
-	    for (i = 0; i < RARRAY_LEN(opt->e_script_pos); ++i) {
-		int pos = FIX2INT(RARRAY_PTR(opt->e_script_pos)[i]);
-		rb_enc_str_buf_cat(opt->e_script, argv[pos], strlen(argv[pos]),
-				   enc);
-		rb_str_cat2(opt->e_script, "\n");
+	if (opt->e_script) {
+	    for (i = 0; i < RARRAY_LEN(opt->e_script); ++i) {
+		int pos = FIX2INT(RARRAY_PTR(RARRAY_PTR(opt->e_script)[i])[0]);
+		RARRAY_PTR(RARRAY_PTR(opt->e_script)[i])[1] =
+		    rb_enc_str_new(argv[pos], strlen(argv[pos]), enc);
 	    }
 	}
 	argc -= opnum;
@@ -1124,15 +1119,22 @@
     rb_set_safe_level_force(safe);
     if (opt->e_script) {
 	rb_encoding *eenc;
+	VALUE script = rb_str_new(0, 0);
 	if (opt->src.enc.index >= 0) {
 	    eenc = rb_enc_from_index(opt->src.enc.index);
 	}
 	else {
 	    eenc = lenc;
 	}
-	rb_enc_associate(opt->e_script, eenc);
+	for (i = 0; i < RARRAY_LEN(opt->e_script); ++i) {
+	    VALUE str = RARRAY_PTR(RARRAY_PTR(opt->e_script)[i])[1];
+	    if (rb_enc_get_index(str) == 0)
+		rb_enc_associate(str, eenc);
+	    rb_str_buf_append(script, str);
+	    rb_str_cat2(script, "\n");
+	}
 	require_libraries(opt);
-	tree = rb_parser_compile_string(parser, opt->script, opt->e_script, 1);
+	tree = rb_parser_compile_string(parser, opt->script, script, 1);
     }
     else {
 	if (opt->script[0] == '-' && !opt->script[1]) {

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

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