[#23295] [proposal] new function for mathing path name — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
山本です。
6 messages
2004/04/01
[#23296] Re: [proposal] new function for mathing path name
— matz@... (Yukihiro Matsumoto)
2004/04/01
まつもと ゆきひろです
[#23309] 100000000000000000000000 == 100000000000000000000000.0 — Tanaka Akira <akr@...17n.org>
ふと (またしても) 気がついたのですが、次のように
5 messages
2004/04/02
[#23310] Re: 100000000000000000000000 == 100000000000000000000000.0
— matz@... (Yukihiro Matsumoto)
2004/04/02
まつもと ゆきひろです
[#23311] Re: 100000000000000000000000 == 100000000000000000000000.0
— Tanaka Akira <akr@...17n.org>
2004/04/02
In article <1080884868.201381.30812.nullmailer@picachu.netlab.jp>,
[#23324] test_pack_U/test_huge_difference error — MIYAMUKO Katsuyuki <k-miyamuko@...>
みやむこです。
9 messages
2004/04/05
[#23353] Re: test_pack_U/test_huge_difference error
— "NAKAMURA, Hiroshi" <nakahiro@...>
2004/04/08
なひです。
[#23332] to_str再考 — matz@... (Yukihiro Matsumoto)
まつもと ゆきひろです
15 messages
2004/04/05
[#23392] Re: to_str再考
— nobu.nakada@...
2004/04/16
なかだです。
[#23396] Re: to_str再考
— Tanaka Akira <akr@...17n.org>
2004/04/16
In article <200404160100.i3G10FjJ003540@sharui.nakada.niregi.kanuma.tochigi.jp>,
[#23346] Solaris Errno::E000 — とみたまさひろ <tommy@...>
とみたです。
4 messages
2004/04/07
[#23380] [SEGV] make test-all (bccwin32 ruby1.9.0) — "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
山本です。
17 messages
2004/04/15
[#23400] Re: [SEGV] make test-all (bccwin32 ruby1.9.0)
— "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
2004/04/16
山本です。落ちる場所がわかりました。
[#23402] Re: [SEGV] make test-all (bccwin32 ruby1.9.0)
— "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
2004/04/16
山本です。
[#23403] Re: [SEGV] make test-all (bccwin32 ruby1.9.0)
— nobu.nakada@...
2004/04/16
なかだです。
[#23405] Re: [SEGV] make test-all (bccwin32 ruby1.9.0)
— "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
2004/04/16
山本です。
[#23407] Re: [SEGV] make test-all (bccwin32 ruby1.9.0)
— "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
2004/04/16
山本です。
[#23412] Re: [SEGV] make test-all (bccwin32 ruby1.9.0)
— "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
2004/04/20
山本です。原因を絞り込めました。
[#23413] Re: [SEGV] make test-all (bccwin32 ruby1.9.0)
— "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
2004/04/20
山本です。
[#23414] Re: [SEGV] make test-all (bccwin32 ruby1.9.0)
— "U.Nakamura" <usa@...>
2004/04/20
こんにちは、なかむら(う)です。
[#23415] Re: [SEGV] make test-all (bccwin32 ruby1.9.0)
— "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
2004/04/20
山本です。
[#23416] Re: [SEGV] make test-all (bccwin32 ruby1.9.0)
— "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
2004/04/20
山本です。
[#23417] Re: [SEGV] make test-all (bccwin32 ruby1.9.0)
— "H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
2004/04/20
山本です。SEGVの原因がわかりました。
[#23418] Re: [SEGV] make test-all (bccwin32 ruby1.9.0)
— nobu.nakada@...
2004/04/20
なかだです。
[#23381] gdbm read only access — Tanaka Akira <akr@...17n.org>
ふと、GDBM を read only で access したくなったのですが、GDBM.open には
4 messages
2004/04/15
[#23385] Process::Status as boolean — nobu.nakada@...
なかだです。
7 messages
2004/04/15
[#23394] drb test failure due to multiple value class — nobu.nakada@...
なかだです。
3 messages
2004/04/16
[#23408] Ruby/Bsearch — MoonWolf <moonwolf@...>
MoonWolfです。
6 messages
2004/04/19
[#23432] Resolv.getaddress(IPv6) causes error — "U.Nakamura" <usa@...>
こんにちは、なかむら(う)です。
7 messages
2004/04/23
[#23433] Re: Resolv.getaddress(IPv6) causes error
— Tanaka Akira <akr@...17n.org>
2004/04/23
In article <20040423115903.F2C7.USA@garbagecollect.jp>,
[#23434] Re: Resolv.getaddress(IPv6) causes error
— "U.Nakamura" <usa@...>
2004/04/23
こんにちは、なかむら(う)です。
[#23443] [Oniguruma] Version 2.2.8 — <kkosako@...>
ftp.ruby-lang.orgとhttp://www.geocities.jp/kosako1/に、
6 messages
2004/04/27
[ruby-dev:23386] Re: Dir.glob の '{ }' について
From:
"H.Yamamoto" <ocean@...2.ccsnet.ne.jp>
Date:
2004-04-15 09:21:08 UTC
List:
ruby-dev #23386
山本です。
>まだ十分な検証をしてませんが、一応動いているパッチを添付します。(少しリファクタリングもしました)
新しいパッチを送ります。
* dir.c(rb_push_glob): Dir.glob にブロックが渡されたときは false ではなくて nil を返す
(ruby-lang.org のリファレンスマニュアルより)
* dir.c(push_braces): { } が3重以上の入れ子になっていると正しく動かないバグを修正
* dir.c(rb_push_glob, push_braces): '{' '}' ',' を正しくエスケープできないバグを修正
ruby_1_8 にも同様の修正が必要だと思います。これをコミットしてもいいでしょうか?
Index: dir.c
===================================================================
RCS file: /ruby/ruby/dir.c,v
retrieving revision 1.117
diff -u -w -b -p -r1.117 dir.c
--- dir.c 12 Apr 2004 01:45:08 -0000 1.117
+++ dir.c 14 Apr 2004 12:24:10 -0000
@@ -1383,7 +1383,7 @@ push_pattern(path, ary)
{
VALUE str = rb_tainted_str_new2(path);
- if (ary) {
+ if (!NIL_P(ary)) {
rb_ary_push(ary, str);
}
else {
@@ -1392,123 +1392,88 @@ push_pattern(path, ary)
}
static int
-push_globs(ary, s, flags)
+push_glob(ary, s, flags)
VALUE ary;
const char *s;
int flags;
{
- return rb_glob2(s, flags, push_pattern, ary);
-}
+ const int escape = !(flags & FNM_NOESCAPE);
-static int
-push_braces(ary, s, flags)
- VALUE ary;
- const char *s;
- int flags;
-{
- char *buf, *b;
- const char *p, *t;
- const char *lbrace, *rbrace;
- int nest = 0;
- int status = 0;
+ const char *p = s;
+ const char *lbrace = 0, *rbrace = 0;
+ int nest = 0, status = 0;
- p = s;
- lbrace = rbrace = 0;
while (*p) {
- if (*p == '{') {
+ if (*p == '{' && nest++ == 0) {
lbrace = p;
- break;
}
- Inc(p);
- }
- while (*p) {
- if (*p == '{') nest++;
- if (*p == '}' && --nest == 0) {
+ if (*p == '}' && --nest <= 0) {
rbrace = p;
break;
}
+ if (*p == '\\' && escape) {
+ if (!*++p) break;
+ }
Inc(p);
}
if (lbrace && rbrace) {
- int len = strlen(s);
- buf = xmalloc(len + 1);
+ char *buf, *b;
+ buf = xmalloc(strlen(s) + 1);
memcpy(buf, s, lbrace-s);
b = buf + (lbrace-s);
p = lbrace;
- while (*p != '}') {
- t = Next(p);
- for (p = t; *p!='}' && *p!=','; Inc(p)) {
- /* skip inner braces */
- if (*p == '{') while (*p!='}') Inc(p);
+ while (p < rbrace) {
+ const char *t = ++p;
+ nest = 0;
+ while (p < rbrace && !(nest == 0 && *p == ',')) {
+ if (*p == '{') nest++;
+ if (*p == '}') nest--;
+ if (*p == '\\' && escape) {
+ if (++p == rbrace) break;
+ }
+ Inc(p);
}
memcpy(b, t, p-t);
- strcpy(b+(p-t), Next(rbrace));
- status = push_braces(ary, buf, flags);
+ strcpy(b+(p-t), rbrace+1);
+ status = push_glob(ary, buf, flags);
if (status) break;
}
free(buf);
}
- else {
- status = push_globs(ary, s, flags);
+ else if (!lbrace && !rbrace) {
+ status = rb_glob2(s, flags, push_pattern, ary);
}
return status;
}
-#define isdelim(c) ((c)=='\0')
static VALUE
-rb_push_glob(str, flags)
+rb_push_glob(str, flags) /* '\0' is delimiter */
VALUE str;
int flags;
{
const char *p, *pend;
- char *buf;
- const char *t;
- int nest, maxnest;
- int status = 0;
- int escape = !(flags & FNM_NOESCAPE);
VALUE ary;
if (rb_block_given_p())
- ary = 0;
+ ary = Qnil;
else
ary = rb_ary_new();
FilePathValue(str);
- buf = xmalloc(RSTRING(str)->len + 1);
p = RSTRING(str)->ptr;
pend = p + RSTRING(str)->len;
while (p < pend) {
- nest = maxnest = 0;
- while (p < pend && isdelim(*p)) p++;
- t = p;
- while (p < pend && !isdelim(*p)) {
- if (*p == '{') nest++, maxnest++;
- if (*p == '}') nest--;
- if (escape && *p == '\\') {
- p++;
- if (p == pend || isdelim(*p)) break;
- }
- Inc(p);
- }
- memcpy(buf, t, p - t);
- buf[p - t] = '\0';
- if (maxnest == 0) {
- status = push_globs(ary, buf, flags);
- if (status) break;
- }
- else if (nest == 0) {
- status = push_braces(ary, buf, flags);
- if (status) break;
- }
- /* else unmatched braces */
- }
- free(buf);
-
+ int status;
+ while (p < pend && *p == '\0') p++;
+ if (p == pend) break;
+ status = push_glob(ary, p, flags);
if (status) rb_jump_tag(status);
+ while (p < pend && *p != '\0') p++;
+ }
return ary;
}
@@ -1531,7 +1496,7 @@ dir_s_aref(obj, str)
/*
* call-seq:
* Dir.glob( string, [flags] ) => array
- * Dir.glob( string, [flags] ) {| filename | block } => false
+ * Dir.glob( string, [flags] ) {| filename | block } => nil
*
* Returns the filenames found by expanding the pattern given in
* <i>string</i>, either as an <i>array</i> or as parameters to the