dmyenc.c: try to load encdb
* load.c (ruby_require_internal): separate from rb_require_safe, not to raise exceptions. * ruby.c (process_options): remove unnatural encoding search. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
49b3b2d8a2
commit
f235dbeea5
@ -1,3 +1,10 @@
|
|||||||
|
Wed Dec 3 14:51:26 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* load.c (ruby_require_internal): separate from rb_require_safe,
|
||||||
|
not to raise exceptions.
|
||||||
|
|
||||||
|
* ruby.c (process_options): remove unnatural encoding search.
|
||||||
|
|
||||||
Wed Dec 3 14:34:07 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Dec 3 14:34:07 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* string.c (setup_fake_str): fake string does not share another
|
* string.c (setup_fake_str): fake string does not share another
|
||||||
|
6
dmyenc.c
6
dmyenc.c
@ -1,4 +1,10 @@
|
|||||||
|
#define require(name) ruby_require_internal(name, (unsigned int)sizeof(name)-1)
|
||||||
|
int ruby_require_internal(const char *, int);
|
||||||
|
|
||||||
void
|
void
|
||||||
Init_enc(void)
|
Init_enc(void)
|
||||||
{
|
{
|
||||||
|
if (require("enc/encdb.so") == 0) {
|
||||||
|
require("enc/trans/transdb.so");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
41
load.c
41
load.c
@ -940,10 +940,10 @@ load_ext(VALUE path)
|
|||||||
return (VALUE)dln_load(RSTRING_PTR(path));
|
return (VALUE)dln_load(RSTRING_PTR(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
static int
|
||||||
rb_require_safe(VALUE fname, int safe)
|
rb_require_internal(VALUE fname, int safe)
|
||||||
{
|
{
|
||||||
volatile VALUE result = Qnil;
|
volatile int result = -2;
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
volatile VALUE errinfo = th->errinfo;
|
volatile VALUE errinfo = th->errinfo;
|
||||||
int state;
|
int state;
|
||||||
@ -985,11 +985,11 @@ rb_require_safe(VALUE fname, int safe)
|
|||||||
}
|
}
|
||||||
if (found) {
|
if (found) {
|
||||||
if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) {
|
if (!path || !(ftptr = load_lock(RSTRING_PTR(path)))) {
|
||||||
result = Qfalse;
|
result = -1;
|
||||||
}
|
}
|
||||||
else if (!*ftptr) {
|
else if (!*ftptr) {
|
||||||
rb_provide_feature(path);
|
rb_provide_feature(path);
|
||||||
result = Qtrue;
|
result = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
switch (found) {
|
switch (found) {
|
||||||
@ -1004,7 +1004,7 @@ rb_require_safe(VALUE fname, int safe)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rb_provide_feature(path);
|
rb_provide_feature(path);
|
||||||
result = Qtrue;
|
result = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1013,11 +1013,7 @@ rb_require_safe(VALUE fname, int safe)
|
|||||||
|
|
||||||
rb_set_safe_level_force(saved.safe);
|
rb_set_safe_level_force(saved.safe);
|
||||||
if (state) {
|
if (state) {
|
||||||
JUMP_TAG(state);
|
return state;
|
||||||
}
|
|
||||||
|
|
||||||
if (NIL_P(result)) {
|
|
||||||
load_failed(fname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
th->errinfo = errinfo;
|
th->errinfo = errinfo;
|
||||||
@ -1031,6 +1027,29 @@ rb_require_safe(VALUE fname, int safe)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ruby_require_internal(const char *fname, unsigned int len)
|
||||||
|
{
|
||||||
|
struct RString fake;
|
||||||
|
VALUE str = rb_setup_fake_str(&fake, fname, len, 0);
|
||||||
|
return rb_require_internal(str, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
rb_require_safe(VALUE fname, int safe)
|
||||||
|
{
|
||||||
|
int result = rb_require_internal(fname, safe);
|
||||||
|
|
||||||
|
if (result > 0) {
|
||||||
|
JUMP_TAG(result);
|
||||||
|
}
|
||||||
|
if (result < -1) {
|
||||||
|
load_failed(fname);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result ? Qfalse : Qtrue;
|
||||||
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_require(const char *fname)
|
rb_require(const char *fname)
|
||||||
{
|
{
|
||||||
|
1
ruby.c
1
ruby.c
@ -1368,7 +1368,6 @@ process_options(int argc, char **argv, struct cmdline_options *opt)
|
|||||||
ruby_gc_set_params(opt->safe_level);
|
ruby_gc_set_params(opt->safe_level);
|
||||||
ruby_init_loadpath_safe(opt->safe_level);
|
ruby_init_loadpath_safe(opt->safe_level);
|
||||||
Init_enc();
|
Init_enc();
|
||||||
rb_enc_find_index("encdb");
|
|
||||||
lenc = rb_locale_encoding();
|
lenc = rb_locale_encoding();
|
||||||
rb_enc_associate(rb_progname, lenc);
|
rb_enc_associate(rb_progname, lenc);
|
||||||
rb_obj_freeze(rb_progname);
|
rb_obj_freeze(rb_progname);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user