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:
parent
30b3ce3445
commit
67d54f209d
5 changed files with 30 additions and 16 deletions
11
ChangeLog
11
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>
|
Mon Nov 15 18:58:05 2004 Tanaka Akira <akr@m17n.org>
|
||||||
|
|
||||||
* configure.in: check rlim_t more portably. [ruby-core:3735]
|
* 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,
|
* eval.c (ruby_cleanup): ruby_finalize_1 may cause exception,
|
||||||
should be wrapped by PUSH_TAG/POP_TAG(). [ruby-dev:24627]
|
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>
|
Wed Oct 27 09:17:30 2004 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* string.c (str_gsub): use a string object for exception safeness.
|
* string.c (str_gsub): use a string object for exception safeness.
|
||||||
|
|
2
array.c
2
array.c
|
@ -1090,7 +1090,6 @@ rb_ary_update(ary, beg, len, rpl)
|
||||||
len = RARRAY(ary)->len - beg;
|
len = RARRAY(ary)->len - beg;
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_ary_modify(ary);
|
|
||||||
if (rpl == Qundef) {
|
if (rpl == Qundef) {
|
||||||
rlen = 0;
|
rlen = 0;
|
||||||
}
|
}
|
||||||
|
@ -1098,6 +1097,7 @@ rb_ary_update(ary, beg, len, rpl)
|
||||||
rpl = rb_ary_to_ary(rpl);
|
rpl = rb_ary_to_ary(rpl);
|
||||||
rlen = RARRAY(rpl)->len;
|
rlen = RARRAY(rpl)->len;
|
||||||
}
|
}
|
||||||
|
rb_ary_modify(ary);
|
||||||
|
|
||||||
if (beg >= RARRAY(ary)->len) {
|
if (beg >= RARRAY(ary)->len) {
|
||||||
len = beg + rlen;
|
len = beg + rlen;
|
||||||
|
|
|
@ -312,20 +312,22 @@ class Integer
|
||||||
return a
|
return a
|
||||||
end
|
end
|
||||||
|
|
||||||
def lcm(int)
|
def lcm(other)
|
||||||
a = self.abs
|
if self.zero? or other.zero?
|
||||||
b = int.abs
|
0
|
||||||
gcd = a.gcd(b)
|
else
|
||||||
(a.div(gcd)) * b
|
(self.div(self.gcd(other)) * other).abs
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def gcdlcm(int)
|
def gcdlcm(other)
|
||||||
a = self.abs
|
gcd = self.gcd(other)
|
||||||
b = int.abs
|
if self.zero? or other.zero?
|
||||||
gcd = a.gcd(b)
|
[gcd, 0]
|
||||||
return gcd, (a.div(gcd)) * b
|
else
|
||||||
|
[gcd, (self.div(gcd) * other).abs]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class Fixnum
|
class Fixnum
|
||||||
|
|
|
@ -144,7 +144,7 @@ class Tempfile < DelegateClass(File)
|
||||||
class << self
|
class << self
|
||||||
def callback(data) # :nodoc:
|
def callback(data) # :nodoc:
|
||||||
pid = $$
|
pid = $$
|
||||||
lambda{
|
Proc.new {
|
||||||
if pid == $$
|
if pid == $$
|
||||||
path, tmpfile, cleanlist = *data
|
path, tmpfile, cleanlist = *data
|
||||||
|
|
||||||
|
|
7
string.c
7
string.c
|
@ -4491,9 +4491,10 @@ rb_str_justify(argc, argv, str, jflag)
|
||||||
res = rb_str_new5(str, 0, width);
|
res = rb_str_new5(str, 0, width);
|
||||||
if (argc == 2) {
|
if (argc == 2) {
|
||||||
StringValue(pad);
|
StringValue(pad);
|
||||||
if (RSTRING(pad)->len > 0) {
|
f = RSTRING(pad)->ptr;
|
||||||
f = RSTRING(pad)->ptr;
|
flen = RSTRING(pad)->len;
|
||||||
flen = RSTRING(pad)->len;
|
if (flen == 0) {
|
||||||
|
rb_raise(rb_eArgError, "zero width padding");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p = RSTRING(res)->ptr;
|
p = RSTRING(res)->ptr;
|
||||||
|
|
Loading…
Add table
Reference in a new issue