зеркало из https://github.com/github/ruby.git
* bignum.c (rb_big_and): protect parameters from GC.
[ruby-talk:110664] * error.c (exc_equal): exceptions are equal if they share same class, message and backtrace. [ruby-talk:110354] * error.c (name_err_mesg_equal): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
55bf54a9c0
Коммит
88ba175ab0
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,8 @@
|
|||
Sat Aug 28 23:04:41 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* bignum.c (rb_big_and): protect parameters from GC.
|
||||
[ruby-talk:110664]
|
||||
|
||||
Fri Aug 27 12:13:50 2004 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* ext/stringio/stringio.c (Init_stringio): add StringIO#readpartial as
|
||||
|
@ -18,6 +23,13 @@ Wed Aug 25 15:18:52 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|||
|
||||
* eval.c (rb_longjmp): Exception#to_str is no longer defined.
|
||||
|
||||
Wed Aug 25 11:39:10 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* error.c (exc_equal): exceptions are equal if they share same
|
||||
class, message and backtrace. [ruby-talk:110354]
|
||||
|
||||
* error.c (name_err_mesg_equal): ditto.
|
||||
|
||||
Tue Aug 24 16:41:48 2004 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* lib/cgi/session.rb (CGI::Session::FileStore#initialize): do not
|
||||
|
|
18
bignum.c
18
bignum.c
|
@ -1638,15 +1638,16 @@ rb_big_pow(x, y)
|
|||
*/
|
||||
|
||||
VALUE
|
||||
rb_big_and(x, y)
|
||||
VALUE x, y;
|
||||
rb_big_and(xx, yy)
|
||||
VALUE xx, yy;
|
||||
{
|
||||
VALUE z;
|
||||
volatile VALUE x, y, z;
|
||||
BDIGIT *ds1, *ds2, *zds;
|
||||
long i, l1, l2;
|
||||
char sign;
|
||||
|
||||
y = rb_to_int(y);
|
||||
x = xx;
|
||||
y = rb_to_int(yy);
|
||||
if (FIXNUM_P(y)) {
|
||||
y = rb_int2big(FIX2LONG(y));
|
||||
}
|
||||
|
@ -1693,15 +1694,16 @@ rb_big_and(x, y)
|
|||
*/
|
||||
|
||||
VALUE
|
||||
rb_big_or(x, y)
|
||||
VALUE x, y;
|
||||
rb_big_or(xx, yy)
|
||||
VALUE xx, yy;
|
||||
{
|
||||
VALUE z;
|
||||
volatile VALUE x, y, z;
|
||||
BDIGIT *ds1, *ds2, *zds;
|
||||
long i, l1, l2;
|
||||
char sign;
|
||||
|
||||
y = rb_to_int(y);
|
||||
x = xx;
|
||||
y = rb_to_int(yy);
|
||||
if (FIXNUM_P(y)) {
|
||||
y = rb_int2big(FIX2LONG(y));
|
||||
}
|
||||
|
|
52
error.c
52
error.c
|
@ -534,6 +534,32 @@ exc_set_backtrace(exc, bt)
|
|||
return rb_iv_set(exc, "bt", check_backtrace(bt));
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* exc == obj => true or false
|
||||
*
|
||||
* Equality---If <i>obj</i> is not an <code>Exception</code>, returns
|
||||
* <code>false</code>. Otherwise, returns <code>true</code> if <i>exc</i> and
|
||||
* <i>obj</i> share same class, messages, and backtrace.
|
||||
*/
|
||||
|
||||
static VALUE
|
||||
exc_equal(exc, obj)
|
||||
VALUE exc;
|
||||
VALUE obj;
|
||||
{
|
||||
ID id_mesg = rb_intern("mesg");
|
||||
|
||||
if (exc == obj) return Qtrue;
|
||||
if (rb_obj_class(exc) != rb_obj_class(obj))
|
||||
return Qfalse;
|
||||
if (!rb_equal(rb_attr_get(exc, id_mesg), rb_attr_get(obj, id_mesg)))
|
||||
return Qfalse;
|
||||
if (!rb_equal(exc_backtrace(exc), exc_backtrace(obj)))
|
||||
return Qfalse;
|
||||
return Qtrue;
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
* SystemExit.new(status=0) => system_exit
|
||||
|
@ -662,7 +688,8 @@ static VALUE
|
|||
name_err_to_s(exc)
|
||||
VALUE exc;
|
||||
{
|
||||
VALUE mesg = rb_attr_get(exc, rb_intern("mesg")), str = mesg;
|
||||
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
|
||||
VALUE str = mesg;
|
||||
|
||||
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
|
||||
StringValue(str);
|
||||
|
@ -716,6 +743,27 @@ name_err_mesg_new(obj, mesg, recv, method)
|
|||
return Data_Wrap_Struct(rb_cNameErrorMesg, name_err_mesg_mark, -1, ptr);
|
||||
}
|
||||
|
||||
/* :nodoc: */
|
||||
static VALUE
|
||||
name_err_mesg_equal(obj1, obj2)
|
||||
VALUE obj1, obj2;
|
||||
{
|
||||
VALUE *ptr1, *ptr2;
|
||||
int i;
|
||||
|
||||
if (obj1 == obj2) return Qtrue;
|
||||
if (rb_obj_class(obj2) != rb_cNameErrorMesg)
|
||||
return Qfalse;
|
||||
|
||||
Data_Get_Struct(obj1, VALUE, ptr1);
|
||||
Data_Get_Struct(obj2, VALUE, ptr2);
|
||||
for (i=0; i<3; i++) {
|
||||
if (!rb_equal(ptr1[i], ptr2[i]))
|
||||
return Qfalse;
|
||||
}
|
||||
return Qtrue;
|
||||
}
|
||||
|
||||
/* :nodoc: */
|
||||
static VALUE
|
||||
name_err_mesg_to_str(obj)
|
||||
|
@ -984,6 +1032,7 @@ Init_Exception()
|
|||
rb_define_singleton_method(rb_eException, "exception", rb_class_new_instance, -1);
|
||||
rb_define_method(rb_eException, "exception", exc_exception, -1);
|
||||
rb_define_method(rb_eException, "initialize", exc_initialize, -1);
|
||||
rb_define_method(rb_eException, "==", exc_equal, 1);
|
||||
rb_define_method(rb_eException, "to_s", exc_to_s, 0);
|
||||
rb_define_method(rb_eException, "message", exc_message, 0);
|
||||
rb_define_method(rb_eException, "inspect", exc_inspect, 0);
|
||||
|
@ -1010,6 +1059,7 @@ Init_Exception()
|
|||
rb_define_method(rb_eNameError, "to_s", name_err_to_s, 0);
|
||||
rb_cNameErrorMesg = rb_define_class_under(rb_eNameError, "message", rb_cData);
|
||||
rb_define_singleton_method(rb_cNameErrorMesg, "!", name_err_mesg_new, 3);
|
||||
rb_define_method(rb_cNameErrorMesg, "==", name_err_mesg_equal, 1);
|
||||
rb_define_method(rb_cNameErrorMesg, "to_str", name_err_mesg_to_str, 0);
|
||||
rb_define_method(rb_cNameErrorMesg, "_dump", name_err_mesg_to_str, 1);
|
||||
rb_define_singleton_method(rb_cNameErrorMesg, "_load", name_err_mesg_load, 1);
|
||||
|
|
5
eval.c
5
eval.c
|
@ -3765,6 +3765,9 @@ rb_eval(self, n)
|
|||
ID cname;
|
||||
int gen = Qfalse;
|
||||
|
||||
cbase = class_prefix(self, node->nd_cpath);
|
||||
cname = node->nd_cpath->nd_mid;
|
||||
|
||||
if (NIL_P(ruby_cbase)) {
|
||||
rb_raise(rb_eTypeError, "no outer class/module");
|
||||
}
|
||||
|
@ -3775,8 +3778,6 @@ rb_eval(self, n)
|
|||
super = 0;
|
||||
}
|
||||
|
||||
cbase = class_prefix(self, node->nd_cpath);
|
||||
cname = node->nd_cpath->nd_mid;
|
||||
if (rb_const_defined_at(cbase, cname)) {
|
||||
klass = rb_const_get_at(cbase, cname);
|
||||
if (TYPE(klass) != T_CLASS) {
|
||||
|
|
3
io.c
3
io.c
|
@ -254,9 +254,6 @@ rb_io_check_writable(fptr)
|
|||
if (!(fptr->mode & FMODE_WRITABLE)) {
|
||||
rb_raise(rb_eIOError, "not opened for writing");
|
||||
}
|
||||
if ((fptr->mode & FMODE_RBUF) && READ_DATA_BUFFERED(fptr->f)) {
|
||||
rb_warn("read buffer data lost");
|
||||
}
|
||||
#if NEED_IO_SEEK_BETWEEN_RW
|
||||
if ((fptr->mode & FMODE_RBUF) && !feof(fptr->f) && !fptr->f2) {
|
||||
io_seek(fptr, 0, SEEK_CUR);
|
||||
|
|
|
@ -173,7 +173,9 @@ class CGI
|
|||
def Session::create_new_id
|
||||
require 'digest/md5'
|
||||
md5 = Digest::MD5::new
|
||||
md5.update(String(Time::now))
|
||||
now = Time::now
|
||||
md5.update(now.to_s)
|
||||
md5.update(String(now.usec))
|
||||
md5.update(String(rand(0)))
|
||||
md5.update(String($$))
|
||||
md5.update('foobar')
|
||||
|
|
2
parse.y
2
parse.y
|
@ -3398,7 +3398,7 @@ arg_ambiguous()
|
|||
}
|
||||
|
||||
#define IS_ARG() (lex_state == EXPR_ARG || lex_state == EXPR_CMDARG)
|
||||
#define IS_BEG() (lex_state == EXPR_BEG || lex_state == EXPR_MID || lex_state == EXPR_TERNARY)
|
||||
#define IS_BEG() (lex_state == EXPR_BEG || lex_state == EXPR_MID || lex_state == EXPR_TERNARY || lex_state == EXPR_CLASS)
|
||||
|
||||
static int
|
||||
yylex()
|
||||
|
|
Загрузка…
Ссылка в новой задаче