[#19457] equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org>

ふと気がついたのですが、

39 messages 2003/02/02
[#19460] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/03

まつもと ゆきひろです

[#19473] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044245817.592933.31973.nullmailer@picachu.netlab.jp>,

[#19474] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19475] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044329220.257740.28127.nullmailer@picachu.netlab.jp>,

[#19476] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19477] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044331431.138035.28173.nullmailer@picachu.netlab.jp>,

[#19478] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19479] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044332948.099873.28206.nullmailer@picachu.netlab.jp>,

[#19482] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19486] Re: equality between "a" and Exception.new("a") — Tanaka Akira <akr@...17n.org> 2003/02/04

In article <1044338964.502066.28474.nullmailer@picachu.netlab.jp>,

[#19491] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19493] Re: equality between "a" and Exception.new("a") — matz@... (Yukihiro Matsumoto) 2003/02/04

まつもと ゆきひろです

[#19556] compare between String and Exception — Tanaka Akira <akr@...17n.org> 2003/02/12

さらに気が付いたのですが、

[#19514] [Oniguruma] Version 1.7.1 — "K.Kosako" <kosako@...>

ftp.ruby-lang.orgに、onigd20030207.tar.gzを置きました。

19 messages 2003/02/07

[#19548] [PATCH] file.c for (PR#389) and (PR#390) — nobu.nakada@...

なかだです。

20 messages 2003/02/11
[#19572] Re: [PATCH] file.c for (PR#389) and (PR#390) — pegacorn@... 2003/02/14

From: nobu.nakada@nifty.ne.jp

[#19648] Re: SEGV at search_method in eval.c (PR#400) — nobu.nakada@...

なかだです。

13 messages 2003/02/24

[ruby-dev:19576] Re: [PATCH] file.c for (PR#389) and (PR#390)

From: nobu.nakada@...
Date: 2003-02-15 05:23:41 UTC
List: ruby-dev #19576
なかだです。

At Sat, 15 Feb 2003 12:06:47 +0900,
pegacorn@jcom.home.ne.jp wrote:
> > それからテストケースを追加していて気づいたんですが、UNC上での
> > expand_pathはこうなるはずではないかと思うんですが、どうでしょう
> > か。
> > 
> > File.expand_path("/", "//machine/share/sub") => "//machine/share"
> 
> 私は cygwin か mswin/mingw かによって異なると思います。
> 
>     cygwin:
>         File.expand_path("/", "//machine/share/sub") => "/"
> 
>     mswin/mingw:
>         File.expand_path("/", "//machine/share/sub") => "//machine/share"
> 
> 理由は、"/" は cygwin 環境では絶対パス、mswin/mingw 環境
> (というか普通の Windows 環境)では相対パスだと思うからです。

カレントディレクトリがUNC上にあるときはいいんですが、よく見ると
今は、ドライブ/UNCなしのフルパスで指定したときは、dnameを無視し
てますね。

> ついでに、ドライブレター指定の場合だと以下のようになると思います。
> 
>     cygwin:
>         File.expand_path("/", "C:/sub") => "/"
> 
>     mswin/mingw:
>         File.expand_path("/", "C:/sub") => "C:/"
>         # 1.6.7 だとこうならない…

これは現状通りということで。

あと、pwd.hがないとFile.expand_path("~nouser")みたいのが展開も
されずエラーにもならないようです。


Index: file.c
===================================================================
RCS file: //sharui/cvs/ruby/src/ruby/file.c,v
retrieving revision 1.136
diff -u -2 -p -r1.136 file.c
--- file.c	14 Feb 2003 16:09:07 -0000	1.136
+++ file.c	15 Feb 2003 04:47:43 -0000
@@ -1425,4 +1425,14 @@ skiproot(path)
 }
 
+static inline char *
+nextdirsep(s)
+    const char *s;
+{
+    while (*s && !isdirsep(*s)) {
+	s = CharNext(s);
+    }
+    return (char *)s;
+}
+
 static char *
 strrdirsep(path)
@@ -1514,10 +1524,7 @@ file_expand_path(fname, dname, result)
 #ifdef HAVE_PWD_H
 	    struct passwd *pwPtr;
-	    s++;
 #endif
-	    b = s;
-	    while (*s && !isdirsep(*s)) {
-		s = CharNext(s);
-	    }
+	    s++;
+	    s = nextdirsep(b = s);
 	    BUFCHECK(p + (s-b) >= pend);
 	    memcpy(p, b, s-b);
@@ -1528,5 +1535,7 @@ file_expand_path(fname, dname, result)
 	    if (!pwPtr) {
 		endpwent();
+#endif
 		rb_raise(rb_eArgError, "user %s doesn't exist", buf);
+#ifdef HAVE_PWD_H
 	    }
 	    BUFCHECK(strlen(pwPtr->pw_dir) > buflen);
@@ -1543,11 +1552,8 @@ file_expand_path(fname, dname, result)
 	    /* specified drive letter, and full path */
 	    /* skip drive letter */
-	    b = s;
-	    while (*s && !isdirsep(*s)) {
-		s = CharNext(s);
-	    }
-	    BUFCHECK(p + (s-b) >= pend);
-	    memcpy(p, b, s-b);
-	    p += s-b;
+	    BUFCHECK(p + 2 >= pend);
+	    memcpy(p, s, 2);
+	    p += 2;
+	    s += 2
 	}
 	else {
@@ -1563,5 +1569,5 @@ file_expand_path(fname, dname, result)
 	    }
 	    if (!same) {
-		getcwdofdrv(*s, buf, MAXPATHLEN);
+		getcwdofdrv(*s, buf, buflen);
 		tainted = 1;
 	    }
@@ -1571,31 +1577,4 @@ file_expand_path(fname, dname, result)
     }
 #endif
-#ifdef DOSISH
-    else if (isdirsep(*s) && !is_absolute_path(s)) {
-	/* specified full path, but not drive letter */
-	/* we need to get the drive letter */
-	tainted = 1;
-	getcwd(buf, MAXPATHLEN);
-	p = &buf[2];
-	if (!isdirsep(*p)) {
-	    while (*p && !isdirsep(*p)) {
-		p = CharNext(p);
-	    }
-	    if (*p) {
-		p++;
-		while (*p && !isdirsep(*p)) {
-		    p = CharNext(p);
-		}
-	    }
-	}
-	b = s;
-	while (*s && !isdirsep(*s)) {
-	    s = CharNext(s);
-	}
-	BUFCHECK(p + (s-b) >= pend);
-	memcpy(p, b, s-b);
-	p += s-b;
-    }
-#endif
     else if (!is_absolute_path(s)) {
 	if (!NIL_P(dname)) {
@@ -1611,7 +1590,20 @@ file_expand_path(fname, dname, result)
 	}
 	p = skiproot(buf);
+#ifdef DOSISH
+	if (isdirsep(*s)) {
+	    /* specified full path, but not drive letter nor UNC */
+	    if (has_drive_letter(buf)) {
+		p = &buf[2];
+	    }
+	    else if (isdirsep(buf[0]) && isdirsep(buf[1])) {
+		/* we need to get the UNC share name */
+		if (*(p = nextdirsep(p))) p = nextdirsep(p + 1);
+	    }
+	}
+	else
+#endif
 	if (*p)
 	    p = chompdirsep(p);
-	else
+	else if (p > buf)
 	    --p;
     }
@@ -2542,5 +2534,5 @@ is_absolute_path(path)
 {
 #ifdef DOSISH_DRIVE_LETTER
-    if (ISALPHA(path[0]) && path[1] == ':' && isdirsep(path[2])) return 1;
+    if (has_drive_letter(path) && isdirsep(path[2])) return 1;
 #endif
 #ifdef DOSISH_UNC


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread