mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (search_required, rb_require_safe): expand path in
rb_features. [ruby-dev:26079] * file.c (rb_find_file_ext): return absolute path. * ext/extmk.rb: expand path for ext/**/extconf.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ce3eb0b204
commit
8121738943
4 changed files with 48 additions and 21 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
Tue Apr 19 00:01:08 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (search_required, rb_require_safe): expand path in
|
||||||
|
rb_features. [ruby-dev:26079]
|
||||||
|
|
||||||
|
* file.c (rb_find_file_ext): return absolute path.
|
||||||
|
|
||||||
|
* ext/extmk.rb: expand path for ext/**/extconf.rb.
|
||||||
|
|
||||||
Mon Apr 18 15:37:35 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Mon Apr 18 15:37:35 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* eval.c (rb_attr): attribute name check added.
|
* eval.c (rb_attr): attribute name check added.
|
||||||
|
|
52
eval.c
52
eval.c
|
@ -6860,49 +6860,68 @@ rb_f_require(obj, fname)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
search_required(fname, featurep, path)
|
search_required(fname, path)
|
||||||
VALUE fname, *featurep, *path;
|
VALUE fname, *path;
|
||||||
{
|
{
|
||||||
VALUE tmp;
|
VALUE tmp;
|
||||||
char *ext, *ftptr;
|
char *ext, *ftptr;
|
||||||
int type;
|
int type;
|
||||||
|
|
||||||
*featurep = fname;
|
|
||||||
*path = 0;
|
*path = 0;
|
||||||
ext = strrchr(ftptr = RSTRING(fname)->ptr, '.');
|
ext = strrchr(ftptr = RSTRING(fname)->ptr, '.');
|
||||||
if (ext && !strchr(ext, '/')) {
|
if (ext && !strchr(ext, '/')) {
|
||||||
if (strcmp(".rb", ext) == 0) {
|
if (strcmp(".rb", ext) == 0) {
|
||||||
if (rb_feature_p(ftptr, ext, Qtrue)) return 'r';
|
if (rb_feature_p(ftptr, ext, Qtrue)) return 'r';
|
||||||
if (*path = rb_find_file(fname)) return 'r';
|
if (tmp = rb_find_file(fname)) {
|
||||||
|
tmp = rb_file_expand_path(tmp, Qnil);
|
||||||
|
ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
|
||||||
|
if (!rb_feature_p(ftptr, ext, Qtrue))
|
||||||
|
*path = tmp;
|
||||||
|
return 'r';
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (IS_SOEXT(ext)) {
|
else if (IS_SOEXT(ext)) {
|
||||||
if (rb_feature_p(ftptr, ext, Qfalse)) return 's';
|
if (rb_feature_p(ftptr, ext, Qfalse)) return 's';
|
||||||
tmp = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr);
|
tmp = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr);
|
||||||
*featurep = tmp;
|
|
||||||
#ifdef DLEXT2
|
#ifdef DLEXT2
|
||||||
OBJ_FREEZE(tmp);
|
OBJ_FREEZE(tmp);
|
||||||
if (rb_find_file_ext(&tmp, loadable_ext+1)) {
|
if (rb_find_file_ext(&tmp, loadable_ext+1)) {
|
||||||
*featurep = tmp;
|
tmp = rb_file_expand_path(tmp, Qnil);
|
||||||
*path = rb_find_file(tmp);
|
ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
|
||||||
|
if (!rb_feature_p(ftptr, ext, Qfalse))
|
||||||
|
*path = tmp;
|
||||||
return 's';
|
return 's';
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
rb_str_cat2(tmp, DLEXT);
|
rb_str_cat2(tmp, DLEXT);
|
||||||
OBJ_FREEZE(tmp);
|
OBJ_FREEZE(tmp);
|
||||||
if (*path = rb_find_file(tmp)) {
|
if (tmp = rb_find_file(tmp)) {
|
||||||
|
tmp = rb_file_expand_path(tmp, Qnil);
|
||||||
|
ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
|
||||||
|
if (!rb_feature_p(ftptr, ext, Qfalse))
|
||||||
|
*path = tmp;
|
||||||
return 's';
|
return 's';
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (IS_DLEXT(ext)) {
|
else if (IS_DLEXT(ext)) {
|
||||||
if (rb_feature_p(ftptr, ext, Qfalse)) return 's';
|
if (rb_feature_p(ftptr, ext, Qfalse)) return 's';
|
||||||
if (*path = rb_find_file(fname)) return 's';
|
if (tmp = rb_find_file(fname)) {
|
||||||
|
tmp = rb_file_expand_path(tmp, Qnil);
|
||||||
|
ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
|
||||||
|
if (!rb_feature_p(ftptr, ext, Qfalse))
|
||||||
|
*path = tmp;
|
||||||
|
return 's';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tmp = fname;
|
tmp = fname;
|
||||||
switch (type = rb_find_file_ext(&tmp, loadable_ext)) {
|
type = rb_find_file_ext(&tmp, loadable_ext);
|
||||||
|
tmp = rb_file_expand_path(tmp, Qnil);
|
||||||
|
switch (type) {
|
||||||
case 0:
|
case 0:
|
||||||
|
ftptr = RSTRING(tmp)->ptr;
|
||||||
if ((ext = rb_feature_p(ftptr, 0, Qfalse))) {
|
if ((ext = rb_feature_p(ftptr, 0, Qfalse))) {
|
||||||
type = strcmp(".rb", ext);
|
type = strcmp(".rb", ext);
|
||||||
break;
|
break;
|
||||||
|
@ -6910,10 +6929,9 @@ search_required(fname, featurep, path)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
*featurep = tmp;
|
|
||||||
ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
|
ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.');
|
||||||
if (rb_feature_p(ftptr, ext, !--type)) break;
|
if (rb_feature_p(ftptr, ext, !--type)) break;
|
||||||
*path = rb_find_file(tmp);
|
*path = tmp;
|
||||||
}
|
}
|
||||||
return type ? 's' : 'r';
|
return type ? 's' : 'r';
|
||||||
}
|
}
|
||||||
|
@ -6947,16 +6965,16 @@ rb_require_safe(fname, safe)
|
||||||
saved.safe = ruby_safe_level;
|
saved.safe = ruby_safe_level;
|
||||||
PUSH_TAG(PROT_NONE);
|
PUSH_TAG(PROT_NONE);
|
||||||
if ((state = EXEC_TAG()) == 0) {
|
if ((state = EXEC_TAG()) == 0) {
|
||||||
VALUE feature, path;
|
VALUE path;
|
||||||
long handle;
|
long handle;
|
||||||
int found;
|
int found;
|
||||||
|
|
||||||
ruby_safe_level = safe;
|
ruby_safe_level = safe;
|
||||||
FilePathValue(fname);
|
FilePathValue(fname);
|
||||||
*(volatile VALUE *)&fname = rb_str_new4(fname);
|
*(volatile VALUE *)&fname = rb_str_new4(fname);
|
||||||
found = search_required(fname, &feature, &path);
|
found = search_required(fname, &path);
|
||||||
if (found) {
|
if (found) {
|
||||||
if (!path || load_wait(RSTRING(feature)->ptr)) {
|
if (!path || load_wait(RSTRING(path)->ptr)) {
|
||||||
result = Qfalse;
|
result = Qfalse;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -6968,7 +6986,7 @@ rb_require_safe(fname, safe)
|
||||||
loading_tbl = st_init_strtable();
|
loading_tbl = st_init_strtable();
|
||||||
}
|
}
|
||||||
/* partial state */
|
/* partial state */
|
||||||
ftptr = ruby_strdup(RSTRING(feature)->ptr);
|
ftptr = ruby_strdup(RSTRING(path)->ptr);
|
||||||
st_insert(loading_tbl, (st_data_t)ftptr, (st_data_t)curr_thread);
|
st_insert(loading_tbl, (st_data_t)ftptr, (st_data_t)curr_thread);
|
||||||
rb_load(path, 0);
|
rb_load(path, 0);
|
||||||
break;
|
break;
|
||||||
|
@ -6984,7 +7002,7 @@ rb_require_safe(fname, safe)
|
||||||
rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
|
rb_ary_push(ruby_dln_librefs, LONG2NUM(handle));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rb_provide_feature(feature);
|
rb_provide_feature(path);
|
||||||
result = Qtrue;
|
result = Qtrue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,12 @@ $extlist = []
|
||||||
$extupdate = false
|
$extupdate = false
|
||||||
$compiled = {}
|
$compiled = {}
|
||||||
|
|
||||||
$:.replace ["."]
|
$:.replace([Dir.pwd])
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
|
|
||||||
srcdir = File.dirname(File.dirname(__FILE__))
|
srcdir = File.expand_path("../..", __FILE__)
|
||||||
|
|
||||||
$:.replace [srcdir, srcdir+"/lib", "."]
|
$:.unshift(srcdir, srcdir+"/lib")
|
||||||
|
|
||||||
$topdir = "."
|
$topdir = "."
|
||||||
$top_srcdir = srcdir
|
$top_srcdir = srcdir
|
||||||
|
|
2
file.c
2
file.c
|
@ -4142,7 +4142,7 @@ rb_find_file_ext(filep, ext)
|
||||||
OBJ_FREEZE(fname);
|
OBJ_FREEZE(fname);
|
||||||
found = dln_find_file(StringValueCStr(fname), path);
|
found = dln_find_file(StringValueCStr(fname), path);
|
||||||
if (found && file_load_ok(found)) {
|
if (found && file_load_ok(found)) {
|
||||||
*filep = fname;
|
*filep = rb_str_new2(found);
|
||||||
return j+1;
|
return j+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue