зеркало из https://github.com/github/ruby.git
* file.c (rb_path_skip_prefix, rb_file_s_basename): UNC without path
should not be splitted. fixed: [ruby-dev:27776] [ruby-dev:27786] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
cbb5d57a2a
Коммит
e4b2293712
|
@ -1,3 +1,8 @@
|
|||
Mon Nov 21 22:19:33 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* file.c (rb_path_skip_prefix, rb_file_s_basename): UNC without path
|
||||
should not be splitted. fixed: [ruby-dev:27776] [ruby-dev:27786]
|
||||
|
||||
Mon Nov 21 16:03:48 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* win32/setup.mk: findstr doesn't exist on win9x.
|
||||
|
|
29
file.c
29
file.c
|
@ -2214,14 +2214,18 @@ rb_path_next(const char *s)
|
|||
return (char *)s;
|
||||
}
|
||||
|
||||
#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
|
||||
#define skipprefix rb_path_skip_prefix
|
||||
#else
|
||||
#define skipprefix(path) (path)
|
||||
#endif
|
||||
char *
|
||||
rb_path_skip_prefix(const char *path)
|
||||
{
|
||||
#if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER)
|
||||
#ifdef DOSISH_UNC
|
||||
if (isdirsep(path[0]) && isdirsep(path[1])) {
|
||||
if (*(path = nextdirsep(path + 2)))
|
||||
if (*(path = nextdirsep(path + 2)) && path[1] && !isdirsep(path[1]))
|
||||
path = nextdirsep(path + 1);
|
||||
return (char *)path;
|
||||
}
|
||||
|
@ -2569,6 +2573,9 @@ rb_file_s_basename(int argc, VALUE *argv)
|
|||
{
|
||||
VALUE fname, fext, basename;
|
||||
char *name, *p;
|
||||
#ifdef DOSISH
|
||||
char *root;
|
||||
#endif
|
||||
int f;
|
||||
|
||||
if (rb_scan_args(argc, argv, "11", &fname, &fext) == 2) {
|
||||
|
@ -2577,14 +2584,30 @@ rb_file_s_basename(int argc, VALUE *argv)
|
|||
StringValue(fname);
|
||||
if (RSTRING(fname)->len == 0 || !*(name = RSTRING(fname)->ptr))
|
||||
return fname;
|
||||
if (!*(name = skiproot(name))) {
|
||||
name = skipprefix(name);
|
||||
#ifdef DOSISH
|
||||
root = name;
|
||||
#endif
|
||||
while (isdirsep(*name))
|
||||
name++;
|
||||
if (!*name) {
|
||||
p = name - 1;
|
||||
f = 1;
|
||||
#ifdef DOSISH
|
||||
if (name != root) {
|
||||
/* has slashes */
|
||||
}
|
||||
#ifdef DOSISH_DRIVE_LETTER
|
||||
if (*p == ':') {
|
||||
else if (*p == ':') {
|
||||
p++;
|
||||
f = 0;
|
||||
}
|
||||
#endif
|
||||
#ifdef DOSISH_UNC
|
||||
else {
|
||||
p = "/";
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
else if (!(p = strrdirsep(name))) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче