1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2000-10-16 09:13:20 +00:00
parent 525836d683
commit 8353f303e3
9 changed files with 91 additions and 59 deletions

View file

@ -1,7 +1,32 @@
Mon Oct 16 15:37:33 2000 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* eval.c (rb_thread_inspect): tag size was shorter than required.
* object.c (rb_obj_inspect): ditto.
Mon Oct 16 14:25:18 2000 Shugo Maeda <shugo@ruby-lang.org>
* object.c (sym_inspect): used `name' before initialization.
Mon Oct 16 14:06:00 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* pack.c (pack_pack): use NATINT_U32 for 'l', 'L', and 'N'.
* pack.c (I32,U32): 32 bit sized integer.
* pack.c (OFF16,OFF32B): big endien offset for network byteorder.
Mon Oct 16 06:39:32 2000 Minero Aoki <aamine@dp.u-netsurf.ne.jp>
* lib/net/http.rb: hex-alpha is not [a-h] but [a-f].
Mon Oct 16 01:02:02 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_thread_start_0): should not abort on exception if
$SAFE >= 4.
* parse.y (sym): symbols for class variable names.
Sat Oct 14 03:32:13 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_thread_alloc): should not link a new thread in the

View file

@ -129,6 +129,7 @@ lib/monitor.rb
lib/mutex_m.rb
lib/net/ftp.rb
lib/net/http.rb
lib/net/imap.rb
lib/net/pop.rb
lib/net/protocol.rb
lib/net/smtp.rb

65
eval.c
View file

@ -637,7 +637,6 @@ rb_dvar_ref(id)
struct RVarmap *vars = ruby_dyna_vars;
while (vars) {
if (TYPE(vars) != T_VARMAP) abort();
if (vars->id == id) {
return vars->val;
}
@ -728,7 +727,6 @@ struct tag {
struct SCOPE *scope;
int dst;
struct tag *prev;
int line;
};
static struct tag *prot_tag;
@ -742,7 +740,6 @@ static struct tag *prot_tag;
_tag.scope = ruby_scope; \
_tag.tag = ptag; \
_tag.dst = 0; \
_tag.line = __LINE__; \
prot_tag = &_tag;
#define PROT_NONE 0
@ -804,8 +801,7 @@ static void scope_dup _((struct SCOPE *));
#define POP_SCOPE() \
if (ruby_scope->flag & SCOPE_DONT_RECYCLE) {\
if (_old)\
scope_dup(_old);\
if (_old) scope_dup(_old); \
} \
if (!(ruby_scope->flag & SCOPE_MALLOC)) {\
ruby_scope->local_vars = 0; \
@ -3495,8 +3491,9 @@ rb_yield_0(val, self, klass, acheck)
struct RVarmap *vars = ruby_dyna_vars;
while (vars && vars->id != 0) {
struct RVarmap *tmp = vars->next;
rb_gc_force_recycle((VALUE)vars);
vars = vars->next;
vars = tmp;
}
if (ruby_dyna_vars && ruby_dyna_vars->id == 0) {
rb_gc_force_recycle((VALUE)ruby_dyna_vars);
@ -7621,19 +7618,15 @@ static VALUE
rb_thread_abort_exc(thread)
VALUE thread;
{
rb_thread_t th = rb_thread_check(thread);
return th->abort?Qtrue:Qfalse;
return rb_thread_check(thread)->abort?Qtrue:Qfalse;
}
static VALUE
rb_thread_abort_exc_set(thread, val)
VALUE thread, val;
{
rb_thread_t th = rb_thread_check(thread);
rb_secure(4);
th->abort = RTEST(val);
rb_thread_check(thread)->abort = RTEST(val);
return val;
}
@ -7686,18 +7679,6 @@ rb_thread_alloc(klass)
THREAD_ALLOC(th);
th->thread = Data_Wrap_Struct(klass, thread_mark, thread_free, th);
if (curr_thread) {
th->prev = curr_thread;
curr_thread->next->prev = th;
th->next = curr_thread->next;
curr_thread->next = th;
th->priority = curr_thread->priority;
th->gid = curr_thread->gid;
}
else {
curr_thread = th->prev = th->next = th;
}
for (vars = th->dyna_vars; vars; vars = vars->next) {
if (FL_TEST(vars, DVAR_DONT_RECYCLE)) break;
FL_SET(vars, DVAR_DONT_RECYCLE);
@ -7789,9 +7770,19 @@ rb_thread_start_0(fn, arg, th_arg)
return thread;
}
if (!th->next) {
/* merge in thread list */
th->prev = curr_thread;
curr_thread->next->prev = th;
th->next = curr_thread->next;
curr_thread->next = th;
th->priority = curr_thread->priority;
th->gid = curr_thread->gid;
}
PUSH_TAG(PROT_THREAD);
if ((state = EXEC_TAG()) == 0) {
if ((status = THREAD_SAVE_CONTEXT(th)) == 0) {
if (THREAD_SAVE_CONTEXT(th) == 0) {
curr_thread = th;
th->result = (*fn)(arg, th);
}
@ -7807,14 +7798,15 @@ rb_thread_start_0(fn, arg, th_arg)
rb_thread_cleanup();
}
else if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
if (ruby_safe_level >= 4) {
if (th->safe >= 4) {
rb_raise(rb_eSecurityError, "Insecure exit at level %d",
ruby_safe_level);
}
/* delegate exception to main_thread */
rb_thread_raise(1, &ruby_errinfo, main_thread);
}
else if (thread_abort || th->abort || RTEST(ruby_debug)) {
else if (th->safe < 4 &&
(thread_abort || th->abort || RTEST(ruby_debug))) {
VALUE err = rb_exc_new(rb_eSystemExit, 0, 0);
error_print();
/* exit on main_thread */
@ -7833,8 +7825,7 @@ rb_thread_create(fn, arg)
VALUE (*fn)();
void *arg;
{
rb_thread_t th = rb_thread_alloc(rb_cThread);
return rb_thread_start_0(fn, arg, th);
return rb_thread_start_0(fn, arg, rb_thread_alloc(rb_cThread));
}
int
@ -7861,10 +7852,9 @@ rb_thread_s_new(argc, argv, klass)
rb_thread_t th = rb_thread_alloc(klass);
volatile VALUE *pos;
THREAD_SAVE_CONTEXT(th);
pos = th->stk_pos;
rb_obj_call_init(th->thread, argc, argv);
if (th->stk_pos == pos) {
if (th->stk_pos == 0) {
rb_raise(rb_eThreadError, "uninitialized thread - check `%s#initialize'",
rb_class2name(klass));
}
@ -7876,14 +7866,10 @@ static VALUE
rb_thread_initialize(thread, args)
VALUE thread, args;
{
rb_thread_t th;
th = rb_thread_check(thread);
if (!rb_block_given_p()) {
rb_thread_remove(th);
rb_raise(rb_eThreadError, "must be called with a block");
}
return rb_thread_start_0(rb_thread_yield, args, th);
return rb_thread_start_0(rb_thread_yield, args, rb_thread_check(thread));
}
static VALUE
@ -7891,12 +7877,11 @@ rb_thread_start(klass, args)
VALUE klass, args;
{
rb_thread_t th;
VALUE t;
if (!rb_block_given_p()) {
rb_raise(rb_eThreadError, "must be called with a block");
}
return rb_thread_start_0(rb_thread_yield, args, rb_thread_alloc(rb_cThread));
return rb_thread_start_0(rb_thread_yield, args, rb_thread_alloc(klass));
}
static VALUE
@ -8194,7 +8179,7 @@ rb_thread_inspect(thread)
default:
status = "unknown"; break;
}
str = rb_str_new(0, strlen(cname)+6+16+9+1); /* 6:tags 16:addr 9:status 1:nul */
str = rb_str_new(0, strlen(cname)+7+16+9+1); /* 7:tags 16:addr 9:status 1:nul */
sprintf(RSTRING(str)->ptr, "#<%s:0x%lx %s>", cname, thread, status);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
OBJ_INFECT(str, thread);
@ -8214,7 +8199,6 @@ rb_callcc(self)
struct RVarmap *vars;
THREAD_ALLOC(th);
th->status = THREAD_RUNNABLE;
cont = Data_Wrap_Struct(rb_cCont, thread_mark, thread_free, th);
scope_dup(ruby_scope);
@ -8374,6 +8358,7 @@ Init_Thread()
/* allocate main thread */
main_thread = rb_thread_alloc(rb_cThread);
curr_thread = main_thread->prev = main_thread->next = main_thread;
rb_cCont = rb_define_class("Continuation", rb_cObject);
rb_undef_method(CLASS_OF(rb_cCont), "new");

4
gc.c
View file

@ -905,7 +905,7 @@ rb_gc()
alloca(0);
# define STACK_END (&stack_end)
#else
# if defined(__GNUC__)
# if defined(__GNUC__) && !defined(__alpha__)
VALUE *stack_end = __builtin_frame_address(0);
# else
VALUE *stack_end = alloca(1);
@ -985,7 +985,7 @@ Init_stack(addr)
#if defined(__human68k__)
extern void *_SEND;
rb_gc_stack_start = _SEND;
#elif defined(__GNUC__)
#elif defined(__GNUC__) && !defined(__alpha__)
rb_gc_stack_start = __builtin_frame_address(2);
#else
VALUE start;

View file

@ -198,12 +198,12 @@ rb_obj_inspect(obj)
c = rb_class2name(CLASS_OF(obj));
if (rb_inspecting_p(obj)) {
str = rb_str_new(0, strlen(c)+8+16+1); /* 8:tags 16:addr 1:eos */
str = rb_str_new(0, strlen(c)+10+16+1); /* 10:tags 16:addr 1:eos */
sprintf(RSTRING(str)->ptr, "#<%s:0x%lx ...>", c, obj);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
return str;
}
str = rb_str_new(0, strlen(c)+4+16+1); /* 4:tags 16:addr 1:eos */
str = rb_str_new(0, strlen(c)+6+16+1); /* 6:tags 16:addr 1:eos */
sprintf(RSTRING(str)->ptr, "-<%s:0x%lx ", c, obj);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
return rb_protect_inspect(inspect_obj, obj, str);
@ -498,8 +498,8 @@ sym_inspect(sym)
VALUE str;
char *name;
str = rb_str_new(0, strlen(name)+2);
name = rb_id2name(SYM2ID(sym));
str = rb_str_new(0, strlen(name)+2);
sprintf(RSTRING(str)->ptr, ":%s", name);
RSTRING(str)->len = strlen(RSTRING(str)->ptr);
return str;

38
pack.c
View file

@ -22,16 +22,24 @@
#endif
#ifdef NATINT_PACK
# define OFF16B(p) ((char*)(p) + (natint?0:(sizeof(short) - SIZE16)))
# define OFF32B(p) ((char*)(p) + (natint?0:(sizeof(long) - SIZE32)))
# define NATINT_I32(x) (natint?sizeof(NUM2LONG(x)):(NUM2I32(x)))
# define NATINT_U32(x) (natint?sizeof(NUM2ULONG(x)):(NUM2U32(x)))
# define NATINT_LEN(type,len) (natint?sizeof(type):(len))
# ifdef WORDS_BIGENDIAN
# define OFF16(p) ((char*)(p) + (natint?0:(sizeof(short) - 2)))
# define OFF32(p) ((char*)(p) + (natint?0:(sizeof(long) - 4)))
# define OFF16(p) OFF16B(p)
# define OFF32(p) OFF32B(p)
# endif
#else
# define NATINT_I32(x) NUM2I32(x)
# define NATINT_U32(x) NUM2U32(x)
# define NATINT_LEN(type,len) sizeof(type)
#endif
#ifndef OFF16
# define OFF16B(p) (char*)(p)
# define OFF32B(p) (char*)(p)
# define OFF16(p) (char*)(p)
# define OFF32(p) (char*)(p)
#endif
@ -293,6 +301,18 @@ endian()
#define VTOHD(x,y) vtohd(x)
#endif
#if SIZEOF_LONG == SIZE32
typedef long I32;
typedef unsigned long U32;
#define NUM2I32(x) NUM2LONG(x)
#define NUM2U32(x) NUM2LONG(x)
#elif SIZEOF_INT == SIZE32
typedef int I32;
typedef unsigned int U32;
#define NUM2I32(x) NUM2INT(x)
#define NUM2U32(x) NUM2UINT(x)
#endif
static char *toofew = "too few arguments";
static void encodes _((VALUE,char*,int,int));
@ -569,7 +589,7 @@ pack_pack(ary, fmt)
from = NEXTFROM;
if (NIL_P(from)) l = 0;
else {
l = NUM2ULONG(from);
l = NATINT_U32(from);
}
rb_str_cat(res, OFF32(&l), NATINT_LEN(long,4));
}
@ -585,7 +605,7 @@ pack_pack(ary, fmt)
s = NUM2INT(from);
}
s = htons(s);
rb_str_cat(res, OFF16(&s), NATINT_LEN(short,2));
rb_str_cat(res, OFF16B(&s), NATINT_LEN(short,2));
}
break;
@ -596,10 +616,10 @@ pack_pack(ary, fmt)
from = NEXTFROM;
if (NIL_P(from)) l = 0;
else {
l = NUM2ULONG(from);
l = NATINT_U32(from);
}
l = htonl(l);
rb_str_cat(res, OFF32(&l), NATINT_LEN(long,4));
rb_str_cat(res, OFF32B(&l), NATINT_LEN(long,4));
}
break;
@ -624,7 +644,7 @@ pack_pack(ary, fmt)
from = NEXTFROM;
if (NIL_P(from)) l = 0;
else {
l = NUM2ULONG(from);
l = NATINT_U32(from);
}
l = htovl(l);
rb_str_cat(res, OFF32(&l), NATINT_LEN(long,4));
@ -1315,7 +1335,7 @@ pack_unpack(str, fmt)
PACK_LENGTH_ADJUST(unsigned short,2);
while (len-- > 0) {
unsigned short tmp = 0;
memcpy(OFF16(&tmp), s, NATINT_LEN(unsigned short,2));
memcpy(OFF16B(&tmp), s, NATINT_LEN(unsigned short,2));
s += NATINT_LEN(unsigned short,2);
rb_ary_push(ary, rb_uint2inum(ntohs(tmp)));
}
@ -1326,7 +1346,7 @@ pack_unpack(str, fmt)
PACK_LENGTH_ADJUST(unsigned long,4);
while (len-- > 0) {
unsigned long tmp = 0;
memcpy(OFF32(&tmp), s, NATINT_LEN(unsigned long,4));
memcpy(OFF32B(&tmp), s, NATINT_LEN(unsigned long,4));
s += NATINT_LEN(unsigned long,4);
rb_ary_push(ary, rb_uint2inum(ntohl(tmp)));
}

View file

@ -1349,6 +1349,7 @@ opt_block_var : none
$$ = $2;
}
do_block : kDO
{
$<vars>$ = dyna_push();
@ -1561,7 +1562,7 @@ symbol : tSYMBEG sym
sym : fname
| tIVAR
| tGVAR
| tCVAR
numeric : tINTEGER
| tFLOAT

4
ruby.h
View file

@ -194,8 +194,8 @@ int rb_num2int _((VALUE));
#define NUM2INT(x) (FIXNUM_P(x)?FIX2INT(x):rb_num2int((VALUE)x))
int rb_fix2int _((VALUE));
#define FIX2INT(x) rb_fix2int((VALUE)x)
#define NUM2UINT(x) ((unsigned int)NUM2ULONG(x))
#define FIX2UINT(x) ((unsigned int)FIX2ULONG(x))
#define NUM2UINT(x) ((unsigned int)NUM2INT(x))
#define FIX2UINT(x) ((unsigned int)FIX2INT(x))
#else
#define NUM2INT(x) NUM2LONG(x)
#define NUM2UINT(x) NUM2ULONG(x)

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.6.2"
#define RUBY_RELEASE_DATE "2000-10-12"
#define RUBY_RELEASE_DATE "2000-10-16"
#define RUBY_VERSION_CODE 162
#define RUBY_RELEASE_CODE 20001012
#define RUBY_RELEASE_CODE 20001016