[#26975] [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>

山本です。

56 messages 2005/09/07
[#26976] Re: [proposal] ANSI style function — Yukihiro Matsumoto <matz@...> 2005/09/07

まつもと ゆきひろです

[#26977] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/07

山本です。

[#26978] Re: [proposal] ANSI style function — nobu@... 2005/09/07

なかだです。

[#26979] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/07

山本です。

[#26980] Re: [proposal] ANSI style function — Yukihiro Matsumoto <matz@...> 2005/09/07

まつもと ゆきひろです

[#26983] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/08

山本です。

[#26988] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/08

山本です。

[#26989] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/08

山本です。

[#26990] Re: [proposal] ANSI style function — Yukihiro Matsumoto <matz@...> 2005/09/08

まつもと ゆきひろです

[#26991] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/08

山本です。

[#26995] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/09

山本です。

[#26996] Re: [proposal] ANSI style function — Yukihiro Matsumoto <matz@...> 2005/09/09

まつもと ゆきひろです

[#26998] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/09

山本です。

[#27000] Re: [proposal] ANSI style function — Takahiro Kambe <taca@...> 2005/09/09

In message <20050909220539.E1B26BB8.ocean@m2.ccsnet.ne.jp>

[#27001] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/10

山本です。

[#27002] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/10

山本です。

[#27003] Re: [proposal] ANSI style function — Yukihiro Matsumoto <matz@...> 2005/09/10

まつもと ゆきひろです

[#27004] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/10

山本です。

[#27005] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/10

山本です。

[#27006] Re: [proposal] ANSI style function — Yukihiro Matsumoto <matz@...> 2005/09/10

まつもと ゆきひろです

[#27007] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/10

山本です。

[#27008] Re: [proposal] ANSI style function — Yukihiro Matsumoto <matz@...> 2005/09/10

まつもと ゆきひろです

[#27009] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/10

山本です。

[#27011] Re: [proposal] ANSI style function — Yukihiro Matsumoto <matz@...> 2005/09/10

まつもと ゆきひろです

[#27013] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/10

山本です。

[#27016] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/11

山本です。

[#27015] Re: [proposal] ANSI style function — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/11

山本です。

[#26984] elimination of "extern int errno;" — Takahiro Kambe <taca@...>

こんにちは。

48 messages 2005/09/08
[#27023] sizeof(FILE) problem on DragonFly BSD — Takahiro Kambe <taca@...> 2005/09/12

In message <20050908.120716.71112483.taca@back-street.net>

[#27024] Re: sizeof(FILE) problem on DragonFly BSD — Yukihiro Matsumoto <matz@...> 2005/09/12

まつもと ゆきひろです

[#27025] Re: sizeof(FILE) problem on DragonFly BSD — Takahiro Kambe <taca@...> 2005/09/12

In message <1126489480.743964.31599.nullmailer@x31.priv.netlab.jp>

[#27027] Re: sizeof(FILE) problem on DragonFly BSD — Takahiro Kambe <taca@...> 2005/09/12

In message <20050912.104954.92585084.taca@back-street.net>

[#27029] Re: sizeof(FILE) problem on DragonFly BSD — Yukihiro Matsumoto <matz@...> 2005/09/12

まつもと ゆきひろです

[#27035] Re: sizeof(FILE) problem on DragonFly BSD — "U.Nakamura" <usa@...> 2005/09/12

こんにちは、なかむら(う)です。

[#27036] Re: sizeof(FILE) problem on DragonFly BSD — Yukihiro Matsumoto <matz@...> 2005/09/12

まつもと ゆきひろです

[#27079] ruby-1.8.3 status for release (Re: Re: sizeof(FILE) problem on DragonFly BSD) — Masayoshi Takahashi <maki@...> 2005/09/15

高橋征義です。

[#27081] Re: ruby-1.8.3 status for release (Re: Re: sizeof(FILE) problem on DragonFly BSD) — Yukihiro Matsumoto <matz@...> 2005/09/15

まつもと ゆきひろです

[#27082] Re: ruby-1.8.3 status for release — Masayoshi Takahashi <maki@...> 2005/09/15

高橋征義です。

[#27083] Re: ruby-1.8.3 status for release — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/09/15

山本です。

[#27099] Re: ruby-1.8.3 status for release — Hidetoshi NAGAI <nagai@...> 2005/09/15

永井@知能.九工大です.

[#27531] ruby/tk installation without tcl/tk (for 1.8.4) — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp> 2005/10/26

山本です。

[#27619] Re: ruby/tk installation without tcl/tk (for 1.8.4) — Hidetoshi NAGAI <nagai@...> 2005/11/02

永井@知能.九工大です.

[#27139] ruby-1.8.3 status for release — Masayoshi Takahashi <maki@...>

高橋征義です。

66 messages 2005/09/18
[#27193] Re: ruby-1.8.3 status for release — TAKAHASHI Masayoshi <maki@...> 2005/09/20

高橋征義です。

[#27251] 脆弱性レポート翻訳者募集 — Yukihiro Matsumoto <matz@...>

まつもと ゆきひろです

13 messages 2005/09/21

[#27321] RubyGemsとOS platformとの関係 — Daigo Moriwaki <techml@...>

こんにちは、森脇です。

42 messages 2005/09/26
[#27327] Re: RubyGemsとOS platformとの関係 — nobuyoshi nakada <nobuyoshi.nakada@...> 2005/09/27

なかだです。

[#27330] Re: RubyGemsとOS platformとの関係 — Yukihiro Matsumoto <matz@...> 2005/09/27

まつもと ゆきひろです

[#27337] Re: RubyGems と OS platform との関係 — NISHIO Mizuho <jurader@...> 2005/09/27

西尾瑞穂 と言います。

[#27343] Re: RubyGems と OS platform との関係 — Yukihiro Matsumoto <matz@...> 2005/09/28

まつもと ゆきひろです

[#27347] Re: RubyGems と OS platform との関係 — Tanaka Akira <akr@...17n.org> 2005/09/28

In article <1127872084.608903.6359.nullmailer@x31.priv.netlab.jp>,

[#27348] Re: RubyGems と OS platform との関係 — Yukihiro Matsumoto <matz@...> 2005/09/28

まつもと ゆきひろです

[#27359] Re: RubyGems と OS platform との関係 — Daigo Moriwaki <techml@...> 2005/09/28

森脇です。

[#27364] Re: RubyGems と OS platform との関係 — akira yamada / やまだあきら <akira@...> 2005/09/30

Daigo Moriwaki wrote:

[#27365] Re: RubyGems と OS platform との関係 — Tanaka Akira <akr@...17n.org> 2005/09/30

In article <433CC31E.20802@ruby-lang.org>,

[#27367] Re: RubyGems と OS platform との関係 — akira yamada / やまだあきら <akira@...> 2005/09/30

Tanaka Akira wrote:

[#27369] Re: RubyGems と OS platform との関係 — Tanaka Akira <akr@...17n.org> 2005/10/01

In article <433D4CED.9030005@ruby-lang.org>,

[ruby-dev:27068] Re: fail on make install

From: nobuyoshi nakada <nobuyoshi.nakada@...>
Date: 2005-09-14 04:47:33 UTC
List: ruby-dev #27068
なかだです。

At Thu, 1 Sep 2005 21:42:00 +0900,
U.Nakamura wrote in [ruby-dev:26940]:
> (1) 元々、glob はインタプリタから独立して動くようになっていて、
> (2) それがインタプリタに依存するようになって、
> (3) win32 で glob を呼ぶタイミングを ruby_init の後にしたら、
> (4) ruby を組み込む人たちからいろいろ問題が報告されて、
> (5) 仕方がないので ruby_init の前に戻したら、
> (6) いつの間にかまた glob が動かなくなっていた。
> 
> ということだと思うんですが、(2)の変更の理由は覚えてないし、(6)
> がなぜ起こったのかも把握してません。

(2)は、Dir.globのブロックの中で例外が起きたりしたときのために、
リソースをVALUEで管理しようとしたためです。

> とりあえず、(6)はなんでなのかご存知のひとー?

rb_protect()内部のコンテキストをcallccで外部から呼び出せないよ
うにするために、オブジェクトをマークとして割り当てるようにしま
した。これがruby_init前に起きるとGCが呼ばれることになります。

それともう一つ、(5)のときの修正漏れですが、rb_glob_caller()の引
数が呼び出し側とあっていないために、ここでもエラーになるか正し
くない結果になります。

たしかにfnmatch()とは無関係なので、名前を変えて外部からは指定で
きないようにしました。


Index: dir.c
===================================================================
RCS file: /cvs/ruby/src/ruby/dir.c,v
retrieving revision 1.144
diff -U2 -p -u -r1.144 dir.c
--- dir.c	12 Sep 2005 10:44:19 -0000	1.144
+++ dir.c	14 Sep 2005 04:41:27 -0000
@@ -891,10 +891,13 @@ dir_s_rmdir(VALUE obj, VALUE dir)
 }
 
+#define GLOB_VERBOSE	(1 << (sizeof(int) * CHAR_BIT - 1))
+
 /* System call with warning */
 static int
-do_stat(const char *path, struct stat *pst)
+do_stat(const char *path, struct stat *pst, int flags)
+
 {
     int ret = stat(path, pst);
-    if (ret < 0 && errno != ENOENT)
+    if (ret < 0 && (flags & GLOB_VERBOSE) && errno != ENOENT)
 	rb_protect((VALUE (*)_((VALUE)))rb_sys_warning, (VALUE)path, 0);
 
@@ -903,8 +906,8 @@ do_stat(const char *path, struct stat *p
 
 static int
-do_lstat(const char *path, struct stat *pst)
+do_lstat(const char *path, struct stat *pst, int flags)
 {
     int ret = lstat(path, pst);
-    if (ret < 0 && errno != ENOENT)
+    if (ret < 0 && (flags & GLOB_VERBOSE) && errno != ENOENT)
 	rb_protect((VALUE (*)_((VALUE)))rb_sys_warning, (VALUE)path, 0);
 
@@ -913,8 +916,8 @@ do_lstat(const char *path, struct stat *
 
 static DIR *
-do_opendir(const char *path)
+do_opendir(const char *path, int flags)
 {
     DIR *dirp = opendir(path);
-    if (dirp == NULL && errno != ENOENT && errno != ENOTDIR)
+    if (!dirp && (flags & GLOB_VERBOSE) && errno != ENOENT && errno != ENOTDIR)
 	rb_protect((VALUE (*)_((VALUE)))rb_sys_warning, (VALUE)path, 0);
 
@@ -1119,17 +1122,5 @@ glob_func_caller(VALUE val)
 }
 
-static int
-glob_call_func(void (*func) (const char *, VALUE), const char *path, VALUE arg)
-{
-    int status;
-    struct glob_args args;
-
-    args.func = func;
-    args.c = path;
-    args.v = arg;
-
-    rb_protect(glob_func_caller, (VALUE)&args, &status);
-    return status;
-}
+#define glob_call_func(func, path, arg) (*func)(path, arg)
 
 static int
@@ -1142,5 +1133,5 @@ glob_helper(
     struct glob_pattern **end,
     int flags,
-    void (*func) (const char *, VALUE),
+    int (*func)(const char *, VALUE),
     VALUE arg)
 {
@@ -1177,5 +1168,5 @@ glob_helper(
     if (*path) {
 	if (match_all && exist == UNKNOWN) {
-	    if (do_lstat(path, &st) == 0) {
+	    if (do_lstat(path, &st, flags) == 0) {
 		exist = YES;
 		isdir = S_ISDIR(st.st_mode) ? YES : S_ISLNK(st.st_mode) ? UNKNOWN : NO;
@@ -1187,5 +1178,5 @@ glob_helper(
 	}
 	if (match_dir && isdir == UNKNOWN) {
-	    if (do_stat(path, &st) == 0) {
+	    if (do_stat(path, &st, flags) == 0) {
 		exist = YES;
 		isdir = S_ISDIR(st.st_mode) ? YES : NO;
@@ -1212,5 +1203,5 @@ glob_helper(
     if (magical || recursive) {
 	struct dirent *dp;
-	DIR *dirp = do_opendir(*path ? path : ".");
+	DIR *dirp = do_opendir(*path ? path : ".", flags);
 	if (dirp == NULL) return 0;
 
@@ -1222,5 +1213,5 @@ glob_helper(
 		&& fnmatch("*", dp->d_name, flags) == 0) {
 #ifndef _WIN32
-		if (do_lstat(buf, &st) == 0)
+		if (do_lstat(buf, &st, flags) == 0)
 		    new_isdir = S_ISDIR(st.st_mode) ? YES : S_ISLNK(st.st_mode) ? UNKNOWN : NO;
 		else
@@ -1294,5 +1285,5 @@ glob_helper(
 
 static int
-rb_glob2(const char *path, int flags, void (*func) (const char *, VALUE), VALUE arg)
+ruby_glob0(const char *path, int flags, int (*func)(const char *, VALUE), VALUE arg)
 {
     struct glob_pattern *list;
@@ -1302,8 +1293,4 @@ rb_glob2(const char *path, int flags, vo
     int status;
 
-    if (flags & FNM_CASEFOLD) {
-	rb_warn("Dir.glob() ignores File::FNM_CASEFOLD");
-    }
-
     start = root = path;
 #if defined DOSISH
@@ -1329,26 +1316,41 @@ rb_glob2(const char *path, int flags, vo
 }
 
-struct rb_glob_args {
-    void (*func) _((const char*, VALUE));
-    VALUE arg;
-};
+int
+ruby_glob(const char *path, int flags, int (*func)(const char *, VALUE), VALUE arg)
+{
+    return ruby_glob0(path, flags & ~GLOB_VERBOSE, func, arg);
+}
 
-static void
+static int
 rb_glob_caller(const char *path, VALUE a)
 {
-    struct rb_glob_args *args = (struct rb_glob_args *)a;
-    (*args->func)(path, args->arg);
+    int status;
+    struct glob_args *args = (struct glob_args *)a;
+
+    args->c = path;
+    rb_protect(glob_func_caller, a, &status);
+    return status;
 }
 
-void
-rb_glob(const char *path, void (*func) (const char *, VALUE), VALUE arg)
+static int
+rb_glob2(const char *path, int flags, void (*func)(const char *, VALUE), VALUE arg)
 {
-    struct rb_glob_args args;
+    struct glob_args args;
     int status;
 
     args.func = func;
-    args.arg = arg;
-    status = rb_glob2(path, 0, rb_glob_caller, (VALUE)&args);
+    args.v = arg;
 
+    if (flags & FNM_CASEFOLD) {
+	rb_warn("Dir.glob() ignores File::FNM_CASEFOLD");
+    }
+
+    return ruby_glob0(path, flags | GLOB_VERBOSE, rb_glob_caller, (VALUE)&args);
+}
+
+void
+rb_glob(const char *path, void (*func) (const char *, VALUE), VALUE arg)
+{
+    int status = rb_glob2(path, 0, func, arg);
     if (status) rb_jump_tag(status);
 }


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

In This Thread