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

* 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
This commit is contained in:
matz 2003-04-18 18:05:11 +00:00
parent 18cdaa6828
commit 6987b0806e
6 changed files with 61 additions and 17 deletions

View file

@ -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.

View file

@ -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);

20
range.c
View file

@ -18,15 +18,6 @@ static ID id_cmp, id_succ, id_beg, id_end, id_excl;
#define EXCL(r) RTEST(rb_ivar_get((r), id_excl))
#define SET_EXCL(r,v) rb_ivar_set((r), id_excl, (v) ? Qtrue : Qfalse)
static VALUE
range_check(args)
VALUE *args;
{
rb_funcall(args[0], id_cmp, 1, args[1]);
/* rb_funcall(args[0], id_succ, 0, 0); */
return Qnil;
}
static VALUE
range_failed()
{
@ -34,6 +25,17 @@ range_failed()
return Qnil; /* dummy */
}
static VALUE
range_check(args)
VALUE *args;
{
VALUE v;
v = rb_funcall(args[0], id_cmp, 1, args[1]);
if (NIL_P(v)) range_failed();
return Qnil;
}
static void
range_init(range, beg, end, exclude_end)
VALUE range, beg, end;

View file

@ -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) {

View file

@ -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";

View file

@ -592,6 +592,25 @@ rb_struct_hash(s)
return LONG2FIX(h);
}
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);