[MacRuby] #850: File.basename is broken when calls the File.basename("..", ".*").
#850: File.basename is broken when calls the File.basename("..", ".*"). ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: new Priority: blocker | Milestone: Component: MacRuby | Keywords: ----------------------------------+----------------------------------------- Test Script: {{{ #!ruby $ cat test.rb p File.basename("..") p File.basename("..", "test") p File.basename("..", "*") p File.basename("..", ".*") }}} Result of Ruby 1.9.1: {{{ $ ruby test.rb ".." ".." ".." ".." }}} Result of MacRuby Trunk: {{{ $ macruby test.rb ".." ".." ".." "." }}} It seems that Implementation of the rmext() is not enough.[[BR]] Merged from Ruby 1.9: {{{ #!diff diff --git a/file.c b/file.c index 2714476..4e62411 100644 --- a/file.c +++ b/file.c @@ -2615,16 +2615,19 @@ rb_file_s_realdirpath(VALUE klass, SEL sel, int argc, VALUE static int rmext(const char *p, int l1, const char *e) { - int l2; + int l0, l2; if (!e) return 0; + for (l0 = 0; l0 < l1; ++l0) { + if (p[l0] != '.') break; + } l2 = strlen(e); if (l2 == 2 && e[1] == '*') { unsigned char c = *e; e = p + l1; do { - if (e <= p) return 0; + if (e <= p + l0) return 0; } while (*--e != c); return e - p; } }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/850> MacRuby <http://macruby.org/>
#850: File.basename is broken when calls the File.basename("..", ".*"). ----------------------------------+----------------------------------------- Reporter: watson1978@… | Owner: lsansonetti@… Type: defect | Status: closed Priority: blocker | Milestone: MacRuby 0.7 Component: MacRuby | Resolution: fixed Keywords: | ----------------------------------+----------------------------------------- Changes (by lsansonetti@…): * status: new => closed * resolution: => fixed * milestone: => MacRuby 0.7 Comment: Thanks for the work, merged the patch in r4425. -- Ticket URL: <http://www.macruby.org/trac/ticket/850#comment:1> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby