1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

ping.rb patch

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@1184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-02-14 05:53:58 +00:00
parent 42f2fc1546
commit 742d73fd35
3 changed files with 14 additions and 12 deletions

23
dir.c
View file

@ -694,7 +694,14 @@ push_pattern(path, ary)
char *path;
VALUE ary;
{
rb_ary_push(ary, rb_tainted_str_new2(path));
VALUE str = rb_tainted_str_new2(path);
if (ary) {
rb_ary_push(ary, str);
}
else {
rb_yield(str);
}
}
static void
@ -768,10 +775,12 @@ dir_s_glob(dir, str)
char buffer[MAXPATHLEN], *buf = buffer;
char *t;
int nest;
VALUE ary;
VALUE ary = 0;
Check_SafeStr(str);
ary = rb_ary_new();
if (!rb_block_given_p()) {
ary = rb_ary_new();
}
if (RSTRING(str)->len >= MAXPATHLEN)
buf = xmalloc(RSTRING(str)->len + 1);
@ -798,14 +807,6 @@ dir_s_glob(dir, str)
}
if (buf != buffer)
free(buf);
if (rb_block_given_p()) {
long len = RARRAY(ary)->len;
VALUE *ptr = RARRAY(ary)->ptr;
while (len--) {
rb_yield(*ptr++);
}
}
return ary;
}

View file

@ -25,7 +25,6 @@ class CGI
md5.update('foobar')
md5.hexdigest[0,16]
end
private :create_new_id
def initialize(request, option={})
session_key = option['session_key'] || '_session_id'

View file

@ -47,6 +47,8 @@ module Ping
s = TCPsocket.new(host, service)
s.close
end
rescue Errno::ECONNREFUSED
return true
rescue
return false
end