なかだです。

requireされたファイルの__FILE__をフルパスにしてみました。
これをやるまで気づいてなかったんですが、extmk.rbで設定している
$:は相対パスなので、ext/**/extconf.rbからは既にrequire済のもの
しか使えなくなっています。


Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.771 diff -U2 -p -r1.771 eval.c --- eval.c 18 Apr 2005 06:38:30 -0000 1.771 +++ eval.c 18 Apr 2005 14:37:40 -0000 @@ -6861,6 +6861,6 @@ rb_f_require(obj, fname) static int -search_required(fname, featurep, path) - VALUE fname, *featurep, *path; +search_required(fname, path) + VALUE fname, *path; { VALUE tmp; @@ -6868,5 +6868,4 @@ search_required(fname, featurep, path) int type; - *featurep = fname; *path = 0; ext = strrchr(ftptr = RSTRING(fname)->ptr, '.'); @@ -6874,5 +6873,11 @@ search_required(fname, featurep, path) if (strcmp(".rb", ext) == 0) { 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; } @@ -6880,10 +6885,11 @@ search_required(fname, featurep, path) if (rb_feature_p(ftptr, ext, Qfalse)) return 's'; tmp = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr); - *featurep = tmp; #ifdef DLEXT2 OBJ_FREEZE(tmp); if (rb_find_file_ext(&tmp, loadable_ext+1)) { - *featurep = tmp; - *path = 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'; } @@ -6891,5 +6897,9 @@ search_required(fname, featurep, path) rb_str_cat2(tmp, DLEXT); 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'; } @@ -6898,10 +6908,19 @@ search_required(fname, featurep, path) else if (IS_DLEXT(ext)) { 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; - 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: + ftptr = RSTRING(tmp)->ptr; if ((ext = rb_feature_p(ftptr, 0, Qfalse))) { type = strcmp(".rb", ext); @@ -6911,8 +6930,7 @@ search_required(fname, featurep, path) default: - *featurep = tmp; ext = strrchr(ftptr = RSTRING(tmp)->ptr, '.'); if (rb_feature_p(ftptr, ext, !--type)) break; - *path = rb_find_file(tmp); + *path = tmp; } return type ? 's' : 'r'; @@ -6948,5 +6966,5 @@ rb_require_safe(fname, safe) PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { - VALUE feature, path; + VALUE path; long handle; int found; @@ -6955,7 +6973,7 @@ rb_require_safe(fname, safe) FilePathValue(fname); *(volatile VALUE *)&fname = rb_str_new4(fname); - found = search_required(fname, &feature, &path); + found = search_required(fname, &path); if (found) { - if (!path || load_wait(RSTRING(feature)->ptr)) { + if (!path || load_wait(RSTRING(path)->ptr)) { result = Qfalse; } @@ -6969,5 +6987,5 @@ rb_require_safe(fname, safe) } /* 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); rb_load(path, 0); @@ -6985,5 +7003,5 @@ rb_require_safe(fname, safe) break; } - rb_provide_feature(feature); + rb_provide_feature(path); result = Qtrue; } Index: file.c =================================================================== RCS file: /cvs/ruby/src/ruby/file.c,v retrieving revision 1.198 diff -U2 -p -r1.198 file.c --- file.c 11 Apr 2005 13:30:10 -0000 1.198 +++ file.c 18 Apr 2005 14:16:48 -0000 @@ -4143,5 +4143,5 @@ rb_find_file_ext(filep, ext) found = dln_find_file(StringValueCStr(fname), path); if (found && file_load_ok(found)) { - *filep = fname; + *filep = rb_str_new2(found); return j+1; } Index: ext/extmk.rb =================================================================== RCS file: /cvs/ruby/src/ruby/ext/extmk.rb,v retrieving revision 1.77 diff -U2 -p -r1.77 extmk.rb --- ext/extmk.rb 17 Apr 2005 14:58:00 -0000 1.77 +++ ext/extmk.rb 18 Apr 2005 14:16:48 -0000 @@ -20,10 +20,10 @@ $extupdate = false $compiled = {} -$:.replace ["."] +$:.replace([Dir.pwd]) require 'rbconfig' -srcdir = File.dirname(File.dirname(__FILE__)) +srcdir = File.expand_path("../..", __FILE__) -$:.replace [srcdir, srcdir+"/lib", "."] +$:.unshift(srcdir, srcdir+"/lib") $topdir = "."
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦