1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* file.c (ruby_find_basename): set correct baselen.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2010-07-07 04:22:30 +00:00
parent 42f4a548f0
commit 09e1383bcf
2 changed files with 16 additions and 6 deletions

View file

@ -1,3 +1,7 @@
Wed Jul 7 13:22:20 2010 NAKAMURA Usaku <usa@ruby-lang.org>
* file.c (ruby_find_basename): set correct baselen.
Wed Jul 7 13:02:59 2010 Akinori MUSHA <knu@iDaemons.org> Wed Jul 7 13:02:59 2010 Akinori MUSHA <knu@iDaemons.org>
* vm_method.c (rb_method_boundp): respond_to?(:protected_method, * vm_method.c (rb_method_boundp): respond_to?(:protected_method,

18
file.c
View file

@ -3430,9 +3430,9 @@ rmext(const char *p, long l1, const char *e)
} }
const char * const char *
ruby_find_basename(const char *name, long *len, long *ext) ruby_find_basename(const char *name, long *baselen, long *alllen)
{ {
const char *p; const char *p, *q, *e;
#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC #if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
const char *root; const char *root;
#endif #endif
@ -3476,12 +3476,18 @@ ruby_find_basename(const char *name, long *len, long *ext)
#else #else
n = chompdirsep(p) - p; n = chompdirsep(p) - p;
#endif #endif
for (q = p; q - p < n && *q == '.'; q++);
for (e = 0; q - p < n; q = CharNext(q)) {
if (*q == '.') e = q;
}
if (e) f = e - p;
else f = n;
} }
if (len) if (baselen)
*len = f; *baselen = f;
if (ext) if (alllen)
*ext = n; *alllen = n;
return p; return p;
} }