mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
* file.c (rb_find_file): $LOAD_PATH must not be empty.
* file.c (rb_find_file_ext): ditto. * range.c (range_eq): class check should be based on range.class, instead of Range to work with Range.dup. * range.c (range_eql): ditto. * class.c (rb_mod_dup): need to preserve metaclass and flags. * object.c (rb_cstr_to_dbl): had a buffer overrun. * marshal.c (w_class): integrate singleton check into a funciton to follow DRY principle. * marshal.c (w_uclass): should check singleton method. * object.c (rb_obj_dup): dmark and dfree functions must be match for T_DATA type. * object.c (rb_obj_dup): class of the duped object must be match to the class of the original. * re.c (rb_reg_quote): do not escape \t, \f, \r, \n, for they are not regular expression metacharacters. * time.c (time_s_alloc): use time_free instead of free (null check, also serves for type mark). * time.c (time_s_at): check dfree function too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
cd3d4a01f2
commit
c45908e41f
18 changed files with 268 additions and 255 deletions
66
marshal.c
66
marshal.c
|
@ -250,11 +250,40 @@ obj_each(id, value, arg)
|
|||
}
|
||||
|
||||
static void
|
||||
w_uclass(obj, klass, arg)
|
||||
VALUE obj, klass;
|
||||
w_class(obj, arg)
|
||||
VALUE obj;
|
||||
struct dump_arg *arg;
|
||||
{
|
||||
if (rb_obj_class(obj) != klass) {
|
||||
VALUE klass = CLASS_OF(obj);
|
||||
char *path;
|
||||
|
||||
while (FL_TEST(klass, FL_SINGLETON) || BUILTIN_TYPE(klass) == T_ICLASS) {
|
||||
if (RCLASS(klass)->m_tbl->num_entries > 0 ||
|
||||
RCLASS(klass)->iv_tbl->num_entries > 1) {
|
||||
rb_raise(rb_eTypeError, "singleton can't be dumped");
|
||||
}
|
||||
}
|
||||
path = rb_class2name(klass);
|
||||
w_unique(path, arg);
|
||||
}
|
||||
|
||||
static void
|
||||
w_uclass(obj, base_klass, arg)
|
||||
VALUE obj, base_klass;
|
||||
struct dump_arg *arg;
|
||||
{
|
||||
VALUE klass = CLASS_OF(obj);
|
||||
char *path;
|
||||
|
||||
while (FL_TEST(klass, FL_SINGLETON) || BUILTIN_TYPE(klass) == T_ICLASS) {
|
||||
if (RCLASS(klass)->m_tbl->num_entries > 0 ||
|
||||
RCLASS(klass)->iv_tbl->num_entries > 1) {
|
||||
rb_raise(rb_eTypeError, "singleton can't be dumped");
|
||||
}
|
||||
klass = RCLASS(klass)->super;
|
||||
}
|
||||
|
||||
if (klass != base_klass) {
|
||||
w_byte(TYPE_UCLASS, arg);
|
||||
w_unique(rb_class2name(CLASS_OF(obj)), arg);
|
||||
}
|
||||
|
@ -472,41 +501,16 @@ w_object(obj, arg, limit)
|
|||
|
||||
case T_OBJECT:
|
||||
w_byte(TYPE_OBJECT, arg);
|
||||
{
|
||||
VALUE klass = CLASS_OF(obj);
|
||||
char *path;
|
||||
|
||||
while (FL_TEST(klass, FL_SINGLETON) || BUILTIN_TYPE(klass) == T_ICLASS) {
|
||||
if (RCLASS(klass)->m_tbl->num_entries > 0 ||
|
||||
RCLASS(klass)->iv_tbl->num_entries > 1) {
|
||||
rb_raise(rb_eTypeError, "singleton can't be dumped");
|
||||
}
|
||||
klass = RCLASS(klass)->super;
|
||||
}
|
||||
path = rb_class2name(klass);
|
||||
w_unique(path, arg);
|
||||
w_ivar(ROBJECT(obj)->iv_tbl, &c_arg);
|
||||
}
|
||||
w_class(obj, arg);
|
||||
w_ivar(ROBJECT(obj)->iv_tbl, &c_arg);
|
||||
break;
|
||||
|
||||
case T_DATA:
|
||||
w_byte(TYPE_DATA, arg);
|
||||
{
|
||||
VALUE klass = CLASS_OF(obj);
|
||||
char *path;
|
||||
|
||||
if (FL_TEST(klass, FL_SINGLETON)) {
|
||||
if (RCLASS(klass)->m_tbl->num_entries > 0 ||
|
||||
RCLASS(klass)->iv_tbl->num_entries > 1) {
|
||||
rb_raise(rb_eTypeError, "singleton can't be dumped");
|
||||
}
|
||||
}
|
||||
path = rb_class2name(klass);
|
||||
w_unique(path, arg);
|
||||
}
|
||||
{
|
||||
VALUE v;
|
||||
|
||||
w_class(obj, arg);
|
||||
if (!rb_respond_to(obj, s_dump_data)) {
|
||||
rb_raise(rb_eTypeError,
|
||||
"class %s needs to have instance method `_dump_data'",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue