Skip to content

Commit

Permalink
* time.c (time_load): restore instance variables (if any) before
Browse files Browse the repository at this point in the history
  loading from marshaled data.

* time.c (time_mdump): new marshal dumper. _dump is still
  available for compatibility.

* time.c (time_mload): new marshal loader.

* marshal.c (w_object): preserve instance variables for objects
  with marshal_dump.

* marshal.c (r_object0): restore instance variables before calling
  marshal_load.

* error.c (rb_warn_m): always return nil.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Oct 2, 2003
1 parent a70a430 commit 10c4bb2
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 80 deletions.
20 changes: 20 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
Thu Oct 2 17:22:37 2003 Yukihiro Matsumoto <[email protected]>

* time.c (time_load): restore instance variables (if any) before
loading from marshaled data.

Thu Oct 2 14:19:15 2003 Nobuyoshi Nakada <[email protected]>

* ext/iconv/iconv.c (iconv_fail): now yield erred substring, and
Expand Down Expand Up @@ -37,6 +42,21 @@ Thu Oct 2 03:25:01 2003 NAKAMURA Usaku <[email protected]>

* eval.c (rb_thread_raise): prototype; avoid VC++ warning.

Thu Oct 2 01:37:34 2003 Yukihiro Matsumoto <[email protected]>

* time.c (time_mdump): new marshal dumper. _dump is still
available for compatibility.

* time.c (time_mload): new marshal loader.

* marshal.c (w_object): preserve instance variables for objects
with marshal_dump.

* marshal.c (r_object0): restore instance variables before calling
marshal_load.

* error.c (rb_warn_m): always return nil.

Thu Oct 2 01:32:46 2003 Yukihiro Matsumoto <[email protected]>

* eval.c (rb_f_block_given_p): real required condition is
Expand Down
9 changes: 5 additions & 4 deletions error.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,11 @@ static VALUE
rb_warn_m(self, mesg)
VALUE self, mesg;
{
if (NIL_P(ruby_verbose)) return;
rb_io_write(rb_stderr, mesg);
rb_io_write(rb_stderr, rb_default_rs);
return mesg;
if (!NIL_P(ruby_verbose)) {
rb_io_write(rb_stderr, mesg);
rb_io_write(rb_stderr, rb_default_rs);
}
return Qnil;
}

void
Expand Down
14 changes: 13 additions & 1 deletion eval.c
Original file line number Diff line number Diff line change
Expand Up @@ -10187,7 +10187,19 @@ rb_catch(tag, func, data)
VALUE (*func)();
VALUE data;
{
return rb_iterate((VALUE(*)_((VALUE)))catch_i, ID2SYM(rb_intern(tag)), func, data);
int state;
VALUE val = Qnil; /* OK */

PUSH_TAG(PROT_NONE);
PUSH_SCOPE();
if ((state = EXEC_TAG()) == 0) {
val = rb_iterate((VALUE(*)_((VALUE)))catch_i, ID2SYM(rb_intern(tag)), func, data);
}
POP_SCOPE();
POP_TAG();
if (state) JUMP_TAG(state);

return val;
}

static VALUE
Expand Down
73 changes: 47 additions & 26 deletions marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,11 +482,15 @@ w_object(obj, arg, limit)
if (rb_respond_to(obj, s_mdump)) {
VALUE v;

if (TYPE(obj) == T_OBJECT) {
w_byte(TYPE_IVAR, arg);
ivtbl = ROBJECT(obj)->iv_tbl;
}
v = rb_funcall(obj, s_mdump, 0, 0);
w_byte(TYPE_USRMARSHAL, arg);
w_unique(rb_class2name(CLASS_OF(obj)), arg);
w_object(v, arg, limit);
if (ivtbl) w_ivar(0, &c_arg); /* do not dump generic_ivar */
if (ivtbl) w_ivar(ivtbl, &c_arg);
return;
}
if (rb_respond_to(obj, s_dump)) {
Expand All @@ -498,7 +502,7 @@ w_object(obj, arg, limit)
}
w_class(TYPE_USERDEF, obj, arg);
w_bytes(RSTRING(v)->ptr, RSTRING(v)->len, arg);
if (ivtbl) w_ivar(0, &c_arg);
if (ivtbl) w_ivar(ivtbl, &c_arg);
return;
}

Expand Down Expand Up @@ -897,7 +901,7 @@ r_string(arg)
}

static VALUE
r_regist(v, arg)
r_entry(v, arg)
VALUE v;
struct load_arg *arg;
{
Expand Down Expand Up @@ -948,9 +952,10 @@ path2module(path)
}

static VALUE
r_object0(arg, proc)
r_object0(arg, proc, ivp)
struct load_arg *arg;
VALUE proc;
int *ivp;
{
VALUE v = Qnil;
int type = r_byte(arg);
Expand All @@ -966,15 +971,19 @@ r_object0(arg, proc)
return v;

case TYPE_IVAR:
v = r_object0(arg, 0);
r_ivar(v, arg);
{
int ivar = Qtrue;

v = r_object0(arg, 0, &ivar);
if (ivar) r_ivar(v, arg);
}
break;

case TYPE_EXTENDED:
{
VALUE m = path2module(r_unique(arg));

v = r_object0(arg, 0);
v = r_object0(arg, 0, 0);
rb_extend_object(v, m);
}
break;
Expand All @@ -986,7 +995,7 @@ r_object0(arg, proc)
if (FL_TEST(c, FL_SINGLETON)) {
rb_raise(rb_eTypeError, "singleton can't be loaded");
}
v = r_object0(arg, 0);
v = r_object0(arg, 0, 0);
if (rb_special_const_p(v) || TYPE(v) == T_OBJECT || TYPE(v) == T_CLASS) {
format_error:
rb_raise(rb_eArgError, "dump format error (user class)");
Expand Down Expand Up @@ -1040,7 +1049,7 @@ r_object0(arg, proc)
d = load_mantissa(d, e, RSTRING(str)->len - (e - ptr));
}
v = rb_float_new(d);
r_regist(v, arg);
r_entry(v, arg);
}
break;

Expand Down Expand Up @@ -1085,19 +1094,19 @@ r_object0(arg, proc)
len--;
}
v = rb_big_norm((VALUE)big);
r_regist(v, arg);
r_entry(v, arg);
}
break;

case TYPE_STRING:
v = r_regist(r_string(arg), arg);
v = r_entry(r_string(arg), arg);
break;

case TYPE_REGEXP:
{
volatile VALUE str = r_bytes(arg);
int options = r_byte(arg);
v = r_regist(rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len, options), arg);
v = r_entry(rb_reg_new(RSTRING(str)->ptr, RSTRING(str)->len, options), arg);
}
break;

Expand All @@ -1106,7 +1115,7 @@ r_object0(arg, proc)
volatile long len = r_long(arg); /* gcc 2.7.2.3 -O2 bug?? */

v = rb_ary_new2(len);
r_regist(v, arg);
r_entry(v, arg);
while (len--) {
rb_ary_push(v, r_object(arg));
}
Expand All @@ -1119,7 +1128,7 @@ r_object0(arg, proc)
long len = r_long(arg);

v = rb_hash_new();
r_regist(v, arg);
r_entry(v, arg);
while (len--) {
VALUE key = r_object(arg);
VALUE value = r_object(arg);
Expand Down Expand Up @@ -1150,7 +1159,7 @@ r_object0(arg, proc)
rb_ary_push(values, Qnil);
}
v = rb_struct_alloc(klass, values);
r_regist(v, arg);
r_entry(v, arg);
for (i=0; i<len; i++) {
slot = r_symbol(arg);

Expand All @@ -1168,27 +1177,39 @@ r_object0(arg, proc)
case TYPE_USERDEF:
{
VALUE klass = path2class(r_unique(arg));
VALUE data;

if (!rb_respond_to(klass, s_load)) {
rb_raise(rb_eTypeError, "class %s needs to have method `_load'",
rb_class2name(klass));
}
v = rb_funcall(klass, s_load, 1, r_string(arg));
r_regist(v, arg);
data = r_string(arg);
if (ivp) {
r_ivar(data, arg);
*ivp = Qfalse;
}
v = rb_funcall(klass, s_load, 1, data);
r_entry(v, arg);
}
break;

case TYPE_USRMARSHAL:
{
VALUE klass = path2class(r_unique(arg));
VALUE data;

v = rb_obj_alloc(klass);
if (!rb_respond_to(v, s_mload)) {
rb_raise(rb_eTypeError, "instance of %s needs to have method `marshal_load'",
rb_class2name(klass));
}
r_regist(v, arg);
rb_funcall(v, s_mload, 1, r_object(arg));
r_entry(v, arg);
data = r_object(arg);
if (ivp) {
r_ivar(v, arg);
*ivp = Qfalse;
}
rb_funcall(v, s_mload, 1, data);
}
break;

Expand All @@ -1200,7 +1221,7 @@ r_object0(arg, proc)
if (TYPE(v) != T_OBJECT) {
rb_raise(rb_eArgError, "dump format error");
}
r_regist(v, arg);
r_entry(v, arg);
r_ivar(v, arg);
}
break;
Expand All @@ -1222,13 +1243,13 @@ r_object0(arg, proc)
if (TYPE(v) != T_DATA) {
rb_raise(rb_eArgError, "dump format error");
}
r_regist(v, arg);
r_entry(v, arg);
if (!rb_respond_to(v, s_load_data)) {
rb_raise(rb_eTypeError,
"class %s needs to have instance method `_load_data'",
rb_class2name(klass));
}
rb_funcall(v, s_load_data, 1, r_object0(arg, 0));
rb_funcall(v, s_load_data, 1, r_object0(arg, 0, 0));
}
break;

Expand All @@ -1237,7 +1258,7 @@ r_object0(arg, proc)
volatile VALUE str = r_bytes(arg);

v = rb_path2class(RSTRING(str)->ptr);
r_regist(v, arg);
r_entry(v, arg);
}
break;

Expand All @@ -1246,7 +1267,7 @@ r_object0(arg, proc)
volatile VALUE str = r_bytes(arg);

v = path2class(RSTRING(str)->ptr);
r_regist(v, arg);
r_entry(v, arg);
}
break;

Expand All @@ -1255,7 +1276,7 @@ r_object0(arg, proc)
volatile VALUE str = r_bytes(arg);

v = path2module(RSTRING(str)->ptr);
r_regist(v, arg);
r_entry(v, arg);
}
break;

Expand All @@ -1280,7 +1301,7 @@ static VALUE
r_object(arg)
struct load_arg *arg;
{
return r_object0(arg, arg->proc);
return r_object0(arg, arg->proc, 0);
}

static VALUE
Expand Down
13 changes: 8 additions & 5 deletions misc/ruby-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -685,15 +685,18 @@ The variable ruby-indent-level controls the amount of indentation.
(setq bol (point))
(end-of-line)
(skip-chars-backward " \t")
(let ((pos (point)))
(while (and (re-search-backward "#" bol t)
(ruby-special-char-p))
(forward-char -1))
(let (end (pos (point)))
(beginning-of-line)
(while (and (re-search-forward "#" pos t)
(setq end (1- (point)))
(ruby-special-char-p end))
(setq end nil))
(goto-char (or end pos))
(skip-chars-backward " \t")
(and
(setq state (ruby-parse-region parse-start (point)))
(nth 0 state)
(setq begin (nth 1 state))
(setq begin (cdr (nth 1 state)))
(goto-char pos)))
(or (bobp) (forward-char -1))
(and
Expand Down
Loading

0 comments on commit 10c4bb2

Please sign in to comment.