mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
2 changed files with 46 additions and 31 deletions
|
@ -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>
|
||||
|
||||
* mdoc2man.rb (parse_macro): Understand .Ux.
|
||||
|
|
73
eval.c
73
eval.c
|
@ -5599,14 +5599,16 @@ rb_provide(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
|
||||
rb_f_require(obj, fname)
|
||||
VALUE obj, fname;
|
||||
{
|
||||
VALUE feature, tmp;
|
||||
char *ext, *ftptr; /* OK */
|
||||
int state;
|
||||
volatile int safe = ruby_safe_level;
|
||||
char *ext; /* OK */
|
||||
|
||||
SafeStringValue(fname);
|
||||
ext = strrchr(RSTRING(fname)->ptr, '.');
|
||||
|
@ -5616,48 +5618,40 @@ rb_f_require(obj, fname)
|
|||
feature = rb_str_dup(fname);
|
||||
tmp = rb_find_file(fname);
|
||||
if (tmp) {
|
||||
fname = tmp;
|
||||
goto load_rb;
|
||||
return load_rb(feature, tmp);
|
||||
}
|
||||
goto not_found;
|
||||
load_failed(fname);
|
||||
}
|
||||
else if (strcmp(".so", ext) == 0 || strcmp(".o", ext) == 0) {
|
||||
tmp = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr);
|
||||
#ifdef DLEXT2
|
||||
if (rb_find_file_ext(&tmp, loadable_ext+1)) {
|
||||
feature = tmp;
|
||||
fname = rb_find_file(tmp);
|
||||
goto load_dyna;
|
||||
return load_dyna(tmp, rb_find_file(tmp));
|
||||
}
|
||||
#else
|
||||
feature = tmp;
|
||||
rb_str_cat2(tmp, DLEXT);
|
||||
tmp = rb_find_file(tmp);
|
||||
if (tmp) {
|
||||
fname = tmp;
|
||||
goto load_dyna;
|
||||
return load_dyna(feature, tmp);
|
||||
}
|
||||
#endif
|
||||
goto not_found;
|
||||
load_failed(fname);
|
||||
}
|
||||
else if (strcmp(DLEXT, ext) == 0) {
|
||||
tmp = rb_find_file(fname);
|
||||
if (tmp) {
|
||||
feature = fname;
|
||||
fname = tmp;
|
||||
goto load_dyna;
|
||||
return load_dyna(fname, tmp);
|
||||
}
|
||||
goto not_found;
|
||||
load_failed(fname);
|
||||
}
|
||||
#ifdef DLEXT2
|
||||
else if (strcmp(DLEXT2, ext) == 0) {
|
||||
tmp = rb_find_file(fname);
|
||||
if (tmp) {
|
||||
feature = fname;
|
||||
fname = tmp;
|
||||
goto load_dyna;
|
||||
return load_dyna(fname, tmp);
|
||||
}
|
||||
goto not_found;
|
||||
load_failed(fname);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -5667,20 +5661,29 @@ rb_f_require(obj, fname)
|
|||
break;
|
||||
|
||||
case 1:
|
||||
feature = fname = tmp;
|
||||
goto load_rb;
|
||||
return load_rb(tmp, tmp);
|
||||
|
||||
default:
|
||||
feature = tmp;
|
||||
fname = rb_find_file(tmp);
|
||||
goto load_dyna;
|
||||
return load_dyna(tmp, rb_find_file(tmp));
|
||||
}
|
||||
if (rb_feature_p(RSTRING(fname)->ptr, Qfalse))
|
||||
return Qfalse;
|
||||
not_found:
|
||||
rb_raise(rb_eLoadError, "No such file to load -- %s", RSTRING(fname)->ptr);
|
||||
if (!rb_feature_p(RSTRING(fname)->ptr, Qfalse))
|
||||
load_failed(fname);
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
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))
|
||||
return Qfalse;
|
||||
rb_provide_feature(feature);
|
||||
|
@ -5710,8 +5713,16 @@ rb_f_require(obj, fname)
|
|||
if (state) JUMP_TAG(state);
|
||||
|
||||
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))
|
||||
return Qfalse;
|
||||
ruby_safe_level = 0;
|
||||
|
|
Loading…
Reference in a new issue