summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--array.c2
-rw-r--r--lib/rational.rb24
-rw-r--r--lib/tempfile.rb2
-rw-r--r--string.c7
5 files changed, 30 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index ba9ab95c16..ad84079301 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Nov 16 01:41:31 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * 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 <akr@m17n.org>
* configure.in: check rlim_t more portably. [ruby-core:3735]
@@ -473,6 +478,12 @@ Fri Oct 29 10:00:30 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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 <akr@m17n.org>
+
+ * 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 <nobu@ruby-lang.org>
* string.c (str_gsub): use a string object for exception safeness.
diff --git a/array.c b/array.c
index 8b9c62063a..3e55ca4e3b 100644
--- a/array.c
+++ b/array.c
@@ -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
diff --git a/string.c b/string.c
index 6ebbf9289d..bf95d610c1 100644
--- a/string.c
+++ b/string.c
@@ -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;