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

ruby-changes:1957

From: ko1@a...
Date: 15 Sep 2007 17:32:23 +0900
Subject: [ruby-changes:1957] nobu - Ruby:r13448 (trunk): * parse.y (parser_initialize): set default encoding.

nobu	2007-09-15 17:32:12 +0900 (Sat, 15 Sep 2007)

  New Revision: 13448

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/ruby.c

  Log:
    * parse.y (parser_initialize): set default encoding.  [ruby-dev:31787]
    
    * ruby.c (load_file): make new parse instance after processing shebang
      line options.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ruby.c?r1=13448&r2=13447
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=13448&r2=13447
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13448&r2=13447

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 13447)
+++ ChangeLog	(revision 13448)
@@ -1,3 +1,10 @@
+Sat Sep 15 17:32:10 2007  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (parser_initialize): set default encoding.  [ruby-dev:31787]
+
+	* ruby.c (load_file): make new parse instance after processing shebang
+	  line options.
+
 Sat Sep 15 17:04:08 2007  Nobuyoshi Nakada  <nobu@r...>
 
 	* encoding.c (rb_enc_associate_index, rb_enc_get_index): check if
Index: parse.y
===================================================================
--- parse.y	(revision 13447)
+++ parse.y	(revision 13448)
@@ -8686,7 +8686,7 @@
 #ifdef YYMALLOC
     parser->heap = NULL;
 #endif
-    parser->enc = rb_enc_from_index(0);
+    parser->enc = onigenc_get_default_encoding();
 }
 
 extern void rb_mark_source_filename(char *);
Index: ruby.c
===================================================================
--- ruby.c	(revision 13447)
+++ ruby.c	(revision 13448)
@@ -64,7 +64,7 @@
 
 char *ruby_inplace_mode = 0;
 
-static NODE *load_file(VALUE, const char *, int);
+static NODE *load_file(VALUE *, const char *, int);
 static void forbid_setid(const char *);
 
 static VALUE do_loop = Qfalse, do_print = Qfalse;
@@ -880,16 +880,16 @@
     process_sflag();
 
     ruby_init_loadpath();
-    parser = rb_parser_new();
     if (e_script) {
 	require_libraries();
+	parser = rb_parser_new();
 	tree = rb_parser_compile_string(parser, script, e_script, 1);
     }
     else {
 	if (script[0] == '-' && !script[1]) {
 	    forbid_setid("program input from stdin");
 	}
-	tree = load_file(parser, script, 1);
+	tree = load_file(&parser, script, 1);
     }
 
     process_sflag();
@@ -911,7 +911,7 @@
 }
 
 static NODE *
-load_file(VALUE parser, const char *fname, int script)
+load_file(VALUE *parser, const char *fname, int script)
 {
     extern VALUE rb_stdin;
     VALUE f;
@@ -1027,8 +1027,9 @@
 	}
 	require_libraries();	/* Why here? unnatural */
     }
-    tree = (NODE *)rb_parser_compile_file(parser, fname, f, line_start);
-    if (script && rb_parser_end_seen_p(parser)) {
+    *parser = rb_parser_new();
+    tree = (NODE *)rb_parser_compile_file(*parser, fname, f, line_start);
+    if (script && rb_parser_end_seen_p(*parser)) {
 	rb_define_global_const("DATA", f);
     }
     else if (f != rb_stdin) {
@@ -1040,7 +1041,9 @@
 void *
 rb_load_file(const char *fname)
 {
-    return load_file(rb_parser_new(), fname, 0);
+    VALUE parser;
+
+    return load_file(&parser, fname, 0);
 }
 
 VALUE rb_progname;

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

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