зеркало из https://github.com/github/ruby.git
* re.c (rb_reg_initialize_m): should raise exception instead of
compile error. [ruby-core:03755] * string.c (rb_str_splice): move rb_str_modify() after StringValue(), which may alter the receiver. [ruby-dev:24878] * error.c (rb_error_frozen): now raise RuntimeError instead of TypeError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
3ad741f132
Коммит
288ceaeec2
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
Wed Nov 17 09:38:18 2004 Johan Holmberg <holmberg@iar.se>
|
||||
|
||||
* re.c (rb_reg_initialize_m): should raise exception instead of
|
||||
compile error. [ruby-core:03755]
|
||||
|
||||
Wed Nov 17 03:42:45 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* string.c (rb_str_splice): move rb_str_modify() after
|
||||
StringValue(), which may alter the receiver. [ruby-dev:24878]
|
||||
|
||||
* error.c (rb_error_frozen): now raise RuntimeError instead of
|
||||
TypeError.
|
||||
|
||||
Tue Nov 16 21:22:47 2004 Michael Neumann <mneumann@ruby-lang.org>
|
||||
|
||||
* lib/xmlrpc/server.rb (CGIServer): fixed bug when client sends
|
||||
|
|
2
error.c
2
error.c
|
@ -1208,7 +1208,7 @@ void
|
|||
rb_error_frozen(what)
|
||||
const char *what;
|
||||
{
|
||||
rb_raise(rb_eTypeError, "can't modify frozen %s", what);
|
||||
rb_raise(rb_eRuntimeError, "can't modify frozen %s", what);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
22
eval.c
22
eval.c
|
@ -2651,7 +2651,7 @@ rb_eval(self, n)
|
|||
if (!node) RETURN(Qnil);
|
||||
|
||||
ruby_current_node = node;
|
||||
if (trace_func && FL_TEST(node, NODE_NEWLINE)) {
|
||||
if (trace_func && (node->flags & NODE_NEWLINE)) {
|
||||
call_trace_func("line", node, self,
|
||||
ruby_frame->last_func,
|
||||
ruby_frame->last_class);
|
||||
|
@ -4513,6 +4513,7 @@ proc_jump_error(state, result)
|
|||
localjump_error(mesg, result, state);
|
||||
}
|
||||
|
||||
NORETURN(static void return_jump(VALUE));
|
||||
static void
|
||||
return_jump(retval)
|
||||
VALUE retval;
|
||||
|
@ -4526,14 +4527,15 @@ return_jump(retval)
|
|||
yield = Qtrue;
|
||||
tt = tt->prev;
|
||||
}
|
||||
if (tt->tag == PROT_FUNC && tt->frame->uniq == ruby_frame->uniq) {
|
||||
tt->dst = (VALUE)ruby_frame->uniq;
|
||||
tt->retval = retval;
|
||||
JUMP_TAG(TAG_RETURN);
|
||||
}
|
||||
if (tt->tag == PROT_LAMBDA && !yield) {
|
||||
if ((tt->tag == PROT_FUNC && tt->frame->uniq == ruby_frame->uniq) ||
|
||||
(tt->tag == PROT_LAMBDA && !yield))
|
||||
{
|
||||
tt->dst = (VALUE)tt->frame->uniq;
|
||||
tt->retval = retval;
|
||||
if (trace_func) {
|
||||
struct FRAME *f = tt->frame;
|
||||
call_trace_func("return", f->node, f->self, f->last_func, f->last_class);
|
||||
}
|
||||
JUMP_TAG(TAG_RETURN);
|
||||
}
|
||||
if (tt->tag == PROT_THREAD) {
|
||||
|
@ -5650,6 +5652,9 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
|||
call_trace_func("call", b2, recv, id, klass);
|
||||
}
|
||||
result = rb_eval(recv, body);
|
||||
if (trace_func) {
|
||||
call_trace_func("return", body, recv, id, klass);
|
||||
}
|
||||
}
|
||||
else if (state == TAG_RETURN && TAG_DST()) {
|
||||
result = prot_tag->retval;
|
||||
|
@ -5660,9 +5665,6 @@ rb_call0(klass, recv, id, oid, argc, argv, body, nosuper)
|
|||
POP_CLASS();
|
||||
POP_SCOPE();
|
||||
ruby_cref = saved_cref;
|
||||
if (trace_func) {
|
||||
call_trace_func("return", ruby_frame->prev->node, recv, id, klass);
|
||||
}
|
||||
switch (state) {
|
||||
case 0:
|
||||
break;
|
||||
|
|
13
node.h
13
node.h
|
@ -156,21 +156,22 @@ typedef struct RNode {
|
|||
|
||||
#define RNODE(obj) (R_CAST(RNode)(obj))
|
||||
|
||||
#define NODE_TYPESHIFT 7
|
||||
#define NODE_TYPEMASK (0xff<<NODE_TYPESHIFT)
|
||||
/* 0..4:T_TYPES, 5:FL_MARK, 6:reserved, 7:NODE_NEWLINE */
|
||||
#define NODE_NEWLINE (1<<7)
|
||||
|
||||
#define nd_type(n) ((int)(((RNODE(n))->flags>>NODE_TYPESHIFT)&0x7f))
|
||||
#define NODE_TYPESHIFT 8
|
||||
#define NODE_TYPEMASK (0x7f<<NODE_TYPESHIFT)
|
||||
|
||||
#define nd_type(n) ((int) (((RNODE(n))->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
|
||||
#define nd_set_type(n,t) \
|
||||
RNODE(n)->flags=((RNODE(n)->flags&~NODE_TYPEMASK)|(((t)<<NODE_TYPESHIFT)&NODE_TYPEMASK))
|
||||
|
||||
#define NODE_LSHIFT (NODE_TYPESHIFT+8)
|
||||
#define NODE_LSHIFT (NODE_TYPESHIFT+7)
|
||||
#define NODE_LMASK (((long)1<<(sizeof(NODE*)*CHAR_BIT-NODE_LSHIFT))-1)
|
||||
#define nd_line(n) ((unsigned int)(((RNODE(n))->flags>>NODE_LSHIFT)&NODE_LMASK))
|
||||
#define nd_set_line(n,l) \
|
||||
RNODE(n)->flags=((RNODE(n)->flags&~(-1<<NODE_LSHIFT))|(((l)&NODE_LMASK)<<NODE_LSHIFT))
|
||||
|
||||
#define NODE_NEWLINE FL_USER7
|
||||
|
||||
#define nd_head u1.node
|
||||
#define nd_alen u2.argc
|
||||
#define nd_next u3.node
|
||||
|
|
|
@ -716,6 +716,7 @@ flo_divmod(x, y)
|
|||
VALUE x, y;
|
||||
{
|
||||
double fy, div, mod;
|
||||
volatile VALUE a, b;
|
||||
|
||||
switch (TYPE(y)) {
|
||||
case T_FIXNUM:
|
||||
|
@ -731,9 +732,9 @@ flo_divmod(x, y)
|
|||
return rb_num_coerce_bin(x, y);
|
||||
}
|
||||
flodivmod(RFLOAT(x)->value, fy, &div, &mod);
|
||||
x = rb_float_new(div);
|
||||
y = rb_float_new(mod);
|
||||
return rb_assoc_new(x, y);
|
||||
a = rb_float_new(div);
|
||||
b = rb_float_new(mod);
|
||||
return rb_assoc_new(a, b);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
6
parse.y
6
parse.y
|
@ -3599,7 +3599,7 @@ string_content : tSTRING_CONTENT
|
|||
COND_LEXPOP();
|
||||
CMDARG_LEXPOP();
|
||||
/*%%%*/
|
||||
FL_UNSET($3, NODE_NEWLINE);
|
||||
$3->flags &= ~NODE_NEWLINE;
|
||||
$$ = new_evstr($3);
|
||||
/*%
|
||||
$$ = dispatch1(string_embexpr, $3);
|
||||
|
@ -6507,7 +6507,9 @@ static NODE*
|
|||
newline_node(node)
|
||||
NODE *node;
|
||||
{
|
||||
FL_SET(node, NODE_NEWLINE);
|
||||
if (node) {
|
||||
node->flags |= NODE_NEWLINE;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
2
re.c
2
re.c
|
@ -1760,7 +1760,7 @@ rb_reg_initialize_m(argc, argv, self)
|
|||
s = StringValuePtr(argv[0]);
|
||||
len = RSTRING(argv[0])->len;
|
||||
}
|
||||
rb_reg_initialize(self, s, len, flags, Qtrue);
|
||||
rb_reg_initialize(self, s, len, flags, Qfalse);
|
||||
return self;
|
||||
}
|
||||
|
||||
|
|
3
ruby.h
3
ruby.h
|
@ -425,7 +425,8 @@ struct RBignum {
|
|||
#define RFILE(obj) (R_CAST(RFile)(obj))
|
||||
|
||||
#define FL_SINGLETON FL_USER0
|
||||
#define FL_MARK (1<<6)
|
||||
#define FL_MARK (1<<5)
|
||||
#define FL_RESERVED (1<<6) /* will be used in the future GC */
|
||||
#define FL_FINALIZE (1<<7)
|
||||
#define FL_TAINT (1<<8)
|
||||
#define FL_EXIVAR (1<<9)
|
||||
|
|
13
string.c
13
string.c
|
@ -788,8 +788,8 @@ VALUE
|
|||
rb_str_append(str, str2)
|
||||
VALUE str, str2;
|
||||
{
|
||||
rb_str_modify(str);
|
||||
StringValue(str2);
|
||||
rb_str_modify(str);
|
||||
if (RSTRING(str2)->len > 0) {
|
||||
if (FL_TEST(str, STR_ASSOC)) {
|
||||
long len = RSTRING(str)->len+RSTRING(str2)->len;
|
||||
|
@ -1643,6 +1643,7 @@ rb_str_splice(str, beg, len, val)
|
|||
}
|
||||
|
||||
StringValue(val);
|
||||
rb_str_modify(str);
|
||||
if (len < RSTRING(val)->len) {
|
||||
/* expand string */
|
||||
RESIZE_CAPA(str, RSTRING(str)->len + RSTRING(val)->len - len + 1);
|
||||
|
@ -1672,7 +1673,6 @@ rb_str_update(str, beg, len, val)
|
|||
long beg, len;
|
||||
VALUE val;
|
||||
{
|
||||
rb_str_modify(str);
|
||||
rb_str_splice(str, beg, len, val);
|
||||
}
|
||||
|
||||
|
@ -1706,7 +1706,6 @@ rb_str_subpat_set(str, re, nth, val)
|
|||
}
|
||||
end = RMATCH(match)->END(nth);
|
||||
len = end - start;
|
||||
rb_str_modify(str);
|
||||
rb_str_splice(str, start, len, val);
|
||||
}
|
||||
|
||||
|
@ -1731,6 +1730,7 @@ rb_str_aset(str, indx, val)
|
|||
idx += RSTRING(str)->len;
|
||||
}
|
||||
if (FIXNUM_P(val)) {
|
||||
rb_str_modify(str);
|
||||
if (RSTRING(str)->len == idx) {
|
||||
RSTRING(str)->len += 1;
|
||||
RESIZE_CAPA(str, RSTRING(str)->len);
|
||||
|
@ -1799,7 +1799,6 @@ rb_str_aset_m(argc, argv, str)
|
|||
VALUE *argv;
|
||||
VALUE str;
|
||||
{
|
||||
rb_str_modify(str);
|
||||
if (argc == 3) {
|
||||
if (TYPE(argv[0]) == T_REGEXP) {
|
||||
rb_str_subpat_set(str, argv[0], NUM2INT(argv[1]), argv[2]);
|
||||
|
@ -1838,7 +1837,6 @@ rb_str_insert(str, idx, str2)
|
|||
{
|
||||
long pos = NUM2LONG(idx);
|
||||
|
||||
rb_str_modify(str);
|
||||
if (pos == -1) {
|
||||
pos = RSTRING(str)->len;
|
||||
}
|
||||
|
@ -2092,7 +2090,7 @@ str_gsub(argc, argv, str, bang)
|
|||
rb_match_busy(match);
|
||||
val = rb_obj_as_string(rb_yield(rb_reg_nth_match(0, match)));
|
||||
str_mod_check(str, sp, slen);
|
||||
str_frozen_check(str);
|
||||
if (bang) str_frozen_check(str);
|
||||
if (val == dest) { /* paranoid chack [ruby-dev:24827] */
|
||||
rb_raise(rb_eRuntimeError, "block should not cheat");
|
||||
}
|
||||
|
@ -3897,8 +3895,8 @@ rb_str_chomp_bang(argc, argv, str)
|
|||
rs = rb_rs;
|
||||
if (rs == rb_default_rs) {
|
||||
smart_chomp:
|
||||
rb_str_modify(str);
|
||||
if (RSTRING(str)->ptr[len-1] == '\n') {
|
||||
rb_str_modify(str);
|
||||
RSTRING(str)->len--;
|
||||
if (RSTRING(str)->len > 0 &&
|
||||
RSTRING(str)->ptr[RSTRING(str)->len-1] == '\r') {
|
||||
|
@ -3906,7 +3904,6 @@ rb_str_chomp_bang(argc, argv, str)
|
|||
}
|
||||
}
|
||||
else if (RSTRING(str)->ptr[len-1] == '\r') {
|
||||
rb_str_modify(str);
|
||||
RSTRING(str)->len--;
|
||||
}
|
||||
else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче