aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--bignum.c18
-rw-r--r--error.c52
-rw-r--r--eval.c5
-rw-r--r--io.c3
-rw-r--r--lib/cgi/session.rb4
-rw-r--r--parse.y2
7 files changed, 80 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index f5cfbadb06..f72dcdb1f6 100644
--- a/ChangeLog
+++ b/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
diff --git a/bignum.c b/bignum.c
index 510860c03c..5f008544c0 100644
--- a/bignum.c
+++ b/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));
}
diff --git a/error.c b/error.c
index e060ea0461..2178aa0dd4 100644
--- a/error.c
+++ b/error.c
@@ -535,6 +535,32 @@ exc_set_backtrace(exc, 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);
@@ -718,6 +745,27 @@ name_err_mesg_new(obj, mesg, recv, method)
/* :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)
VALUE 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);
diff --git a/eval.c b/eval.c
index 19e6a361c3..3829be617f 100644
--- a/eval.c
+++ b/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) {
diff --git a/io.c b/io.c
index 45056040bb..2c71a6d929 100644
--- a/io.c
+++ b/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);
diff --git a/lib/cgi/session.rb b/lib/cgi/session.rb
index c320ac9c47..9a49fdedc9 100644
--- a/lib/cgi/session.rb
+++ b/lib/cgi/session.rb
@@ -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')
diff --git a/parse.y b/parse.y
index adfd7eeed1..742107e0e5 100644
--- a/parse.y
+++ b/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()