diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | array.c | 2 | ||||
-rw-r--r-- | lib/rational.rb | 24 | ||||
-rw-r--r-- | lib/tempfile.rb | 2 | ||||
-rw-r--r-- | string.c | 7 |
5 files changed, 30 insertions, 16 deletions
@@ -1,3 +1,8 @@ +Tue Nov 16 01:41:31 2004 Yukihiro Matsumoto <[email protected]> + + * array.c (rb_ary_update): pedantic check to detect + rb_ary_to_ary() to modify the receiver. [ruby-dev:24861] + Mon Nov 15 18:58:05 2004 Tanaka Akira <[email protected]> * configure.in: check rlim_t more portably. [ruby-core:3735] @@ -473,6 +478,12 @@ Fri Oct 29 10:00:30 2004 Yukihiro Matsumoto <[email protected]> * eval.c (ruby_cleanup): ruby_finalize_1 may cause exception, should be wrapped by PUSH_TAG/POP_TAG(). [ruby-dev:24627] +Thu Oct 28 08:42:02 2004 Tanaka Akira <[email protected]> + + * io.c (argf_forward): use ANSI style. + (argf_read): call argf_forward with argv argument. + [ruby-dev:24624] + Wed Oct 27 09:17:30 2004 Nobuyoshi Nakada <[email protected]> * string.c (str_gsub): use a string object for exception safeness. @@ -1090,7 +1090,6 @@ rb_ary_update(ary, beg, len, rpl) len = RARRAY(ary)->len - beg; } - rb_ary_modify(ary); if (rpl == Qundef) { rlen = 0; } @@ -1098,6 +1097,7 @@ rb_ary_update(ary, beg, len, rpl) rpl = rb_ary_to_ary(rpl); rlen = RARRAY(rpl)->len; } + rb_ary_modify(ary); if (beg >= RARRAY(ary)->len) { len = beg + rlen; diff --git a/lib/rational.rb b/lib/rational.rb index 2019363ac6..2241004852 100644 --- a/lib/rational.rb +++ b/lib/rational.rb @@ -312,20 +312,22 @@ class Integer return a end - def lcm(int) - a = self.abs - b = int.abs - gcd = a.gcd(b) - (a.div(gcd)) * b + def lcm(other) + if self.zero? or other.zero? + 0 + else + (self.div(self.gcd(other)) * other).abs + end end - def gcdlcm(int) - a = self.abs - b = int.abs - gcd = a.gcd(b) - return gcd, (a.div(gcd)) * b + def gcdlcm(other) + gcd = self.gcd(other) + if self.zero? or other.zero? + [gcd, 0] + else + [gcd, (self.div(gcd) * other).abs] + end end - end class Fixnum diff --git a/lib/tempfile.rb b/lib/tempfile.rb index 828e1cf8f3..65b4bc69ac 100644 --- a/lib/tempfile.rb +++ b/lib/tempfile.rb @@ -144,7 +144,7 @@ class Tempfile < DelegateClass(File) class << self def callback(data) # :nodoc: pid = $$ - lambda{ + Proc.new { if pid == $$ path, tmpfile, cleanlist = *data @@ -4491,9 +4491,10 @@ rb_str_justify(argc, argv, str, jflag) res = rb_str_new5(str, 0, width); if (argc == 2) { StringValue(pad); - if (RSTRING(pad)->len > 0) { - f = RSTRING(pad)->ptr; - flen = RSTRING(pad)->len; + f = RSTRING(pad)->ptr; + flen = RSTRING(pad)->len; + if (flen == 0) { + rb_raise(rb_eArgError, "zero width padding"); } } p = RSTRING(res)->ptr; |