[#12164] patch for ext/gdbm — Koji Arai <JCA02266@...>

新井です。

24 messages 2001/02/04
[#12168] Re: patch for ext/gdbm — matz@... (Yukihiro Matsumoto) 2001/02/05

まつもと ゆきひろです

[#12176] Re: patch for ext/gdbm — Koji Arai <JCA02266@...> 2001/02/05

新井です。

[#12179] Re: patch for ext/gdbm — matz@... (Yukihiro Matsumoto) 2001/02/06

まつもと ゆきひろです

[#12219] Re: patch for ext/gdbm — Koji Arai <JCA02266@...> 2001/02/12

新井です。

[#12220] Re: patch for ext/gdbm — Koji Arai <JCA02266@...> 2001/02/12

新井です。

[#12256] set_trace_func — keiju@... (Keiju ISHITSUKA)

けいじゅ@日本ラショナルソフトウェアです.

15 messages 2001/02/17

[#12293] crash on proc without a block — Kenichi Komiya <kom@...1.accsnet.ne.jp>

15 messages 2001/02/25

[#12323] Re: [ruby-list:28364] class definition extension — "K.Kosako" <kosako@...>

ruby-listから移動しました。

13 messages 2001/02/28
[#12324] Re: [ruby-list:28364] class definition extension — matz@... (Yukihiro Matsumoto) 2001/02/28

まつもと ゆきひろです

[ruby-dev:12200] Re: File.directory? on mswin32

From: "Nobuyoshi.Nakada" <nobu.nakada@...>
Date: 2001-02-09 03:34:25 UTC
List: ruby-dev #12200
なかだです。

At Fri, 9 Feb 2001 10:36:53 +0900
"たけ(tk)"<ggb03124@nifty.ne.jp> wrote:
> 》Windows 2000 [Version 5.00.2195] の場合、その現象が
> 》起きるようです。
> 》
> 》>ruby -v
> 》ruby 1.6.2 (2000-12-25) [i586-mswin32]
> 》
> 》>ruby -e "p File.directory? 'f:/temp'"
> 》true
> 》
> 》>ruby -e "p File.directory? 'f:/temp/'"
> 》false
> 
>  win95でもおなじ。(Apollo版Ruby.exe)。
> 
> ruby -v
> ruby 1.6.2 (2000-12-25) [i586-mswin32]
> ruby -e "p File.directory? 'c:/temp'"
> true
> ruby -e "p File.directory? 'c:/temp/'"
> false

  むっきー。

  NT4.0 じゃどっちも true になるので確認できませんが(ってグレー
ドダウンかー > W2k)、これで直りますか。

  まだ stat() を使ってるところが残ってますが、dir.c の方は 
glob した結果から内部で作ってるので不要、dln.c と file.c の方
は load 関係なのでそもそもディレクトリは対象外と見てます。

  ちなみに cygwin だとどうなりますか?


Index: dir.c
===================================================================
RCS file: /home/cvs/ruby/src/ruby/dir.c,v
retrieving revision 1.24
diff -u -2 -p -r1.24 dir.c
--- dir.c	2000/11/20 01:24:22	1.24
+++ dir.c	2001/02/09 03:32:24
@@ -569,5 +569,5 @@ rb_glob_helper(path, flag, func, arg)
 
     if (!has_magic(path, 0)) {
-	if (stat(path, &st) == 0) {
+	if (rb_sys_stat(path, &st) == 0) {
 	    (*func)(path, arg);
 	}
Index: file.c
===================================================================
RCS file: /home/cvs/ruby/src/ruby/file.c,v
retrieving revision 1.44
diff -u -2 -p -r1.44 file.c
--- file.c	2001/01/29 05:10:41	1.44
+++ file.c	2001/02/09 03:32:00
@@ -68,5 +68,5 @@ char *strrchr _((const char*,const char)
 
 #ifndef HAVE_LSTAT
-#define lstat stat
+#define lstat rb_sys_stat
 #endif
  
@@ -314,5 +314,5 @@ rb_stat(file, st)
     if (RSTRING(file)->len == 0) return -1;
 #endif
-    return stat(RSTRING(file)->ptr, st);
+    return rb_sys_stat(RSTRING(file)->ptr, st);
 }
 
@@ -324,5 +324,5 @@ rb_file_s_stat(obj, fname)
 
     Check_SafeStr(fname);
-    if (stat(RSTRING(fname)->ptr, &st) == -1) {
+    if (rb_sys_stat(RSTRING(fname)->ptr, &st) == -1) {
 	rb_sys_fail(RSTRING(fname)->ptr);
     }
@@ -420,5 +420,5 @@ eaccess(path, mode)
   static int euid = -1;
 
-  if (stat(path, &st) < 0) return (-1);
+  if (rb_sys_stat(path, &st) < 0) return (-1);
 
   if (euid == -1)
@@ -722,5 +722,5 @@ check3rdbyte(file, mode)
     struct stat st;
 
-    if (stat(file, &st) < 0) return Qfalse;
+    if (rb_sys_stat(file, &st) < 0) return Qfalse;
     if (st.st_mode & mode) return Qtrue;
     return Qfalse;
Index: ruby.h
===================================================================
RCS file: /home/cvs/ruby/src/ruby/ruby.h,v
retrieving revision 1.35
diff -u -2 -p -r1.35 ruby.h
--- ruby.h	2001/01/29 05:10:42	1.35
+++ ruby.h	2001/02/09 03:36:20
@@ -592,4 +592,8 @@ static char *dln_libs_to_be_linked[] = {
 #endif
 
+#ifndef rb_sys_stat
+#define rb_sys_stat stat
+#endif
+
 #if defined(__cplusplus)
 }  /* extern "C" { */
Index: win32/win32.c
===================================================================
RCS file: /home/cvs/ruby/src/ruby/win32/win32.c,v
retrieving revision 1.32
diff -u -2 -p -r1.32 win32.c
--- win32/win32.c	2001/01/14 09:20:21	1.32
+++ win32/win32.c	2001/02/09 03:33:22
@@ -30,4 +30,5 @@
 #define index(x, y) strchr((x), (y))
 #endif
+#define isdirsep(x) ((x) == '/' || (x) == '\\')
 
 #ifndef bool
@@ -2611,4 +2612,24 @@ myrename(const char *oldpath, const char
 
     return res;
+}
+
+int
+rb_sys_stat(const char *path, struct stat *st)
+{
+    const char *p = path;
+
+    if ((isdirsep(*p) && (p++, TRUE)) || /* absolute path or UNC */
+	(ISALPHA(*p) && p[1] == ':' && (p += 2, TRUE))) { /* has drive */
+	if (isdirsep(*p)) p++;
+    }
+    if (*p && (p = CharPrev(p, p + strlen(p)), isdirsep(*p))) {
+	/* Win95/2000 fail with trailing path separator? */
+	int len = p - path;
+	char *s = ALLOCA_N(char, len);
+	memcpy(s, path, len);
+	s[len] = '\0';
+	path = s;
+    }
+    return stat(path, st);
 }
 
Index: win32/win32.h
===================================================================
RCS file: /home/cvs/ruby/src/ruby/win32/win32.h,v
retrieving revision 1.14
diff -u -2 -p -r1.14 win32.h
--- win32/win32.h	2001/01/11 01:55:51	1.14
+++ win32/win32.h	2001/02/09 03:34:26
@@ -163,4 +163,6 @@ extern "C++" {
 #define strcasecmp _stricmp
 #define strncasecmp _strnicmp
+#undef rb_sys_stat
+#define rb_sys_stat win32_stat
 /* these are defined in nt.c */
 


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

In This Thread