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

* array.c (rb_ary_update): pedantic check to detect

rb_ary_to_ary() to modify the receiver.  [ruby-dev:24861]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@7273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2004-11-15 16:45:03 +00:00
parent 30b3ce3445
commit 67d54f209d
5 changed files with 30 additions and 16 deletions

View file

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

View file

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

View file

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

View file

@ -144,7 +144,7 @@ class Tempfile < DelegateClass(File)
class << self
def callback(data) # :nodoc:
pid = $$
lambda{
Proc.new {
if pid == $$
path, tmpfile, cleanlist = *data

View file

@ -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;
if (flen == 0) {
rb_raise(rb_eArgError, "zero width padding");
}
}
p = RSTRING(res)->ptr;