なかだです。

  requireに~で始まるファイル名を指定したとき、拡張子がついてな
いとロードできなくなってます。

$ echo p __FILE__ > ~/a.rb
$ ruby17 -v -r~/a -e0
ruby 1.7.1 (2001-07-03) [i686-linux]
0: No such file to load -- ~/a (LoadError)
$ ruby16 -v -r~/a -e0
ruby 1.6.4 (2001-07-02) [i686-linux]
0: No such file to load -- ~/a (LoadError)
$ ruby14 -v -r~/a -e0
ruby 1.4.6 (2000-08-16) [i686-linux]
"/home/nobu/a.rb"


Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.192 diff -u -2 -p -r1.192 eval.c --- eval.c 2001/07/03 09:37:08 1.192 +++ eval.c 2001/07/05 13:53:27 @@ -5460,5 +5460,10 @@ rb_f_require(obj, fname) #endif } - buf = ALLOCA_N(char, strlen(RSTRING(fname)->ptr) + 5); + obj = fname; + if (RSTRING(fname)->ptr[0] == '~') { + obj = rb_file_s_expand_path(1, &fname); + StringValue(obj); + } + buf = ALLOCA_N(char, strlen(RSTRING(obj)->ptr) + 5); strcpy(buf, RSTRING(fname)->ptr); switch (rb_find_file_noext(buf)) { Index: file.c =================================================================== RCS file: /cvs/ruby/src/ruby/file.c,v retrieving revision 1.58 diff -u -2 -p -r1.58 file.c --- file.c 2001/06/19 04:35:13 1.58 +++ file.c 2001/07/05 13:43:03 @@ -2234,10 +2234,4 @@ rb_find_file_noext(file) }; - if (file[0] == '~') { - fname = rb_str_new2(file); - fname = rb_file_s_expand_path(1, &fname); - file = StringValuePtr(fname); - } - if (is_absolute_path(file)) { for (i=0; ext[i]; i++) {
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦