summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--dir.c1
-rw-r--r--hash.c6
-rw-r--r--io.c32
-rw-r--r--lib/cgi.rb2
5 files changed, 33 insertions, 22 deletions
diff --git a/ChangeLog b/ChangeLog
index 185e9feb29..a4f46a013a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,16 @@ Tue Mar 4 15:08:08 2003 WATANABE Hirofumi <eban@ruby-lang.org>
* missing/strftime.c: ditto.
+Tue Mar 4 10:11:32 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_popen): do not call rb_io_close() directly, call
+ "close" method instead. [ruby-dev:19717]
+
+ * io.c (rb_io_s_open): ditto.
+
+ * hash.c (rb_any_hash): remove DEFER_INTS. all do_hash() calls in
+ st.c are at the top of functions. No reentrant problem.
+
Tue Mar 4 01:19:21 2003 Akinori MUSHA <knu@iDaemons.org>
* ext/dl/MANIFEST: Exclude .cvsignore. [found by: eban]
@@ -569,6 +579,10 @@ Thu Jan 30 08:27:19 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* file.c (rb_file_s_expand_path): removed a sludge.
+Wed Jan 29 03:24:39 2003 Michal Rokos <michal@rokos.homeip.net>
+
+ * dir.c (glob_helper): memory leak fixed.
+
Tue Jan 28 04:45:03 2003 Akinori MUSHA <knu@iDaemons.org>
* instruby.rb (parse_args), ext/extmk.rb (parse_args): Prepend a
diff --git a/dir.c b/dir.c
index e3783b39f3..ed42213d17 100644
--- a/dir.c
+++ b/dir.c
@@ -778,6 +778,7 @@ glob_helper(path, sub, flags, func, arg)
sprintf(buf, "%s%s%s", base, (BASE) ? "/" : "", dp->d_name);
if (lstat(buf, &st) < 0) {
if (errno != ENOENT) rb_sys_warning(buf);
+ free(buf);
continue;
}
if (S_ISDIR(st.st_mode)) {
diff --git a/hash.c b/hash.c
index 81b882ed14..1bb4c93bf6 100644
--- a/hash.c
+++ b/hash.c
@@ -65,6 +65,8 @@ rb_any_cmp(a, b)
VALUE a, b;
{
VALUE args[2];
+
+ if (a == b) return 0;
if (FIXNUM_P(a) && FIXNUM_P(b)) {
return a != b;
}
@@ -72,10 +74,10 @@ rb_any_cmp(a, b)
TYPE(b) == T_STRING && RBASIC(b)->klass == rb_cString) {
return rb_str_cmp(a, b);
}
+ if (a == Qundef || b == Qundef) return -1;
if (SYMBOL_P(a) && SYMBOL_P(b)) {
return a != b;
}
- if (a == Qundef || b == Qundef) return -1;
args[0] = a;
args[1] = b;
@@ -99,12 +101,10 @@ rb_any_hash(a)
break;
default:
- DEFER_INTS;
hval = rb_funcall(a, id_hash, 0);
if (!FIXNUM_P(hval)) {
hval = rb_funcall(hval, '%', 1, INT2FIX(536870923));
}
- ENABLE_INTS;
return (int)FIX2LONG(hval);
}
}
diff --git a/io.c b/io.c
index 4865b7ce79..af370ddeb4 100644
--- a/io.c
+++ b/io.c
@@ -1422,6 +1422,12 @@ rb_io_close_m(io)
}
static VALUE
+io_close(io)
+{
+ return rb_funcall(io, rb_intern("close"), 0, 0);
+}
+
+static VALUE
rb_io_closed(io)
VALUE io;
{
@@ -2154,7 +2160,7 @@ rb_io_popen(str, argc, argv, klass)
}
RBASIC(port)->klass = klass;
if (rb_block_given_p()) {
- return rb_ensure(rb_yield, port, rb_io_close, port);
+ return rb_ensure(rb_yield, port, io_close, port);
}
return port;
}
@@ -2209,7 +2215,7 @@ rb_io_s_open(argc, argv, klass)
VALUE io = rb_class_new_instance(argc, argv, klass);
if (rb_block_given_p()) {
- return rb_ensure(rb_yield, io, rb_io_close, io);
+ return rb_ensure(rb_yield, io, io_close, io);
}
return io;
@@ -2999,16 +3005,6 @@ next_argv()
return Qtrue;
}
-static void
-any_close(file)
- VALUE file;
-{
- if (TYPE(file) == T_FILE)
- rb_io_close(file);
- else
- rb_funcall3(file, rb_intern("close"), 0, 0);
-}
-
static VALUE
argf_getline(argc, argv)
int argc;
@@ -3039,7 +3035,7 @@ argf_getline(argc, argv)
line = rb_io_getline(rs, fptr);
}
if (NIL_P(line) && next_p != -1) {
- any_close(current_file);
+ io_close(current_file);
next_p = 1;
goto retry;
}
@@ -3074,7 +3070,7 @@ rb_gets()
if (!next_argv()) return Qnil;
line = rb_io_gets(current_file);
if (NIL_P(line) && next_p != -1) {
- any_close(current_file);
+ io_close(current_file);
next_p = 1;
goto retry;
}
@@ -3725,7 +3721,7 @@ argf_read(argc, argv)
tmp = io_read(argc, argv, current_file);
}
if (NIL_P(tmp) && next_p != -1) {
- any_close(current_file);
+ io_close(current_file);
next_p = 1;
goto retry;
}
@@ -3758,7 +3754,7 @@ argf_getc()
byte = rb_io_getc(current_file);
}
if (NIL_P(byte) && next_p != -1) {
- any_close(current_file);
+ io_close(current_file);
next_p = 1;
goto retry;
}
@@ -3850,7 +3846,7 @@ static VALUE
argf_skip()
{
if (next_p != -1) {
- any_close(current_file);
+ io_close(current_file);
next_p = 1;
}
return argf;
@@ -3859,7 +3855,7 @@ argf_skip()
static VALUE
argf_close()
{
- any_close(current_file);
+ io_close(current_file);
if (next_p != -1) {
next_p = 1;
}
diff --git a/lib/cgi.rb b/lib/cgi.rb
index a69fb4cc87..2e18bfd20d 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -497,7 +497,7 @@ status:
$stderr.printf("name:%s value:%s\n", name, value) if $DEBUG
case name
when 'Set-Cookie'
- table.add($1, $2)
+ table.add(name, value)
when /^status$/ni
Apache::request.status_line = value
Apache::request.status = value.to_i