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

ruby-changes:12176

From: nobu <ko1@a...>
Date: Thu, 25 Jun 2009 15:53:41 +0900 (JST)
Subject: [ruby-changes:12176] Ruby:r23852 (ruby_1_8): * ruby.c (load_file): preserves $..

nobu	2009-06-25 15:53:28 +0900 (Thu, 25 Jun 2009)

  New Revision: 23852

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

  Log:
    * ruby.c (load_file): preserves $..  [ruby-core:24024]

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/ruby.c
    branches/ruby_1_8/version.h

Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 23851)
+++ ruby_1_8/ChangeLog	(revision 23852)
@@ -1,3 +1,7 @@
+Thu Jun 25 15:53:25 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* ruby.c (load_file): preserves $..  [ruby-core:24024]
+
 Fri Jun 19 08:14:25 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* bignum.c (big_lshift, big_rshift): return Bignum always withou
Index: ruby_1_8/version.h
===================================================================
--- ruby_1_8/version.h	(revision 23851)
+++ ruby_1_8/version.h	(revision 23852)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.8.8"
-#define RUBY_RELEASE_DATE "2009-06-23"
+#define RUBY_RELEASE_DATE "2009-06-25"
 #define RUBY_VERSION_CODE 188
-#define RUBY_RELEASE_CODE 20090623
+#define RUBY_RELEASE_CODE 20090625
 #define RUBY_PATCHLEVEL -1
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
 #define RUBY_VERSION_TEENY 8
 #define RUBY_RELEASE_YEAR 2009
 #define RUBY_RELEASE_MONTH 6
-#define RUBY_RELEASE_DAY 23
+#define RUBY_RELEASE_DAY 25
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: ruby_1_8/ruby.c
===================================================================
--- ruby_1_8/ruby.c	(revision 23851)
+++ ruby_1_8/ruby.c	(revision 23852)
@@ -864,12 +864,19 @@
 
 extern int ruby__end__seen;
 
-static void
-load_file(fname, script)
+struct load_file_arg {
     const char *fname;
     int script;
+};
+
+static VALUE
+load_file_internal(arg)
+    VALUE arg;
 {
     extern VALUE rb_stdin;
+    struct load_file_arg *argp = (struct load_file_arg *)arg;
+    const char *fname = argp->fname;
+    int script = argp->script;
     VALUE f;
     int line_start = 1;
 
@@ -919,7 +926,7 @@
 	c = rb_io_getc(f);
 	if (c == INT2FIX('#')) {
 	    line = rb_io_gets(f);
-	    if (NIL_P(line)) return;
+	    if (NIL_P(line)) return Qnil;
 	    line_start++;
 
 	    if (RSTRING(line)->len > 2 && RSTRING(line)->ptr[0] == '!') {
@@ -972,7 +979,7 @@
 	    rb_io_ungetc(f, c);
 	}
 	require_libraries();	/* Why here? unnatural */
-	if (NIL_P(c)) return;
+	if (NIL_P(c)) return Qnil;
     }
     rb_compile_file(fname, f, line_start);
     if (script && ruby__end__seen) {
@@ -985,8 +992,28 @@
     if (ruby_parser_stack_on_heap()) {
         rb_gc();
     }
+
+    return Qnil;
 }
 
+static VALUE
+restore_lineno(lineno)
+    VALUE lineno;
+{
+    return rb_gv_set("$.", lineno);
+}
+
+static void
+load_file(fname, script)
+    const char *fname;
+    int script;
+{
+    struct load_file_arg arg;
+    arg.fname = fname;
+    arg.script = script;
+    rb_ensure(load_file_internal, (VALUE)&arg, restore_lineno, rb_gv_get("$."));
+}
+
 void
 rb_load_file(fname)
     const char *fname;

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

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