Sorry, I had a mistake: + temp_name += name.substring(rindex); + name = temp_name; + } should be: + temp_name += name.substring(rindex); + name = temp_name.substring(0); + }
2008/2/26, Dove Cradle (JIRA) <[EMAIL PROTECTED]>: > > File.dirname got different results between jruby-1.0.3 and ruby-1.8.5 > --------------------------------------------------------------------- > > Key: JRUBY-2176 > URL: http://jira.codehaus.org/browse/JRUBY-2176 > Project: JRuby > Issue Type: Bug > Affects Versions: JRuby 1.0.3 > Reporter: Dove Cradle > Assignee: Thomas E Enebo > Attachments: File_dirname.diff > > 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 two problems, FYI. Do you have the > better way? > > diff -u src/org/jruby/RubyFile.java.old src/org/jruby/RubyFile.java > --- src/org/jruby/RubyFile.java.old 2008-01-21 16:08:07.000000000+0800 > +++ src/org/jruby/RubyFile.java 2008-02-26 11:18:04.000000000 +0800 > @@ -646,6 +646,22 @@ > } > } else { > //TODO deal with UNC names > + int lindex = name.indexOf('/'); > + if (lindex != -1) { > + int rindex = name.lastIndexOf('/'); > + String temp_name = name.substring(0, lindex); > + while (lindex < rindex) { > + if (name.charAt(lindex+1) == '/') { > + lindex++; > + } else { > + int tmp_lindex = name.indexOf('/', lindex+1); > + temp_name += name.substring(lindex, tmp_lindex); > + lindex = tmp_lindex; > + } > + } > + temp_name += name.substring(rindex); > + name = temp_name; > + } > int index = name.lastIndexOf('/'); > if (index == -1) return recv.getRuntime().newString("."); > if (index == 0) return recv.getRuntime().newString("/"); > @@ -656,7 +672,8 @@ > index++; > } > > - result = jfilename.substring(0, index); > + result = name.substring(0, index); > + //result = jfilename.substring(0, index); > } > > return recv.getRuntime().newString(result).infectBy(filename); > > -- > This message is automatically generated by JIRA. > - > If you think it was sent incorrectly contact one of the administrators: > http://jira.codehaus.org/secure/Administrators.jspa > - > For more information on JIRA, see: http://www.atlassian.com/software/jira > > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > >
