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

* marshal.c (w_class): should not dump singleton class.

[ruby-dev:22631]

* marshal.c (class2path): check anonymous class/module before
  checking referable, and allow singleton classes.

* marshal.c (class2path): get class path and check referable.
  [ruby-dev:22588]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@6421 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-05-27 07:50:04 +00:00
parent 588394468c
commit f4c7c5dc07
4 changed files with 46 additions and 23 deletions

View file

@ -1489,6 +1489,11 @@ Tue Jan 20 02:49:22 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
* ext/openssl/extconf.rb: add check for OpenSSL version. * ext/openssl/extconf.rb: add check for OpenSSL version.
[ruby-list:39054] [ruby-list:39054]
Tue Jan 20 02:38:13 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* marshal.c (w_class): should not dump singleton class.
[ruby-dev:22631]
Tue Jan 20 01:31:36 2004 WATANABE Hirofumi <eban@ruby-lang.org> Tue Jan 20 01:31:36 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* io.c (lineno): typo fix(FIX2INT -> INT2FIX). * io.c (lineno): typo fix(FIX2INT -> INT2FIX).
@ -1515,6 +1520,16 @@ Sun Jan 18 02:33:26 2004 WATANABE Hirofumi <eban@ruby-lang.org>
* defines.h (_WIN32): undef _WIN32 on Cygwin before defining DOSISH. * defines.h (_WIN32): undef _WIN32 on Cygwin before defining DOSISH.
Sun Jan 18 00:23:55 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (class2path): check anonymous class/module before
checking referable, and allow singleton classes.
Fri Jan 16 14:33:35 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
* marshal.c (class2path): get class path and check referable.
[ruby-dev:22588]
Fri Jan 16 09:52:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org> Fri Jan 16 09:52:23 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (proc_eq): Proc with empty body may not be equal. * eval.c (proc_eq): Proc with empty body may not be equal.

View file

@ -1547,14 +1547,9 @@ class CGI
body = "" body = ""
end end
if @output_hidden if @output_hidden
hidden = @output_hidden.collect{|k,v| body += @output_hidden.collect{|k,v|
"<INPUT TYPE=HIDDEN NAME=\"#{k}\" VALUE=\"#{v}\">" "<INPUT TYPE=\"HIDDEN\" NAME=\"#{k}\" VALUE=\"#{v}\">"
}.to_s }.to_s
if defined? fieldset
body += fieldset{ hidden }
else
body += hidden
end
end end
super(attributes){body} super(attributes){body}
end end

View file

@ -189,11 +189,14 @@ class ConditionVariable
# Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup. # Releases the lock held in +mutex+ and waits; reacquires the lock on wakeup.
# #
def wait(mutex) def wait(mutex)
mutex.exclusive_unlock do begin
@waiters.push(Thread.current) mutex.exclusive_unlock do
Thread.stop @waiters.push(Thread.current)
Thread.stop
end
ensure
mutex.lock
end end
mutex.lock
end end
# #

View file

@ -98,6 +98,24 @@ struct dump_call_arg {
int limit; int limit;
}; };
static VALUE
class2path(klass)
VALUE klass;
{
VALUE path = rb_class_path(klass);
char *n = RSTRING(path)->ptr;
if (n[0] == '#') {
rb_raise(rb_eTypeError, "can't dump anonymous %s %s",
(TYPE(klass) == T_CLASS ? "class" : "module"),
n);
}
if (rb_path2class(n) != rb_class_real(klass)) {
rb_raise(rb_eTypeError, "%s cannot be referred", n);
}
return path;
}
static void w_long _((long, struct dump_arg*)); static void w_long _((long, struct dump_arg*));
static void static void
@ -382,7 +400,7 @@ w_class(type, obj, arg, check)
VALUE klass = CLASS_OF(obj); VALUE klass = CLASS_OF(obj);
w_extended(klass, arg, check); w_extended(klass, arg, check);
w_byte(type, arg); w_byte(type, arg);
path = rb_class2name(klass); path = RSTRING(class2path(rb_class_real(klass)))->ptr;
w_unique(path, arg); w_unique(path, arg);
} }
@ -397,7 +415,7 @@ w_uclass(obj, base_klass, arg)
klass = rb_class_real(klass); klass = rb_class_real(klass);
if (klass != base_klass) { if (klass != base_klass) {
w_byte(TYPE_UCLASS, arg); w_byte(TYPE_UCLASS, arg);
w_unique(rb_class2name(klass), arg); w_unique(RSTRING(class2path(klass))->ptr, arg);
} }
} }
@ -517,11 +535,7 @@ w_object(obj, arg, limit)
} }
w_byte(TYPE_CLASS, arg); w_byte(TYPE_CLASS, arg);
{ {
VALUE path = rb_class_path(obj); VALUE path = class2path(obj);
if (RSTRING(path)->ptr[0] == '#') {
rb_raise(rb_eTypeError, "can't dump anonymous class %s",
RSTRING(path)->ptr);
}
w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg); w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg);
} }
break; break;
@ -529,11 +543,7 @@ w_object(obj, arg, limit)
case T_MODULE: case T_MODULE:
w_byte(TYPE_MODULE, arg); w_byte(TYPE_MODULE, arg);
{ {
VALUE path = rb_class_path(obj); VALUE path = class2path(obj);
if (RSTRING(path)->ptr[0] == '#') {
rb_raise(rb_eTypeError, "can't dump anonymous module %s",
RSTRING(path)->ptr);
}
w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg); w_bytes(RSTRING(path)->ptr, RSTRING(path)->len, arg);
} }
break; break;