ruby-changes:2336
From: ko1@a...
Date: 6 Nov 2007 16:38:13 +0900
Subject: [ruby-changes:2336] nobu - Ruby:r13827 (trunk): * eval_load.c (loaded_feature_path): need to expand relative paths.
nobu 2007-11-06 16:37:49 +0900 (Tue, 06 Nov 2007)
New Revision: 13827
Modified files:
trunk/ChangeLog
trunk/eval_load.c
Log:
* eval_load.c (loaded_feature_path): need to expand relative paths.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/eval_load.c?r1=13827&r2=13826
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13827&r2=13826
Index: eval_load.c
===================================================================
--- eval_load.c (revision 13826)
+++ eval_load.c (revision 13827)
@@ -23,7 +23,19 @@
};
VALUE rb_load_path; /* to be moved to VM */
+static VALUE
+get_load_path(void)
+{
+ VALUE load_path = rb_load_path;
+ VALUE ary = rb_ary_new2(RARRAY_LEN(load_path));
+ long i;
+ for (i = 0; i < RARRAY_LEN(load_path); ++i) {
+ rb_ary_push(ary, rb_file_expand_path(RARRAY_PTR(load_path)[i], Qnil));
+ }
+ return ary;
+}
+
static VALUE
get_loaded_features(void)
{
@@ -37,12 +49,13 @@
}
static VALUE
-loaded_feature_path(const char *name, long vlen, const char *feature, long len)
+loaded_feature_path(const char *name, long vlen, const char *feature, long len,
+ VALUE load_path)
{
long i;
- for (i = 0; i < RARRAY_LEN(rb_load_path); ++i) {
- VALUE p = RARRAY_PTR(rb_load_path)[i];
+ for (i = 0; i < RARRAY_LEN(load_path); ++i) {
+ VALUE p = RARRAY_PTR(load_path)[i];
const char *s = StringValuePtr(p);
long n = RSTRING_LEN(p);
@@ -58,6 +71,7 @@
struct loaded_feature_searching {
const char *name;
long len;
+ VALUE load_path;
const char *result;
};
@@ -66,7 +80,7 @@
{
const char *s = (const char *)v;
struct loaded_feature_searching *fp = (struct loaded_feature_searching *)f;
- VALUE p = loaded_feature_path(s, strlen(s), fp->name, fp->len);
+ VALUE p = loaded_feature_path(s, strlen(s), fp->name, fp->len, fp->load_path);
if (!p) return ST_CONTINUE;
fp->result = s;
return ST_STOP;
@@ -75,7 +89,7 @@
static int
rb_feature_p(const char *feature, const char *ext, int rb, int expanded)
{
- VALUE v, features, p;
+ VALUE v, features, p, load_path = 0;
const char *f, *e;
long i, len, elen, n;
st_table *loading_tbl;
@@ -94,7 +108,9 @@
f = StringValuePtr(v);
if ((n = RSTRING_LEN(v)) < len) continue;
if (strncmp(f, feature, len) != 0) {
- if (expanded || !(p = loaded_feature_path(f, n, feature, len)))
+ if (expanded) continue;
+ if (!load_path) load_path = get_load_path();
+ if (!(p = loaded_feature_path(f, n, feature, len, load_path)))
continue;
f += RSTRING_LEN(p) + 1;
}
@@ -116,6 +132,7 @@
struct loaded_feature_searching fs;
fs.name = feature;
fs.len = len;
+ fs.load_path = load_path ? load_path : get_load_path();
fs.result = 0;
st_foreach(loading_tbl, loaded_feature_path_i, (st_data_t)&fs);
if (fs.result) goto loading;
Index: ChangeLog
===================================================================
--- ChangeLog (revision 13826)
+++ ChangeLog (revision 13827)
@@ -1,5 +1,7 @@
-Tue Nov 6 15:52:01 2007 Nobuyoshi Nakada <nobu@r...>
+Tue Nov 6 16:37:47 2007 Nobuyoshi Nakada <nobu@r...>
+ * eval_load.c (loaded_feature_path): need to expand relative paths.
+
* eval_load.c (rb_feature_p): check if the feature is loading with
load path. [ruby-dev:31932]
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml