summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-04-18 18:05:11 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-04-18 18:05:11 +0000
commit6987b0806e970c7e4b19800c2a2effc290947b78 (patch)
tree79823d81475a9659b3c0e21988721c7d6b200d04
parent18cdaa6828045306da4aa95f3828f634a8c9d0ee (diff)
* struct.c (rb_struct_eql): should compare values with "eql?".
* range.c (range_check): <=> returns nil for invalid values; should check. * regex.c (re_compile_pattern): should not set RE_OPTIMIZE_ANCHOR, if anychar_repeat is enclosed by parentheses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog18
-rw-r--r--marshal.c8
-rw-r--r--range.c18
-rw-r--r--regex.c1
-rw-r--r--sample/test.rb10
-rw-r--r--struct.c21
6 files changed, 60 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index a903886..acfed87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,22 @@
+Sat Apr 19 00:56:13 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * struct.c (rb_struct_eql): should compare values with "eql?".
+
+Fri Apr 18 23:29:08 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * range.c (range_check): <=> returns nil for invalid values;
+ should check.
+
Fri Apr 18 15:26:50 2003 NAKAMURA Usaku <usa@ruby-lang.org>
* error.c (rb_raise): workaround for some implementations of
vsnprintf.
+Fri Apr 18 02:23:42 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * regex.c (re_compile_pattern): should not set RE_OPTIMIZE_ANCHOR,
+ if anychar_repeat is enclosed by parentheses.
+
Fri Apr 18 01:49:18 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* util.c (ruby_strtod): improved conversion accuracy.
@@ -51,13 +65,13 @@ Mon Apr 14 19:45:56 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
Mon Apr 14 03:22:33 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
- * rubyio.h (struct OpenFile): add error raise flag to finalizer.
+ * rubyio.h (struct OpenFile): add noraise flag to finalizer.
* io.c (Init_IO): define $/, $-0, and $\ as string-only
variables.
* string.c (rb_str_split_m): does not generate empty string if
- there's no match in the receiver.
+ the receiver is empty.
* io.c (fptr_finalize): should raise error on EBADF for readable
IOs as well.
diff --git a/marshal.c b/marshal.c
index 27d038a..265f454 100644
--- a/marshal.c
+++ b/marshal.c
@@ -1112,16 +1112,16 @@ r_object0(arg, proc)
case TYPE_MODULE_OLD:
{
- VALUE str = r_bytes(arg);
+ volatile VALUE str = r_bytes(arg);
- v = path2module(RSTRING(str)->ptr);
+ v = rb_path2class(RSTRING(str)->ptr);
r_regist(v, arg);
}
break;
case TYPE_CLASS:
{
- VALUE str = r_bytes(arg);
+ volatile VALUE str = r_bytes(arg);
v = path2class(RSTRING(str)->ptr);
r_regist(v, arg);
@@ -1130,7 +1130,7 @@ r_object0(arg, proc)
case TYPE_MODULE:
{
- VALUE str = r_bytes(arg);
+ volatile VALUE str = r_bytes(arg);
v = path2module(RSTRING(str)->ptr);
r_regist(v, arg);
diff --git a/range.c b/range.c
index 830228e..e0d17f4 100644
--- a/range.c
+++ b/range.c
@@ -19,19 +19,21 @@ static ID id_cmp, id_succ, id_beg, id_end, id_excl;
#define SET_EXCL(r,v) rb_ivar_set((r), id_excl, (v) ? Qtrue : Qfalse)
static VALUE
-range_check(args)
- VALUE *args;
+range_failed()
{
- rb_funcall(args[0], id_cmp, 1, args[1]);
- /* rb_funcall(args[0], id_succ, 0, 0); */
- return Qnil;
+ rb_raise(rb_eArgError, "bad value for range");
+ return Qnil; /* dummy */
}
static VALUE
-range_failed()
+range_check(args)
+ VALUE *args;
{
- rb_raise(rb_eArgError, "bad value for range");
- return Qnil; /* dummy */
+ VALUE v;
+
+ v = rb_funcall(args[0], id_cmp, 1, args[1]);
+ if (NIL_P(v)) range_failed();
+ return Qnil;
}
static void
diff --git a/regex.c b/regex.c
index 2e51365..698f3c7 100644
--- a/regex.c
+++ b/regex.c
@@ -2397,7 +2397,6 @@ re_compile_pattern(pattern, size, bufp)
/* set optimize flags */
laststart = bufp->buffer;
if (laststart != b) {
- if (*laststart == start_memory) laststart += 3;
if (*laststart == dummy_failure_jump) laststart += 3;
else if (*laststart == try_next) laststart += 3;
if (*laststart == anychar_repeat) {
diff --git a/sample/test.rb b/sample/test.rb
index 0abf999..ebed593 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -995,6 +995,9 @@ nan.test(-0.001);
nan.test(1.0/0);
nan.test(-1.0/0);
+s = "3.7517675036461267e+17"
+test_ok(s == sprintf("%.16e", s.to_f))
+
test_check "bignum"
def fact(n)
return 1 if n == 0
@@ -1550,6 +1553,13 @@ test_ok($x == Marshal.load($y))
StrClone=String.clone;
test_ok(Marshal.load(Marshal.dump(StrClone.new("abc"))).class == StrClone)
+[[1,2,3,4], [81, 2, 118, 3146]].each { |w,x,y,z|
+ a = (x.to_f + y.to_f / z.to_f) * Math.exp(w.to_f / (x.to_f + y.to_f / z.to_f))
+ ma = Marshal.dump(a)
+ b = Marshal.load(ma)
+ test_ok(a == b)
+}
+
test_check "pack"
$format = "c2x5CCxsdils_l_a6";
diff --git a/struct.c b/struct.c
index d695b15..b1fa31f 100644
--- a/struct.c
+++ b/struct.c
@@ -593,6 +593,25 @@ rb_struct_hash(s)
}
static VALUE
+rb_struct_eql(s, s2)
+ VALUE s, s2;
+{
+ long i;
+
+ if (s == s2) return Qtrue;
+ if (TYPE(s2) != T_STRUCT) return Qfalse;
+ if (rb_obj_class(s) != rb_obj_class(s2)) return Qfalse;
+ if (RSTRUCT(s)->len != RSTRUCT(s2)->len) {
+ rb_bug("inconsistent struct"); /* should never happen */
+ }
+
+ for (i=0; i<RSTRUCT(s)->len; i++) {
+ if (!rb_eql(RSTRUCT(s)->ptr[i], RSTRUCT(s2)->ptr[i])) return Qfalse;
+ }
+ return Qtrue;
+}
+
+static VALUE
rb_struct_size(s)
VALUE s;
{
@@ -612,7 +631,7 @@ Init_Struct()
rb_define_method(rb_cStruct, "copy_object", rb_struct_copy_object, 1);
rb_define_method(rb_cStruct, "==", rb_struct_equal, 1);
- rb_define_method(rb_cStruct, "eql?", rb_struct_equal, 1);
+ rb_define_method(rb_cStruct, "eql?", rb_struct_eql, 1);
rb_define_method(rb_cStruct, "hash", rb_struct_hash, 0);
rb_define_method(rb_cStruct, "to_s", rb_struct_to_s, 0);