* eval.c (rb_f_require): purge too many goto's.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3369 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
36583aac97
commit
79847e0b36
@ -1,3 +1,7 @@
|
|||||||
|
Mon Jan 20 18:22:40 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
|
* eval.c (rb_f_require): purge too many goto's.
|
||||||
|
|
||||||
Mon Jan 20 17:50:05 2003 Akinori MUSHA <knu@iDaemons.org>
|
Mon Jan 20 17:50:05 2003 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
* mdoc2man.rb (parse_macro): Understand .Ux.
|
* mdoc2man.rb (parse_macro): Understand .Ux.
|
||||||
|
71
eval.c
71
eval.c
@ -5599,14 +5599,16 @@ rb_provide(feature)
|
|||||||
rb_provide_feature(rb_str_new2(feature));
|
rb_provide_feature(rb_str_new2(feature));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NORETURN(static void load_failed _((VALUE)));
|
||||||
|
static VALUE load_dyna _((VALUE, VALUE));
|
||||||
|
static VALUE load_rb _((VALUE, VALUE));
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
rb_f_require(obj, fname)
|
rb_f_require(obj, fname)
|
||||||
VALUE obj, fname;
|
VALUE obj, fname;
|
||||||
{
|
{
|
||||||
VALUE feature, tmp;
|
VALUE feature, tmp;
|
||||||
char *ext, *ftptr; /* OK */
|
char *ext; /* OK */
|
||||||
int state;
|
|
||||||
volatile int safe = ruby_safe_level;
|
|
||||||
|
|
||||||
SafeStringValue(fname);
|
SafeStringValue(fname);
|
||||||
ext = strrchr(RSTRING(fname)->ptr, '.');
|
ext = strrchr(RSTRING(fname)->ptr, '.');
|
||||||
@ -5616,48 +5618,40 @@ rb_f_require(obj, fname)
|
|||||||
feature = rb_str_dup(fname);
|
feature = rb_str_dup(fname);
|
||||||
tmp = rb_find_file(fname);
|
tmp = rb_find_file(fname);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
fname = tmp;
|
return load_rb(feature, tmp);
|
||||||
goto load_rb;
|
|
||||||
}
|
}
|
||||||
goto not_found;
|
load_failed(fname);
|
||||||
}
|
}
|
||||||
else if (strcmp(".so", ext) == 0 || strcmp(".o", ext) == 0) {
|
else if (strcmp(".so", ext) == 0 || strcmp(".o", ext) == 0) {
|
||||||
tmp = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr);
|
tmp = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr);
|
||||||
#ifdef DLEXT2
|
#ifdef DLEXT2
|
||||||
if (rb_find_file_ext(&tmp, loadable_ext+1)) {
|
if (rb_find_file_ext(&tmp, loadable_ext+1)) {
|
||||||
feature = tmp;
|
return load_dyna(tmp, rb_find_file(tmp));
|
||||||
fname = rb_find_file(tmp);
|
|
||||||
goto load_dyna;
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
feature = tmp;
|
feature = tmp;
|
||||||
rb_str_cat2(tmp, DLEXT);
|
rb_str_cat2(tmp, DLEXT);
|
||||||
tmp = rb_find_file(tmp);
|
tmp = rb_find_file(tmp);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
fname = tmp;
|
return load_dyna(feature, tmp);
|
||||||
goto load_dyna;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
goto not_found;
|
load_failed(fname);
|
||||||
}
|
}
|
||||||
else if (strcmp(DLEXT, ext) == 0) {
|
else if (strcmp(DLEXT, ext) == 0) {
|
||||||
tmp = rb_find_file(fname);
|
tmp = rb_find_file(fname);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
feature = fname;
|
return load_dyna(fname, tmp);
|
||||||
fname = tmp;
|
|
||||||
goto load_dyna;
|
|
||||||
}
|
}
|
||||||
goto not_found;
|
load_failed(fname);
|
||||||
}
|
}
|
||||||
#ifdef DLEXT2
|
#ifdef DLEXT2
|
||||||
else if (strcmp(DLEXT2, ext) == 0) {
|
else if (strcmp(DLEXT2, ext) == 0) {
|
||||||
tmp = rb_find_file(fname);
|
tmp = rb_find_file(fname);
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
feature = fname;
|
return load_dyna(fname, tmp);
|
||||||
fname = tmp;
|
|
||||||
goto load_dyna;
|
|
||||||
}
|
}
|
||||||
goto not_found;
|
load_failed(fname);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -5667,20 +5661,29 @@ rb_f_require(obj, fname)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
feature = fname = tmp;
|
return load_rb(tmp, tmp);
|
||||||
goto load_rb;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
feature = tmp;
|
return load_dyna(tmp, rb_find_file(tmp));
|
||||||
fname = rb_find_file(tmp);
|
|
||||||
goto load_dyna;
|
|
||||||
}
|
}
|
||||||
if (rb_feature_p(RSTRING(fname)->ptr, Qfalse))
|
if (!rb_feature_p(RSTRING(fname)->ptr, Qfalse))
|
||||||
|
load_failed(fname);
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
not_found:
|
}
|
||||||
rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr);
|
|
||||||
|
static void
|
||||||
|
load_failed(fname)
|
||||||
|
VALUE fname;
|
||||||
|
{
|
||||||
|
rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
load_dyna(feature, fname)
|
||||||
|
VALUE feature, fname;
|
||||||
|
{
|
||||||
|
int state;
|
||||||
|
|
||||||
load_dyna:
|
|
||||||
if (rb_feature_p(RSTRING(feature)->ptr, Qfalse))
|
if (rb_feature_p(RSTRING(feature)->ptr, Qfalse))
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
rb_provide_feature(feature);
|
rb_provide_feature(feature);
|
||||||
@ -5710,8 +5713,16 @@ rb_f_require(obj, fname)
|
|||||||
if (state) JUMP_TAG(state);
|
if (state) JUMP_TAG(state);
|
||||||
|
|
||||||
return Qtrue;
|
return Qtrue;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
load_rb(feature, fname)
|
||||||
|
VALUE feature, fname;
|
||||||
|
{
|
||||||
|
int state;
|
||||||
|
char *ftptr;
|
||||||
|
volatile int safe = ruby_safe_level;
|
||||||
|
|
||||||
load_rb:
|
|
||||||
if (rb_feature_p(RSTRING(feature)->ptr, Qtrue))
|
if (rb_feature_p(RSTRING(feature)->ptr, Qtrue))
|
||||||
return Qfalse;
|
return Qfalse;
|
||||||
ruby_safe_level = 0;
|
ruby_safe_level = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user