なかだです。 At Mon, 21 Nov 2005 16:08:49 +0900, nobuyoshi nakada wrote in [ruby-dev:27783]: > > | > +#ifdef DOSISH_UNC > > | > + if (!isdirsep(*p)) /* when *p is not dirsep, incomplete UNC. */ > > | > + p = RSTRING(fname)->ptr + 1; > > | > +#endif > > | > > | ちょっと気になるのは、例によってマルチバイト関係ですが…。 > > > > これ、どこかから / を拾ってこようと思って、ついなんとなく先頭 > > から2文字目を拾っちゃったのですが、 > > p = strrdirsep(RSTRING(fname)->ptr); > > か > > p = "/"; > > にすりゃよかったと反省しております。 > > 気にしてるのは、 !isdirsep(*p) のほうです。UNCってマルチバイト > は不可なんでしたっけ? というか、その後のDOSISH_DRIVE_LETTER用の *p == ':' が無効にな りませんか。そのコードだと。
Index: file.c =================================================================== RCS file: /cvs/ruby/src/ruby/file.c,v retrieving revision 1.225 diff -U2 -p -r1.225 file.c --- file.c 18 Nov 2005 09:09:23 -0000 1.225 +++ file.c 21 Nov 2005 07:29:41 -0000 @@ -2215,5 +2215,9 @@ rb_path_next(const 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) @@ -2570,4 +2574,7 @@ rb_file_s_basename(int argc, VALUE *argv VALUE fname, fext, basename; char *name, *p; +#ifdef DOSISH + char *root; +#endif int f; @@ -2578,13 +2585,29 @@ rb_file_s_basename(int argc, VALUE *argv 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))) {
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦