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

* string.c (rb_str_shared_replace): clear flags before copy.

* string.c (rb_str_replace): ditto.

* eval.c (rb_yield_0): override visibility mode for module_eval
  etc. (ruby-bugs-ja PR#505)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4028 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-07-02 04:27:29 +00:00
parent f261bdf66c
commit 447578a8a0
4 changed files with 26 additions and 11 deletions

View file

@ -1,3 +1,12 @@
Wed Jul 2 13:22:39 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
* string.c (rb_str_shared_replace): clear flags before copy.
* string.c (rb_str_replace): ditto.
* eval.c (rb_yield_0): override visibility mode for module_eval
etc. (ruby-bugs-ja PR#505)
Wed Jul 2 11:45:34 2003 Minero Aoki <aamine@loveruby.net>
* lib/net/smtp.rb: synchronize document with source code.

22
eval.c
View file

@ -950,6 +950,10 @@ static VALUE eval _((VALUE,VALUE,VALUE,char*,int));
static NODE *compile _((VALUE, char*, int));
static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int, int));
#define YIELD_PROC_CALL 1
#define YIELD_PUBLIC_DEF 2
static VALUE rb_call _((VALUE,VALUE,ID,int,const VALUE*,int));
static VALUE module_setup _((VALUE,NODE*));
@ -2780,7 +2784,7 @@ rb_eval(self, n)
result = Qundef; /* no arg */
}
SET_CURRENT_SOURCE();
result = rb_yield_0(result, 0, 0, Qfalse, node->nd_state);
result = rb_yield_0(result, 0, 0, 0, node->nd_state);
break;
case NODE_RESCUE:
@ -4010,9 +4014,9 @@ rb_f_block_given_p()
}
static VALUE
rb_yield_0(val, self, klass, pcall, avalue)
rb_yield_0(val, self, klass, flags, avalue)
VALUE val, self, klass; /* OK */
int pcall, avalue;
int flags, avalue;
{
NODE *node;
volatile VALUE result = Qnil;
@ -4043,7 +4047,7 @@ rb_yield_0(val, self, klass, pcall, avalue)
old_scope = ruby_scope;
ruby_scope = block->scope;
old_vmode = scope_vmode;
scope_vmode = block->vmode;
scope_vmode = (flags & YIELD_PUBLIC_DEF) ? SCOPE_PUBLIC : block->vmode;
ruby_block = block->prev;
if (block->flags & BLOCK_D_SCOPE) {
/* put place holder for dynamic (in-block) local variables */
@ -4061,7 +4065,7 @@ rb_yield_0(val, self, klass, pcall, avalue)
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
if (block->var == (NODE*)1) { /* no parameter || */
if (pcall && RARRAY(val)->len != 0) {
if ((flags & YIELD_PROC_CALL) && RARRAY(val)->len != 0) {
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 0)",
RARRAY(val)->len);
}
@ -4076,7 +4080,7 @@ rb_yield_0(val, self, klass, pcall, avalue)
if (!avalue) {
val = svalue_to_mrhs(val, block->var->nd_head);
}
massign(self, block->var, val, pcall);
massign(self, block->var, val, flags&YIELD_PROC_CALL);
}
else {
int len = 0;
@ -4100,7 +4104,7 @@ rb_yield_0(val, self, klass, pcall, avalue)
ruby_current_node = curr;
}
}
assign(self, block->var, val, pcall);
assign(self, block->var, val, flags&YIELD_PROC_CALL);
}
}
POP_TAG();
@ -5589,7 +5593,7 @@ static VALUE
yield_under_i(self)
VALUE self;
{
return rb_yield_0(self, self, ruby_class, Qfalse, Qfalse);
return rb_yield_0(self, self, ruby_class, YIELD_PUBLIC_DEF, Qfalse);
}
/* block eval under the class/module context */
@ -6954,7 +6958,7 @@ proc_invoke(proc, args, self, klass)
Data_Get_Struct(proc, struct BLOCK, data);
orphan = block_orphan(data);
pcall = data->flags & BLOCK_LAMBDA;
pcall = data->flags & BLOCK_LAMBDA ? YIELD_PROC_CALL : 0;
ruby_wrapper = data->wrapper;
ruby_dyna_vars = data->dyna_vars;

View file

@ -8,6 +8,7 @@ make=false
have_library("mytinfo", "tgetent") if /bow/ =~ RUBY_PLATFORM
if have_header("ncurses.h") and have_library("ncurses", "initscr")
make=true
elsif have_header("ncurses/curses.h") and have_library("ncurses", "initscr") and have_library("tinfo", "tgetent")
elsif have_header("ncurses/curses.h") and have_library("ncurses", "initscr")
make=true
elsif have_header("curses_colr/curses.h") and have_library("cur_colr", "initscr")

View file

@ -241,12 +241,12 @@ rb_str_shared_replace(str, str2)
}
RSTRING(str)->ptr = RSTRING(str2)->ptr;
RSTRING(str)->len = RSTRING(str2)->len;
FL_UNSET(str, ELTS_SHARED|STR_ASSOC);
if (FL_TEST(str2, ELTS_SHARED|STR_ASSOC)) {
FL_SET(str, RBASIC(str2)->flags & (ELTS_SHARED|STR_ASSOC));
RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
}
else {
FL_UNSET(str, ELTS_SHARED|STR_ASSOC);
RSTRING(str)->aux.capa = RSTRING(str2)->aux.capa;
}
RSTRING(str2)->ptr = 0; /* abandon str2 */
@ -559,7 +559,7 @@ rb_str_resize(str, len)
rb_str_modify(str);
if (RSTRING(str)->len < len || RSTRING(str)->len - len > 1024) {
REALLOC_N(RSTRING(str)->ptr, char, len+1);
if (!FL_TEST(str, STR_ASSOC)) {
if (!FL_TEST(str, STR_ASSOC|ELTS_SHARED)) {
RSTRING(str)->aux.capa = len;
}
}
@ -1705,6 +1705,7 @@ rb_str_replace(str, str2)
RSTRING(str)->len = RSTRING(str2)->len;
RSTRING(str)->ptr = RSTRING(str2)->ptr;
FL_SET(str, ELTS_SHARED);
FL_UNSET(str, STR_ASSOC);
RSTRING(str)->aux.shared = RSTRING(str2)->aux.shared;
}
else {