On Jan 21, 2008 10:03 PM, Spring Dove <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I found File.dirname got the different results when run it on jruby-1.0.3
> and on ruby-1.8.5.
>
> jruby -e 'p File.dirname("C://a")'
> C:/
> ruby -e 'p File.dirname("C://a")'
> C:
>
> also:
> jruby -e 'p File.dirname("//a/b")'
> //a
> ruby -e 'p File.dirname("//a/b")'
> /a
>
> I try to give the solution for the first problem, FYI. Do you have the
> better way?
>
> diff -u org/jruby/RubyFile.java org/jruby/RubyFile.java.new
> --- org/jruby/RubyFile.java 2008-01-21 15:40:14.000000000 +0800
> +++ org/jruby/RubyFile.java.new 2008-01-21 15:41:00.000000000 +0800
> @@ -647,6 +647,14 @@
> } else {
> //TODO deal with UNC names
> int index = name.lastIndexOf('/');
> + while (index > 0) {
> + if (name.charAt(index-1) == '/') {
> + index --;
> + }
> + else {
> + break;
> + }
> + }
> if (index == -1) return recv.getRuntime().newString(".");
> if (index == 0) return recv.getRuntime().newString("/");
Hi, thanks for the report. I think this fix looks fine -- could you
please post this patch along with a test case to our bug tracker so we
don't lose it?
http://jira.codehaus.org/browse/JRUBY
Thanks,
/Nick
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email