[#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:13817] Fw: DOSISH file.c changes
こんにちは、なかむら(う)です。 Patrick Cheng氏から下記のようなパッチを頂いているので転送し ます。 At Tue, 10 Jul 2001 00:30:49 -0700, "Patrick Cheng" <pcyc@hotmail.com> wrote: > Hello, > I have made some changes to the File class to handle DOSISH file name > better, namely: > > - basname() and dirname() can split using backslash > - expand_path() to handle drive letter better. > > hopefully, some of it you might find it useful. > > Patrick Cheng あとUNC対応が必要? # マルチバイト対応は... まぁ「置き」ですかねぇ。 それでは。 -- U.Nakamura <usa@osb.att.ne.jp>
Attachments (2)
--- file.c Tue Jul 10 00:05:49 2001
+++ new/file.c Mon Jul 9 23:56:05 2001
@@ -75,6 +75,9 @@
static VALUE rb_cStat;
static int
+is_absolute_path(path);
+
+static int
apply2files(func, vargs, arg)
int (*func)();
VALUE vargs;
@@ -1345,14 +1348,62 @@
}
}
#if defined DOSISH
- /* skip drive letter */
- else if (ISALPHA(s[0]) && s[1] == ':' && isdirsep(s[2])) {
- while (*s && !isdirsep(*s)) {
- *p++ = *s++;
- }
+ else if (ISALPHA(s[0]) && s[1] == ':') {
+ if (isdirsep(s[2])) {
+ /* specified drive letter, and full path */
+ /* skip drive letter */
+ while (*s && !isdirsep(*s)) {
+ *p++ = *s++;
+ }
+ }
+ else {
+ /* specified drive, but not full path */
+ char drive[3];
+ char oldcwd[MAXPATHLEN+1];
+
+ drive[0] = *s++;
+ drive[1] = *s++;
+ 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);
+ chdir(drive);
+
+ tainted = 1;
+ getcwd(buf, MAXPATHLEN);
+ p = &buf[strlen(buf)];
+ if ( *s )
+ {
+ /* need to append '/' before appending the rest of the path
*/
+ if (! isdirsep(*(p - 1))) *p++ = '/';
+ while (*s && !isdirsep(*s)) {
+ *p++ = *s++;
+ }
+ }
+ chdir(oldcwd);
+ }
+ }
+#endif
+#if defined DOSISH && ! defined(__CYGWIN__)
+ else if (isdirsep(*s)) {
+ /* specified full path, but not drive letter */
+ /* we need to get the drive letter */
+ tainted = 1;
+#ifdef HAVE_GETCWD
+ getcwd(buf, MAXPATHLEN);
+#else
+ getwd(buf);
+#endif
+ p = &buf[2];
+ while (*s && !isdirsep(*s)) {
+ *p++ = *s++;
+ }
}
#endif
- else if (!isdirsep(*s)) {
+ else if (!is_absolute_path(s)) {
if (!NIL_P(dname)) {
dname = rb_file_s_expand_path(1, &dname);
if (OBJ_TAINTED(dname)) tainted = 1;
@@ -1367,7 +1418,7 @@
#endif
}
p = &buf[strlen(buf)];
- while (p > buf && *(p - 1) == '/') p--;
+ while (p > buf && isdirsep(*(p - 1))) p--;
}
else {
while (*s && isdirsep(*s)) {
@@ -1418,6 +1469,13 @@
/* 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';
fname = rb_str_new2(buf);
@@ -1448,6 +1506,20 @@
return 0;
}
+
+static char *
+strrdirsep(name)
+ char *name;
+{
+ char *last = NULL;
+ do {
+ if (isdirsep(*name)) last = name;
+ name++;
+ }
+ while( *name );
+ return last;
+}
+
static VALUE
rb_file_s_basename(argc, argv)
int argc;
@@ -1461,7 +1533,7 @@
ext = StringValuePtr(fext);
}
name = StringValuePtr(fname);
- p = strrchr(name, '/');
+ p = strrdirsep(name);
if (!p) {
if (NIL_P(fext) || !(f = rmext(name, ext)))
return fname;
@@ -1488,12 +1560,16 @@
VALUE dirname;
name = StringValuePtr(fname);
- p = strrchr(name, '/');
+ p = strrdirsep(name);
if (!p) {
return rb_str_new2(".");
}
if (p == name)
p++;
+#if defined(DOSISH)
+ if ( ISALPHA(name[0]) && name[1] == ':' && p == &name[2])
+ p++;
+#endif
dirname = rb_str_new(name, p - name);
if (OBJ_TAINTED(fname)) OBJ_TAINT(dirname);
return dirname;
@@ -2121,10 +2197,11 @@
is_absolute_path(path)
const char *path;
{
+#if ! defined(DOSISH) || defined(__CYGWIN__)
if (path[0] == '/') return 1;
+#endif
# if defined DOSISH
- if (path[0] == '\\') return 1;
- if (strlen(path) > 2 && path[1] == ':') return 1;
+ if (strlen(path) > 3 && path[1] == ':' && isdirsep(path[2]) ) return 1;
# endif
return 0;
}
@@ -2155,7 +2232,7 @@
if (p) *p = '/';
return 0;
}
- s = strrchr(path, '/');
+ s = strrdirsep(path);
if (p) *p = '/';
if (!s || s == path) return 1;
p = s;
require 'runit/testcase'
require 'runit/cui/testrunner'
require 'rbconfig'
class TestFile_basename < RUNIT::TestCase
def test_basename_separator
dirname = 'dir'
basename = 'basename.txt'
expandpath = dirname + File::SEPARATOR + basename
assert_equal ( basename, File.basename( expandpath ) )
end
if ! File::ALT_SEPARATOR.nil? then
def test_basename_alt_separator
dirname = 'dir'
basename = 'basename.txt'
expandpath = dirname + File::ALT_SEPARATOR + basename
assert_equal ( basename, File.basename( expandpath ) )
end
end
end
class TestFile_dirname < RUNIT::TestCase
def test_dirname_separator
dirname = 'dir'
basename = 'basename.txt'
expandpath = dirname + File::SEPARATOR + basename
assert_equal ( dirname, File.dirname( expandpath ) )
end
if ! File::ALT_SEPARATOR.nil? then
def test_dirname_alt_separator
dirname = 'dir'
basename = 'basename.txt'
expandpath = dirname + File::ALT_SEPARATOR + basename
assert_equal ( dirname, File.dirname( expandpath ) )
end
end
if ["mswin32"].include?( Config::CONFIG["host_os"]) then
def test_dirname_dos
assert_equal ( "c:/winnt/system32", File.dirname(
"c:/winnt/system32/test.txt" ) )
end
def test_dirname_dos_root
assert_equal ( "c:/", File.dirname( "c:/test.txt" ) )
end
end
def test_dirname_root
assert_equal ( "/", File.dirname( "/test.txt" ) )
end
end
class TestFile_join < RUNIT::TestCase
def test_join_root
assert_equal ( "/test.txt", File.join( "/", "test.txt" ) )
end
def test_join_non_root
assert_equal ( "/etc/test.txt", File.join( "/etc", "test.txt" ) )
end
def test_join_non_root_with_trailing_slash
assert_equal ( "/etc/test.txt", File.join( "/etc/", "test.txt" ) )
end
end
class TestFile_expand_path < RUNIT::TestCase
if ! ["mswin32"].include?( Config::CONFIG["host_os"]) then
def test_expand_path_root
assert_equal ( "/", File::expand_path( "/" ) )
end
end
if ["mswin32"].include?( Config::CONFIG["host_os"]) then
def test_expand_path_root
Dir::chdir( "c:/winnt/system32" )
assert_equal ( "c:/", File::expand_path( "/" ) )
end
def test_expand_path_dos_root_forward_slash
assert_equal ( "c:/", File::expand_path( "c:/" ) )
end
def test_expand_path_dos_root_backward_slash
assert_equal ( "c:/", File::expand_path( "c:\\" ) )
end
def test_expand_path_dos_non_root_forward_slash
assert_equal ( "c:/winnt/system32/test.txt", File::expand_path(
"c:/winnt/system32/test.txt" ) )
end
def test_expand_path_dos_non_root_backward_slash
assert_equal ( "c:/winnt/system32/test.txt", File::expand_path(
"c:\\winnt\\system32\\test.txt" ) )
end
def test_expand_path_dos_drive_only
Dir::chdir( "c:/winnt/system32" )
assert_equal ( "c:/winnt/system32", File::expand_path( "c:" ) )
end
def test_expand_path_dos_drive_relative_path
Dir::chdir( "c:/winnt/system32" )
assert_equal ( "c:/winnt/system32/test.txt", File::expand_path(
"c:test.txt" ) )
end
end
end
suite = RUNIT::TestSuite.new
suite.add_test(TestFile_basename.suite)
suite.add_test(TestFile_dirname.suite)
suite.add_test(TestFile_expand_path.suite)
# join current does not deal with trailing separator
#suite.add_test(TestFile_join.suite)
RUNIT::CUI::TestRunner.quiet_mode = true
RUNIT::CUI::TestRunner.run(suite)