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

merge from trunk (r28565)

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


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@28568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2010-07-07 04:27:09 +00:00
parent c3db8dfaa8
commit d4d1388ad8

20
file.c
View file

@ -2859,13 +2859,13 @@ rmext(p, l1, e)
}
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
const char *root;
#endif
long f, n = -1;
long f = 0, n = -1;
name = skipprefix(name);
#if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC
@ -2905,12 +2905,18 @@ ruby_find_basename(const char *name, long *len, long *ext)
#else
n = chompdirsep(p) - p;
#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)
*len = f;
if (ext)
*ext = n;
if (baselen)
*baselen = f;
if (alllen)
*alllen = n;
return p;
}