mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
encoding.c: load by rb_require_internal
* encoding.c (load_encoding): use rb_require_internal instead of calling rb_require_safe with protection. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
638ba47303
commit
aacc35e144
4 changed files with 10 additions and 11 deletions
|
@ -1,3 +1,8 @@
|
|||
Wed Dec 3 17:13:24 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* 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@ruby-lang.org>
|
||||
|
||||
* enc/encinit.c.erb (Init_enc): initialize encdb and transdb
|
||||
|
|
13
encoding.c
13
encoding.c
|
@ -629,13 +629,6 @@ rb_enc_registered(const char *name)
|
|||
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)
|
|||
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)
|
|||
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;
|
||||
|
|
|
@ -733,6 +733,7 @@ VALUE rb_iseq_method_name(VALUE self);
|
|||
/* 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 */
|
||||
|
|
2
load.c
2
load.c
|
@ -947,7 +947,7 @@ load_ext(VALUE path)
|
|||
* <0: not found (LoadError)
|
||||
* >1: exception
|
||||
*/
|
||||
static int
|
||||
int
|
||||
rb_require_internal(VALUE fname, int safe)
|
||||
{
|
||||
volatile int result = -1;
|
||||
|
|
Loading…
Reference in a new issue