[#13727] Thread.critical=true and fork and exec — Kazuhiro NISHIYAMA <zn@...>
このような感じでforkとexecの間に必要のないIOを閉じようと
[#13754] Kconv(NKF) with tainted strings — Tietew <tietew@...>
Tietew といいます。
[#13765] GenerativeHash — TAKAHASHI Masayoshi <maki@...>
高橋征義です。
まつもと ゆきひろです
高橋征義です。
TAKAHASHI Masayoshiさんの
高橋征義です。
[#13767] Dir::glob() — "Akinori MUSHA" <knu@...>
File::fnmatch の提案のときに切り離した、 Dir::glob の拡張を
[#13774] mkmf.rb: cleaning facility — Takaaki Tateishi <ttate@...>
立石です.
まつもと ゆきひろです
At Mon, 9 Jul 2001 15:20:28 +0900,
まつもと ゆきひろです
[#13779] dln.c patch for Mac OS X — Mitsuhiro Kondo <kondo@...>
こんにちは、近藤と申します。
[#13800] Re: [ruby-cvs] ruby: * ruby.h: fix a wrong function name: rb_iglob() -> rb_globi(). — nobu.nakada@...
なかだです。
わたなべです。
まつもと ゆきひろです
わたなべです。
まつもと ゆきひろです
わたなべです。
まつもと ゆきひろです
At Tue, 10 Jul 2001 15:23:04 +0900,
わたなべです。
At Tue, 10 Jul 2001 16:50:52 +0900,
もうひとつあった。
At Tue, 10 Jul 2001 18:04:57 +0900,
まつもと ゆきひろです
At Mon, 16 Jul 2001 01:16:31 +0900,
まつもと ゆきひろです
At Mon, 16 Jul 2001 09:22:46 +0900,
まつもと ゆきひろです
[#13817] Fw: DOSISH file.c changes — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
なかだです。
こんにちは、なかむら(う)です。
なかだです。
[#13818] COPYING files — "Akinori MUSHA" <knu@...>
Ruby は GPL のシングルライセンスではないのに、 COPYING という
先日の:
高橋征義です。
[#13821] [BUG] rb_gc_mark(): unknown data type 0x1c(0xbfff3d6c) non object — akira yamada / やまだあきら <akira@...>
[#13824] config.{guess,sub} too old? — akira yamada / やまだあきら <akira@...>
[#13828] supported platforms / K&R — "Akinori MUSHA" <knu@...>
digest モジュールの各プラットフォームでの動作確認をお願いした
新井です。
清水@biglobeです。
新井です。
清水@biglobe です。
なかだです。
新井です。
新井です。
なかだです。
新井です。
なかだです。
新井です。
なかだです。
新井です。
新井です。
[#13833] Net::HTTP#proxy? — WATANABE Hirofumi <eban@...>
わたなべです。
[#13866] yield and proc — Takashi Ikeda <nov28@...>
池田と申します。
[#13870] massign to Hash — nobu.nakada@...
なかだです。
[#13878] Prototype for rb_gc_mark / volatile in ruby.h — Tietew <tietew@...>
Tietew です。
まつもと ゆきひろです
こんにちは、なかむら(う)です。
わたなべです。
こんにちは、なかむら(う)です。
わたなべです。
こんにちは、なかむら(う)です。
むらけんです.
[#13908] Forward: Seg fault in latest regex.c (PR#154) — matz@... (Yukihiro Matsumoto)
まつもと ゆきひろです
[#13924] doc/ — Minero Aoki <aamine@...>
あおきです。
[#13929] error: multiple require of digest/* — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
なかだです。
まつもと ゆきひろです
[#13940] IO#read — "Akinori MUSHA" <knu@...>
IO#read を使って何度もストリームから読み込むような処理をする
なかだです。
まつもと ゆきひろです
At Sat, 21 Jul 2001 03:21:11 +0900,
まつもと ゆきひろです
At Sat, 21 Jul 2001 04:43:06 +0900,
At Sat, 21 Jul 2001 05:03:10 +0900,
[#13943] [REQ] ruby_stop without exit — Tietew <tietew@...>
Tietew です。
[#13959] Re: [ruby-list:30682] Re: overwride method — "Akinori MUSHA" <knu@...>
At Fri, 20 Jul 2001 21:09:36 +0900,
ごとけんです
まつもと ゆきひろです
ごとけんです
まつもと ゆきひろです
[ruby-dev:13969]>
まつもと ゆきひろです
ごとけんです
なひです。
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
なひです。
まつもと ゆきひろです
なひです。
まつもと ゆきひろです
なひです。
まつもと ゆきひろです
ごとけんです
まつもと ゆきひろです
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
あづみです。
まつもと ゆきひろです
In <996211878.306635.31396.nullmailer@ev.netlab.jp>
まつもと ゆきひろです
In <996255758.830993.629.nullmailer@ev.netlab.jp>
まつもと ゆきひろです
In <996282482.936326.1948.nullmailer@ev.netlab.jp>
なひです。
まつもと ゆきひろです
なひです。
あづみです。
まつもと ゆきひろです
けいじゅ@日本ラショナルソフトウェアです.
前田です。
まつもと ゆきひろです
前田です。
まつもと ゆきひろです
[#14003] to_int in mathn [Re: overwride method ] — keiju@... (石塚圭樹)
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
原です。
けいじゅ@日本ラショナルソフトウェアです.
まつもと ゆきひろです
[#14026] Exception in coerce — Shin-ichiro HARA <sinara@...>
原です。
まつもと ゆきひろです
原です。
まつもと ゆきひろです
まつもと ゆきひろです
原です。
まつもと ゆきひろです
原です。
まつもと ゆきひろです
原です。
まつもと ゆきひろです
原です。
まつもと ゆきひろです
原です。
まつもと ゆきひろです
[#14045] load "~/foo" — WATANABE Hirofumi <eban@...>
わたなべです。
[#14097] DOSISH file.c — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)@帰省中です。
[ruby-dev:13845] Re: Fw: DOSISH file.c changes
なかだです。
なかだです。
At Wed, 11 Jul 2001 20:37:33 +0900,
U.Nakamura <usa@osb.att.ne.jp> wrote:
> Patrick Cheng氏から下記のようなパッチを頂いているので転送し
> ます。
ちょっと気になったのが…。
(1) is_absolute_path()がc:hogeみたいのに対して偽を返すようになっ
てるので、require 'c:hoge'なんてのがエラーになりそうな気が
するんですが、そういうもん? これはどちらかといえば
is_macos_native_path()と同様の扱いにしたほうがいいようにも
思えますが。
(2) rb_file_s_expand_path()でis_absolute_path()で分岐しているけ
れど、ドライブレターを考えたときには絶対パスかどうかという
分け方はできないと思うので、それぞれのパターンについて分岐
したほうがいいのでは。
(3) パッチが壊れてるとか。
> あとUNC対応が必要?
> # マルチバイト対応は... まぁ「置き」ですかねぇ。
ちょっとやってみましたが、まぁたぶんダメダメでしょう。
Index: file.c
===================================================================
RCS file: /cvs/ruby/src/ruby/file.c,v
retrieving revision 1.58
diff -u -2 -p -r1.58 file.c
--- file.c 2001/06/19 04:35:13 1.58
+++ file.c 2001/07/13 13:30:29
@@ -1291,10 +1291,106 @@ rb_file_s_umask(argc, argv)
}
+#ifndef HAVE_GETCWD
+#define getcwd(buf, len) getwd(buf)
+#endif
+
#if defined DOSISH
#define isdirsep(x) ((x) == '/' || (x) == '\\')
+static inline int
+has_drive_letter(path)
+ const char *path;
+{
+ if (ISALPHA(path[0]) && path[1] == ':') return 1;
+ return 0;
+}
+
+static void
+getdrivecurdir(char *buf, int len, int drive)
+{
+ char drive[4];
+ char oldcwd[MAXPATHLEN+1];
+
+ drive[0] = drive;
+ drive[1] = ':';
+ drive[2] = '\0';
+
+ /* the only way that I know to get the current directory
+ of a particular drive is to change chdir() to that drive,
+ so save the old cwd before chdir()
+ */
+ getcwd(oldcwd, MAXPATHLEN);
+ if (chdir(drive) == 0) {
+ getcwd(buf, len);
+ chdir(oldcwd);
+ }
+ else {
+ drive[2] = '/';
+ drive[3] = '\0';
+ strncpy(buf, drive, len);
+ }
+}
+
+static char*
+skipprefix(char *path)
+{
+ if (has_drive_letter(path)) {
+ path += 2;
+ }
+ else if (isdirsep(path[0]) && isdirsep(path[1])) {
+ while (isdirsep(*path)) path++;
+ while (*path && !isdirsep(*path)) path = CharNext(path); /* skip host */
+ if (*path) {
+ path++;
+ while (*path && !isdirsep(*path)) path = CharNext(path); /* skip share */
+ }
+ }
+ return path;
+}
#else
#define isdirsep(x) ((x) == '/')
#endif
+#ifndef CharNext
+# if defined(DJGPP)
+# define CharNext(p) ((p) + mblen(p, MB_CUR_MAX))
+# else
+# define CharNext(p) ((p) + 1)
+# endif
+#endif
+
+static char *
+strrdirsep(name)
+ char *name;
+{
+ char *last = NULL;
+ do {
+ if (isdirsep(*name)) {
+ last = name++;
+ }
+ else {
+ name = CharNext(name);
+ }
+ } while (*name);
+ return last;
+}
+static char *
+endofdir(name)
+ char *name;
+{
+ char *last = NULL;
+
+ do {
+ if (isdirsep(*name)) {
+ last = name++;
+ }
+ else {
+ name = CharNext(name);
+ }
+ } while (*name);
+ if (last == name - 1)
+ --name;
+ return name;
+}
+
VALUE
rb_file_s_expand_path(argc, argv)
@@ -1320,5 +1416,5 @@ rb_file_s_expand_path(argc, argv)
}
strcpy(buf, dir);
- p = &buf[strlen(buf)];
+ p = endofdir(buf);
s++;
tainted = 1;
@@ -1340,5 +1436,5 @@ rb_file_s_expand_path(argc, argv)
}
strcpy(buf, pwPtr->pw_dir);
- p = &buf[strlen(buf)];
+ p = endofdir(buf);
endpwent();
#endif
@@ -1346,8 +1442,17 @@ rb_file_s_expand_path(argc, argv)
}
#if defined DOSISH
- /* skip drive letter */
- else if (ISALPHA(s[0]) && s[1] == ':' && isdirsep(s[2])) {
- while (*s && !isdirsep(*s)) {
+ else if (has_drive_letter(s)) {
+ if (isdirsep(s[2])) {
+ /* specified drive letter, and full path */
+ /* skip drive letter */
+ *p++ = *s++;
*p++ = *s++;
+ s++;
+ }
+ else {
+ /* specified drive, but not full path */
+ getdrivecurdir(buf, *s);
+ tainted = 1;
+ p = endofdir(buf);
}
}
@@ -1361,19 +1466,28 @@ rb_file_s_expand_path(argc, argv)
else {
tainted = 1;
-#ifdef HAVE_GETCWD
getcwd(buf, MAXPATHLEN);
-#else
- getwd(buf);
-#endif
}
- p = &buf[strlen(buf)];
- while (p > buf && *(p - 1) == '/') p--;
+ p = endofdir(buf);
+ }
+#if defined DOSISH
+ else if (!isdirsep(s[1])) {
+ /* specified full path, but not drive letter */
+ /* we need to get the drive letter */
+ tainted = 1;
+ getcwd(buf, MAXPATHLEN);
+ p = skipprefix(buf);
+ s++;
}
+#endif
else {
- while (*s && isdirsep(*s)) {
+ while (isdirsep(*s)) {
*p++ = '/';
s++;
}
+#ifdef DOSISH
+ if (p > buf + 1 && *s) p--;
+#else
if (p > buf && *s) p--;
+#endif
}
*p = '/';
@@ -1387,6 +1501,6 @@ rb_file_s_expand_path(argc, argv)
if (*(s+1) == '\0' || isdirsep(*(s+1))) {
/* We must go back to the parent */
- if (isdirsep(*p) && p > buf) p--;
- while (p > buf && !isdirsep(*p)) p--;
+ *p = '\0';
+ p = strrdirsep(buf);
}
else {
@@ -1419,4 +1533,11 @@ rb_file_s_expand_path(argc, argv)
/* Place a \0 at end. If path ends with a "/", delete it */
if (p == buf || !isdirsep(*p)) p++;
+#if defined(DOSISH)
+ if (ISALPHA(buf[0]) && buf[1] == ':' && isdirsep(buf[2])) {
+ /* root directory needs a trailing backslash,
+ otherwise it mean the current directory of the drive */
+ if (p == (buf+2)) p++;
+ }
+#endif
*p = '\0';
@@ -1462,5 +1583,5 @@ rb_file_s_basename(argc, argv)
}
name = StringValuePtr(fname);
- p = strrchr(name, '/');
+ p = strrdirsep(name);
if (!p) {
if (NIL_P(fext) || !(f = rmext(name, ext)))
@@ -1489,10 +1610,20 @@ rb_file_s_dirname(klass, fname)
name = StringValuePtr(fname);
- p = strrchr(name, '/');
+#if defined(DOSISH)
+ if (ISALPHA(name[0]) && name[1] == ':')
+ name += 2;
+#endif
+ p = strrdirsep(name);
if (!p) {
- return rb_str_new2(".");
+#if defined(DOSISH)
+ if (name == RSTRING(fname)->ptr)
+#endif
+ return rb_str_new2(".");
}
if (p == name)
p++;
+#if defined(DOSISH)
+ name = RSTRING(fname)->ptr;
+#endif
dirname = rb_str_new(name, p - name);
if (OBJ_TAINTED(fname)) OBJ_TAINT(dirname);
@@ -2122,9 +2253,10 @@ is_absolute_path(path)
const char *path;
{
+#ifndef DOSISH
if (path[0] == '/') return 1;
-# if defined DOSISH
- if (path[0] == '\\') return 1;
- if (strlen(path) > 2 && path[1] == ':') return 1;
-# endif
+#else
+ if (isdirsep(path[0]) && isdirsep(path[1])) return 1;
+ if (ISALPHA(path[0]) && path[1] == ':' && isdirsep(path[2])) return 1;
+#endif
return 0;
}
@@ -2135,28 +2267,46 @@ path_check_1(path)
{
struct stat st;
+ char buf[MAXPATHLEN+1];
char *p = 0;
char *s;
- if (!is_absolute_path(path)) {
- char buf[MAXPATHLEN+1];
-
-#ifdef HAVE_GETCWD
+#ifdef DOSISH
+ if (has_drive_letter(path)) {
+ if (!isdirsep(path[2])) {
+ /* specified drive, but not full path */
+ getdrivecurdir(buf, *path);
+ *endofdir(buf) = '\0';
+ goto cat;
+ }
+ }
+ else if (!isdirsep(path[0]) || !isdirsep(path[1])) {
if (getcwd(buf, MAXPATHLEN) == 0) return 0;
+ if (isdirsep(path[0])) *skipprefix(buf) = '\0';
+ cat:
+ strncat(buf, "/", MAXPATHLEN);
+ strncat(buf, path, MAXPATHLEN);
+ buf[MAXPATHLEN] = '\0';
+ path = buf;
+ }
#else
- if (getwd(buf) == 0) return 0;
-#endif
+ if (!is_absolute_path(path)) {
+ if (getcwd(buf, MAXPATHLEN) == 0) return 0;
strncat(buf, "/", MAXPATHLEN);
strncat(buf, path, MAXPATHLEN);
buf[MAXPATHLEN] = '\0';
- return path_check_1(buf);
+ path = buf;
}
+#endif
for (;;) {
if (stat(path, &st) == 0 && (st.st_mode & 002)) {
- if (p) *p = '/';
+ if (p) *p = '/';
return 0;
}
- s = strrchr(path, '/');
+ s = strrdirsep(path);
if (p) *p = '/';
if (!s || s == path) return 1;
+#ifdef DOSISH
+ if (s == path + 2) return 1;
+#endif
p = s;
*p = '\0';
@@ -2181,8 +2331,8 @@ rb_path_check(path)
if (pend) *pend = '\0';
safe = path_check_1(p);
- if (!safe) {
- if (pend) *pend = sep;
- return 0;
- }
+ if (!safe) {
+ if (pend) *pend = sep;
+ return 0;
+ }
if (!pend) break;
*pend = sep;
@@ -2201,4 +2351,9 @@ is_macos_native_path(path)
return 0;
}
+#define is_native_path(path) is_macos_native_path(path)
+#elif defined(DOSISH)
+#define is_native_path(path) has_drive_letter(path)
+#else
+#define is_native_path(path) 0
#endif
@@ -2240,5 +2395,5 @@ rb_find_file_noext(file)
}
- if (is_absolute_path(file)) {
+ if (is_native_path(file) || is_absolute_path(file)) {
for (i=0; ext[i]; i++) {
strcpy(fend, ext[i]);
@@ -2281,15 +2436,6 @@ rb_find_file(file)
file = StringValuePtr(fname);
}
-
-#if defined(__MACOS__) || defined(riscos)
- if (is_macos_native_path(file)) {
- if (rb_safe_level() >= 2 && !rb_path_check(file)) {
- rb_raise(rb_eSecurityError, "loading from unsafe file %s", file);
- }
- return file_load_ok(file);
- }
-#endif
- if (is_absolute_path(file)) {
+ if (is_native_path(file) || is_absolute_path(file)) {
if (rb_safe_level() >= 2 && !rb_path_check(file)) {
rb_raise(rb_eSecurityError, "loading from unsafe file %s", file);
--
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
中田 伸悦