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:
parent
c3db8dfaa8
commit
d4d1388ad8
1 changed files with 13 additions and 7 deletions
20
file.c
20
file.c
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue