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

ruby-changes:36619

From: nobu <ko1@a...>
Date: Wed, 3 Dec 2014 17:13:38 +0900 (JST)
Subject: [ruby-changes:36619] nobu:r48700 (trunk): encoding.c: load by rb_require_internal

nobu	2014-12-03 17:13:26 +0900 (Wed, 03 Dec 2014)

  New Revision: 48700

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

  Log:
    encoding.c: load by rb_require_internal
    
    * encoding.c (load_encoding): use rb_require_internal instead of
      calling rb_require_safe with protection.

  Modified files:
    trunk/ChangeLog
    trunk/encoding.c
    trunk/internal.h
    trunk/load.c
Index: encoding.c
===================================================================
--- encoding.c	(revision 48699)
+++ encoding.c	(revision 48700)
@@ -629,13 +629,6 @@ rb_enc_registered(const char *name) https://github.com/ruby/ruby/blob/trunk/encoding.c#L629
     return -1;
 }
 
-static VALUE
-require_enc(VALUE enclib)
-{
-    int safe = rb_safe_level();
-    return rb_require_safe(enclib, safe > 3 ? 3 : safe);
-}
-
 static int
 load_encoding(const char *name)
 {
@@ -643,8 +636,8 @@ load_encoding(const char *name) https://github.com/ruby/ruby/blob/trunk/encoding.c#L636
     VALUE verbose = ruby_verbose;
     VALUE debug = ruby_debug;
     VALUE errinfo;
-    VALUE loaded;
     char *s = RSTRING_PTR(enclib) + 4, *e = RSTRING_END(enclib) - 3;
+    int loaded;
     int idx;
 
     while (s < e) {
@@ -657,11 +650,11 @@ load_encoding(const char *name) https://github.com/ruby/ruby/blob/trunk/encoding.c#L650
     ruby_verbose = Qfalse;
     ruby_debug = Qfalse;
     errinfo = rb_errinfo();
-    loaded = rb_protect(require_enc, enclib, 0);
+    loaded = rb_require_internal(enclib, rb_safe_level());
     ruby_verbose = verbose;
     ruby_debug = debug;
     rb_set_errinfo(errinfo);
-    if (NIL_P(loaded)) return -1;
+    if (loaded < 0 || 1 < loaded) return -1;
     if ((idx = rb_enc_registered(name)) < 0) return -1;
     if (enc_autoload_p(enc_table.list[idx].enc)) return -1;
     return idx;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48699)
+++ ChangeLog	(revision 48700)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec  3 17:13:24 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* encoding.c (load_encoding): use rb_require_internal instead of
+	  calling rb_require_safe with protection.
+
 Wed Dec  3 16:47:35 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* enc/encinit.c.erb (Init_enc): initialize encdb and transdb
Index: load.c
===================================================================
--- load.c	(revision 48699)
+++ load.c	(revision 48700)
@@ -947,7 +947,7 @@ load_ext(VALUE path) https://github.com/ruby/ruby/blob/trunk/load.c#L947
  * <0: not found (LoadError)
  * >1: exception
  */
-static int
+int
 rb_require_internal(VALUE fname, int safe)
 {
     volatile int result = -1;
Index: internal.h
===================================================================
--- internal.h	(revision 48699)
+++ internal.h	(revision 48700)
@@ -733,6 +733,7 @@ VALUE rb_iseq_method_name(VALUE self); https://github.com/ruby/ruby/blob/trunk/internal.h#L733
 /* load.c */
 VALUE rb_get_load_path(void);
 VALUE rb_get_expanded_load_path(void);
+int rb_require_internal(VALUE fname, int safe);
 NORETURN(void rb_load_fail(VALUE, const char*));
 
 /* loadpath.c */

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

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