Hi,

At Wed, 24 Nov 2004 23:49:16 +0900,
noreply / rubyforge.org wrote in [ruby-core:03806]:
> Here are the info:
> 16:46 > cat foo.rb 
>     def self.search_loadpath(file)
> p file
>       result = Dir.glob("{#{($LOAD_PATH).join(',')}}/#{file}{,.rb,.so}")
>       p result
>       result.delete_if {|f|  p f;File.directory?(f)}.size > 0
>       result
>     end
> search_loadpath("openssl.so")
> 16:46 > ruby foo.rb 
> "openssl.so"
> ["/sb/tb/toolbox3/sparc-sun-solaris2.5.1/lib/ruby/1.8/sparc-solaris2.8/openssl.so"]
> "/sb/tb/toolbox3/sparc-sun-solaris2.5.1/lib/ruby/1.8/sparc-solaris2.8/openssl.so"
> foo.rb:5:in `directory?': string contains null byte (ArgumentError)
>         from foo.rb:5:in `search_loadpath'
>         from foo.rb:5:in `delete_if'
>         from foo.rb:5:in `search_loadpath'
>         from foo.rb:8
> 16:46 > ruby -v
> ruby 1.8.2 (2004-11-24) [sparc-solaris2.8]

Buffer string is reused.


Index: dir.c =================================================================== RCS file: /cvs/ruby/src/ruby/dir.c,v retrieving revision 1.92.2.18 diff -u -2 -p -r1.92.2.18 dir.c --- dir.c 22 Nov 2004 15:29:52 -0000 1.92.2.18 +++ dir.c 24 Nov 2004 15:58:44 -0000 @@ -1190,7 +1190,4 @@ push_braces(ary, str, flags) if (lbrace && rbrace) { int len = strlen(s); - buf = rb_str_new(0, len+1); - memcpy(RSTRING(buf)->ptr, s, lbrace-s); - b = RSTRING(buf)->ptr + (lbrace-s); p = lbrace; while (*p != '}') { @@ -1200,4 +1197,7 @@ push_braces(ary, str, flags) if (*p == '{') while (*p!='}') p++; } + buf = rb_str_new(0, len+1); + memcpy(RSTRING(buf)->ptr, s, lbrace-s); + b = RSTRING(buf)->ptr + (lbrace-s); memcpy(b, t, p-t); strcpy(b+(p-t), rbrace+1);
-- Nobu Nakada