From: nobu.nakada@... Date: 2001-08-31T19:56:04+09:00 Subject: [ruby-dev:14606] Re: library search path なかだです。  ずいぶん前の話を蒸し返すようですが。 At Tue, 24 Jul 2001 15:51:52 +0900, matz@ruby-lang.org (Yukihiro Matsumoto) wrote: > | $(dir1)/foo.rb > | $(dir1)/foo.$(DLEXT) > | $(dir1)/foo.$(DLEXT2) > | $(dir1)/$(arch)/foo.rb > | $(dir1)/$(arch)/foo.$(DLEXT) > | $(dir1)/$(arch)/foo.$(DLEXT2) > > とか。_noext関数を導入したのはこの順序を実現するためだったよ > うな。  今拡張子を指定せずにrequireしたときにはこうなってますが、.oや .soを指定したときにはDLEXT2のある環境では、こうなっています。 $(dir1)/foo.$(DLEXT) $(dir2)/foo.$(DLEXT) $(dir1)/foo.$(DLEXT2) $(dir2)/foo.$(DLEXT2)  無指定のときと揃えるためには、こうなるべきなのでは。 $(dir1)/foo.$(DLEXT) $(dir1)/foo.$(DLEXT2) $(dir2)/foo.$(DLEXT) $(dir2)/foo.$(DLEXT2) # つーか、DLEXT2探してないし。 Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.201 diff -u -2 -p -r1.201 eval.c --- eval.c 2001/08/29 06:28:44 1.201 +++ eval.c 2001/08/31 10:46:05 @@ -5394,4 +5394,12 @@ rb_feature_p(feature, wait) } +static const char *const loadable_ext[] = { + ".rb", DLEXT, +#ifdef DLEXT2 + DLEXT2, +#endif + 0 +}; + int rb_provided(feature) @@ -5401,5 +5409,5 @@ rb_provided(feature) if (strrchr(feature, '.') == 0) { - if (rb_find_file_noext(&f) == 0) { + if (rb_find_file_ext(&f, loadable_ext) == 0) { return Qfalse; } @@ -5445,12 +5453,12 @@ rb_f_require(obj, fname) else if (strcmp(".so", ext) == 0 || strcmp(".o", ext) == 0) { fname = rb_str_new(RSTRING(fname)->ptr, ext-RSTRING(fname)->ptr); - feature = tmp = rb_str_dup(fname); - rb_str_cat2(tmp, DLEXT); - tmp = rb_find_file(tmp); - if (tmp) { - fname = tmp; +#ifdef DLEXT2 + tmp = fname; + if (rb_find_file_ext(&tmp, loadable_ext+1)) { + feature = tmp; + fname = rb_find_file(tmp); goto load_dyna; } -#ifdef DLEXT2 +#else feature = tmp = rb_str_dup(fname); rb_str_cat2(tmp, DLEXT); @@ -5482,5 +5490,5 @@ rb_f_require(obj, fname) } tmp = fname; - switch (rb_find_file_noext(&tmp)) { + switch (rb_find_file_ext(&tmp, loadable_ext)) { case 0: break; Index: file.c =================================================================== RCS file: /cvs/ruby/src/ruby/file.c,v retrieving revision 1.69 diff -u -2 -p -r1.69 file.c --- file.c 2001/08/23 06:02:14 1.69 +++ file.c 2001/08/31 10:46:19 @@ -2285,6 +2285,7 @@ extern VALUE rb_load_path; int -rb_find_file_noext(filep) +rb_find_file_ext(filep, ext) VALUE *filep; + char **ext; { char *path, *e, *found; @@ -2293,12 +2294,4 @@ rb_find_file_noext(filep) int i, j; - static char *ext[] = { - ".rb", DLEXT, -#ifdef DLEXT2 - DLEXT2, -#endif - 0 - }; - if (f[0] == '~') { fname = *filep; -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦