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

* range.c (range_step): 'iter' here should be an array.

* marshal.c (w_object): should retrieve __member__ data from
  non-singleton class.

* variable.c (rb_cvar_get): class variable override check added.

* variable.c (rb_cvar_set): ditto

* variable.c (rb_cvar_declare): ditto.

* parse.y (parse_regx): handle backslash escaping of delimiter here.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-08-20 04:29:58 +00:00
parent 772ed5507e
commit c786866812
16 changed files with 101 additions and 52 deletions

View file

@ -1,3 +1,20 @@
Mon Aug 20 13:24:08 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* range.c (range_step): 'iter' here should be an array.
Mon Aug 20 12:43:08 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* marshal.c (w_object): should retrieve __member__ data from
non-singleton class.
Sat Aug 18 23:11:14 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* variable.c (rb_cvar_get): class variable override check added.
* variable.c (rb_cvar_set): ditto
* variable.c (rb_cvar_declare): ditto.
Fri Aug 17 12:13:48 2001 Minero Aoki <aamine@loveruby.net>
* lib/net/protocol.rb: Protocol.new requires at least one arg.
@ -8,6 +25,10 @@ Fri Aug 17 12:13:48 2001 Minero Aoki <aamine@loveruby.net>
* lib/net/http.rb: ditto.
Fri Aug 17 00:49:51 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (parse_regx): handle backslash escaping of delimiter here.
Thu Aug 16 13:54:04 2001 Usaku Nakamura <usa@ruby-lang.org>
* ext/socket/socket.c (s_recvfrom): fix typo.

1
ToDo
View file

@ -27,6 +27,7 @@ Language Spec.
* raise exception by `` error
* jar like combined library package.
* resumable Exception via Exception#resume.
* method combination, e.g. before, after, around, etc.
Hacking Interpreter

View file

@ -732,7 +732,7 @@ rb_ary_dup(ary)
{
VALUE dup = rb_ary_new2(RARRAY(ary)->len);
OBJSETUP(dup, rb_obj_type(ary), T_ARRAY);
OBJSETUP(dup, rb_obj_class(ary), T_ARRAY);
MEMCPY(RARRAY(dup)->ptr, RARRAY(ary)->ptr, VALUE, RARRAY(ary)->len);
RARRAY(dup)->len = RARRAY(ary)->len;
OBJ_INFECT(dup, ary);

View file

@ -244,7 +244,7 @@ VALUE rb_obj_tainted _((VALUE));
VALUE rb_obj_untaint _((VALUE));
VALUE rb_obj_freeze _((VALUE));
VALUE rb_obj_id _((VALUE));
VALUE rb_obj_type _((VALUE));
VALUE rb_obj_class _((VALUE));
VALUE rb_class_real _((VALUE));
VALUE rb_convert_type _((VALUE,int,const char*,const char*));
VALUE rb_to_int _((VALUE));

View file

@ -7,7 +7,7 @@ END, klEND, klEND, EXPR_END
alias, kALIAS, kALIAS, EXPR_FNAME
and, kAND, kAND, EXPR_BEG
begin, kBEGIN, kBEGIN, EXPR_BEG
break, kBREAK, kBREAK, EXPR_END
break, kBREAK, kBREAK, EXPR_MID
case, kCASE, kCASE, EXPR_BEG
class, kCLASS, kCLASS, EXPR_CLASS
def, kDEF, kDEF, EXPR_FNAME
@ -22,7 +22,7 @@ for, kFOR, kFOR, EXPR_BEG
if, kIF, kIF_MOD, EXPR_BEG
in, kIN, kIN, EXPR_BEG
module, kMODULE, kMODULE, EXPR_BEG
next, kNEXT, kNEXT, EXPR_END
next, kNEXT, kNEXT, EXPR_MID
nil, kNIL, kNIL, EXPR_END
not, kNOT, kNOT, EXPR_BEG
or, kOR, kOR, EXPR_BEG

4
lex.c
View file

@ -97,14 +97,14 @@ rb_reserved_word (str, len)
{"defined?", kDEFINED, kDEFINED, EXPR_ARG},
{"super", kSUPER, kSUPER, EXPR_ARG},
{"undef", kUNDEF, kUNDEF, EXPR_FNAME},
{"break", kBREAK, kBREAK, EXPR_END},
{"break", kBREAK, kBREAK, EXPR_MID},
{"in", kIN, kIN, EXPR_BEG},
{"do", kDO, kDO, EXPR_BEG},
{"nil", kNIL, kNIL, EXPR_END},
{"until", kUNTIL, kUNTIL_MOD, EXPR_BEG},
{"unless", kUNLESS, kUNLESS_MOD, EXPR_BEG},
{"or", kOR, kOR, EXPR_BEG},
{"next", kNEXT, kNEXT, EXPR_END},
{"next", kNEXT, kNEXT, EXPR_MID},
{"when", kWHEN, kWHEN, EXPR_BEG},
{"redo", kREDO, kREDO, EXPR_END},
{"and", kAND, kAND, EXPR_BEG},

View file

@ -25,7 +25,7 @@
#
#=end
class TimeoutError<StandardError
class TimeoutError<Interrupt
end
def timeout(sec)
@ -37,14 +37,20 @@ def timeout(sec)
x.raise TimeoutError, "execution expired" if x.alive?
}
yield sec
return true
# return true
ensure
Thread.kill y if y and y.alive?
y.kill if y and y.alive?
end
end
if __FILE__ == $0
timeout(5) {
p 10
p timeout(5) {
45
}
p timeout(5) {
loop {
p 10
sleep 1
}
}
end

View file

@ -293,7 +293,7 @@ w_object(obj, arg, limit)
w_byte(TYPE_FIXNUM, arg);
w_long(FIX2INT(obj), arg);
#else
if (RSHIFT((long)obj, 32) == 0 || RSHIFT((long)obj, 32) == -1) {
if (RSHIFT((long)obj, 30) == 0 || RSHIFT((long)obj, 30) == -1) {
w_byte(TYPE_FIXNUM, arg);
w_long(FIX2LONG(obj), arg);
}
@ -447,13 +447,12 @@ w_object(obj, arg, limit)
w_byte(TYPE_STRUCT, arg);
{
long len = RSTRUCT(obj)->len;
char *path = rb_class2name(CLASS_OF(obj));
VALUE mem;
long i;
w_unique(path, arg);
w_unique(rb_class2name(CLASS_OF(obj)), arg);
w_long(len, arg);
mem = rb_ivar_get(CLASS_OF(obj), rb_intern("__member__"));
mem = rb_ivar_get(rb_obj_class(obj), rb_intern("__member__"));
if (mem == Qnil) {
rb_raise(rb_eTypeError, "uninitialized struct");
}

View file

@ -81,7 +81,7 @@ rb_class_real(cl)
}
VALUE
rb_obj_type(obj)
rb_obj_class(obj)
VALUE obj;
{
return rb_class_real(CLASS_OF(obj));
@ -116,7 +116,7 @@ rb_obj_dup(obj)
rb_raise(rb_eTypeError, "dupulicated object must be same type");
}
if (!SPECIAL_CONST_P(dup)) {
OBJSETUP(dup, rb_obj_type(obj), BUILTIN_TYPE(obj));
OBJSETUP(dup, rb_obj_class(obj), BUILTIN_TYPE(obj));
OBJ_INFECT(dup, obj);
if (FL_TEST(obj, FL_EXIVAR)) {
FL_SET(dup, FL_EXIVAR);
@ -233,7 +233,7 @@ rb_obj_is_instance_of(obj, c)
rb_raise(rb_eTypeError, "class or module required");
}
if (rb_obj_type(obj) == c) return Qtrue;
if (rb_obj_class(obj) == c) return Qtrue;
return Qfalse;
}
@ -1155,8 +1155,8 @@ Init_Object()
rb_define_method(rb_mKernel, "hash", rb_obj_id, 0);
rb_define_method(rb_mKernel, "id", rb_obj_id, 0);
rb_define_method(rb_mKernel, "__id__", rb_obj_id, 0);
rb_define_method(rb_mKernel, "type", rb_obj_type, 0);
rb_define_method(rb_mKernel, "class", rb_obj_type, 0);
rb_define_method(rb_mKernel, "type", rb_obj_class, 0);
rb_define_method(rb_mKernel, "class", rb_obj_class, 0);
rb_define_method(rb_mKernel, "clone", rb_obj_clone, 0);
rb_define_method(rb_mKernel, "dup", rb_obj_dup, 0);

10
parse.y
View file

@ -2327,7 +2327,8 @@ read_escape()
}
static int
tokadd_escape()
tokadd_escape(term)
int term;
{
int c;
@ -2388,7 +2389,7 @@ tokadd_escape()
tokadd('\\'); tokadd('c');
escaped:
if ((c = nextc()) == '\\') {
return tokadd_escape();
return tokadd_escape(term);
}
else if (c == -1) goto eof;
tokadd(c);
@ -2400,7 +2401,8 @@ tokadd_escape()
return -1;
default:
tokadd('\\');
if (c == '/' && c != term)
tokadd('\\');
tokadd(c);
}
return 0;
@ -2431,7 +2433,7 @@ parse_regx(term, paren)
continue;
case '\\':
if (tokadd_escape() < 0)
if (tokadd_escape(term) < 0)
return 0;
continue;

View file

@ -286,7 +286,7 @@ range_step(argc, argv, range)
}
else if (TYPE(b) == T_STRING) {
VALUE args[5];
long *iter;
long iter[2];
args[0] = b; args[1] = e; args[2] = range;
iter[0] = 1; iter[1] = NUM2LONG(step);

View file

@ -2897,6 +2897,7 @@ re_compile_fastmap(bufp)
case duplicate:
bufp->can_be_null = 1;
if (*p >= bufp->re_nsub) break;
fastmap['\n'] = 1;
case anychar_repeat:
case anychar:
@ -3740,6 +3741,8 @@ re_match(bufp, string_arg, size, pos, regs)
int regno = *p++; /* Get which register to match against */
register unsigned char *d2, *dend2;
/* Check if there's corresponding group */
if (regno >= num_regs) goto fail;
/* Check if corresponding group is still open */
if (IS_ACTIVE(reg_info[regno])) goto fail;

View file

@ -100,7 +100,7 @@ rb_str_new4(orig)
{
VALUE klass;
klass = rb_obj_type(orig);
klass = rb_obj_class(orig);
if (RSTRING(orig)->orig) {
VALUE str;
@ -257,7 +257,7 @@ rb_str_dup(str)
VALUE klass;
StringValue(str);
klass = rb_obj_type(str);
klass = rb_obj_class(str);
if (OBJ_FROZEN(str)) str2 = rb_str_new3(str);
else if (FL_TEST(str, STR_NO_ORIG)) {

View file

@ -16,16 +16,6 @@ VALUE rb_cStruct;
static VALUE struct_alloc _((int, VALUE*, VALUE));
static VALUE
class_of(obj)
VALUE obj;
{
obj = CLASS_OF(obj);
if (FL_TEST(obj, FL_SINGLETON))
return RCLASS(obj)->super;
return obj;
}
static VALUE
iv_get(obj, name)
VALUE obj;
@ -68,7 +58,7 @@ static VALUE
rb_struct_members(obj)
VALUE obj;
{
return rb_struct_s_members(class_of(obj));
return rb_struct_s_members(rb_obj_class(obj));
}
VALUE
@ -79,7 +69,7 @@ rb_struct_getmember(obj, id)
VALUE member, slot;
long i;
member = iv_get(class_of(obj), "__member__");
member = iv_get(rb_obj_class(obj), "__member__");
if (NIL_P(member)) {
rb_bug("uninitialized struct");
}
@ -140,7 +130,7 @@ rb_struct_set(obj, val)
VALUE member, slot;
long i;
member = iv_get(class_of(obj), "__member__");
member = iv_get(rb_obj_class(obj), "__member__");
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
@ -260,7 +250,7 @@ static VALUE
rb_struct_initialize(self, values)
VALUE self, values;
{
VALUE klass = CLASS_OF(self);
VALUE klass = rb_obj_class(self);
VALUE size;
long n;
@ -349,7 +339,7 @@ static VALUE
rb_struct_to_s(s)
VALUE s;
{
char *cname = rb_class2name(CLASS_OF(s));
char *cname = rb_class2name(rb_obj_class(s));
VALUE str = rb_str_new(0, strlen(cname) + 4);
sprintf(RSTRING(str)->ptr, "#<%s>", cname);
@ -361,11 +351,11 @@ static VALUE
inspect_struct(s)
VALUE s;
{
char *cname = rb_class2name(CLASS_OF(s));
char *cname = rb_class2name(rb_obj_class(s));
VALUE str, member;
long i;
member = iv_get(CLASS_OF(s), "__member__");
member = iv_get(rb_obj_class(s), "__member__");
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
@ -398,7 +388,7 @@ rb_struct_inspect(s)
VALUE s;
{
if (rb_inspecting_p(s)) {
char *cname = rb_class2name(CLASS_OF(s));
char *cname = rb_class2name(rb_obj_class(s));
VALUE str = rb_str_new(0, strlen(cname) + 8);
sprintf(RSTRING(str)->ptr, "#<%s:...>", cname);
@ -436,7 +426,7 @@ rb_struct_aref_id(s, id)
VALUE member;
long i, len;
member = iv_get(CLASS_OF(s), "__member__");
member = iv_get(rb_obj_class(s), "__member__");
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
@ -480,7 +470,7 @@ rb_struct_aset_id(s, id, val)
VALUE member;
long i, len;
member = iv_get(CLASS_OF(s), "__member__");
member = iv_get(rb_obj_class(s), "__member__");
if (NIL_P(member)) {
rb_bug("non-initialized struct");
}
@ -527,7 +517,7 @@ rb_struct_equal(s, s2)
long i;
if (TYPE(s2) != T_STRUCT) return Qfalse;
if (CLASS_OF(s) != CLASS_OF(s2)) return Qfalse;
if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse;
if (RSTRUCT(s)->len != RSTRUCT(s2)->len) {
rb_bug("inconsistent struct"); /* should never happen */
}

View file

@ -1376,6 +1376,22 @@ rb_cvar_singleton(obj)
return CLASS_OF(obj);
}
static void
cvar_override_check(id, a, b)
VALUE a, b;
{
a = RCLASS(a)->super;
while (a) {
if (!RCLASS(a)->iv_tbl) continue;
if (st_lookup(RCLASS(a)->iv_tbl,id,0)) {
rb_warning("class variable %s of %s is overridden by %s",
rb_id2name(id), rb_class2name(a),
rb_class2name(b));
}
a = RCLASS(a)->super;
}
}
void
rb_cvar_set(klass, id, val)
VALUE klass;
@ -1386,10 +1402,14 @@ rb_cvar_set(klass, id, val)
tmp = klass;
while (tmp) {
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,0)) {
if (!RCLASS(tmp)->iv_tbl) continue;
if (st_lookup(RCLASS(tmp)->iv_tbl,id,0)) {
if (!OBJ_TAINTED(tmp) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't modify class variable");
st_insert(RCLASS(tmp)->iv_tbl,id,val);
if (ruby_verbose) {
cvar_override_check(id, tmp, klass);
}
return;
}
tmp = RCLASS(tmp)->super;
@ -1416,6 +1436,9 @@ rb_cvar_declare(klass, id, val)
rb_warning("already initialized class variable %s", rb_id2name(id));
}
st_insert(RCLASS(tmp)->iv_tbl,id,val);
if (ruby_verbose) {
cvar_override_check(id, tmp, klass);
}
return;
}
tmp = RCLASS(tmp)->super;
@ -1434,7 +1457,11 @@ rb_cvar_get(klass, id)
tmp = klass;
while (tmp) {
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) {
if (!RCLASS(tmp)->iv_tbl) continue;
if (st_lookup(RCLASS(tmp)->iv_tbl,id,&value)) {
if (ruby_verbose) {
cvar_override_check(id, tmp, klass);
}
return value;
}
tmp = RCLASS(tmp)->super;

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.1"
#define RUBY_RELEASE_DATE "2001-08-16"
#define RUBY_RELEASE_DATE "2001-08-20"
#define RUBY_VERSION_CODE 171
#define RUBY_RELEASE_CODE 20010816
#define RUBY_RELEASE_CODE 20010820