mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* range.c (rb_range_beg_len): returns Qnil only when "beg" points
outside of a range. No boundary check for "end". git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ca14017bb6
commit
280d014d6d
5 changed files with 12 additions and 10 deletions
|
@ -1,3 +1,8 @@
|
|||
Sat Jul 24 13:32:47 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* range.c (rb_range_beg_len): returns Qnil only when "beg" points
|
||||
outside of a range. No boundary check for "end".
|
||||
|
||||
Fri Jul 23 16:40:25 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* gc.c (define_final): should not disclose NODE* to Ruby world.
|
||||
|
|
6
array.c
6
array.c
|
@ -774,10 +774,8 @@ rb_ary_subseq(ary, beg, len)
|
|||
* continuing for _length_ elements, or returns a subarray
|
||||
* specified by _range_.
|
||||
* Negative indices count backward from the end of the
|
||||
* array (-1 is the last element). Returns nil if any indices
|
||||
* are out of range unless the index equals the array size and a
|
||||
* _length_ or _range_ parameter is given, in which case an
|
||||
* empty array is returned.
|
||||
* array (-1 is the last element). Returns nil if the index
|
||||
* (or starting index) are out of range.
|
||||
*
|
||||
* a = [ "a", "b", "c", "d", "e" ]
|
||||
* a[2] + a[0] + a[1] #=> "cab"
|
||||
|
|
|
@ -49,7 +49,7 @@ module Ping
|
|||
end
|
||||
rescue Errno::ECONNREFUSED
|
||||
return true
|
||||
rescue
|
||||
rescue Timeout::Error
|
||||
return false
|
||||
end
|
||||
return true
|
||||
|
|
6
range.c
6
range.c
|
@ -480,14 +480,12 @@ rb_range_beg_len(range, begp, lenp, len, err)
|
|||
}
|
||||
if (err == 0 || err == 2) {
|
||||
if (beg > len) goto out_of_range;
|
||||
if (end > len)
|
||||
end = len;
|
||||
if (end > len) end = len;
|
||||
}
|
||||
if (end < 0) end += len;
|
||||
if (!EXCL(range)) end++; /* include end point */
|
||||
if (end < 0) goto out_of_range;
|
||||
len = end - beg;
|
||||
if (len < 0) goto out_of_range;
|
||||
if (len < 0) len = 0;
|
||||
|
||||
*begp = beg;
|
||||
*lenp = len;
|
||||
|
|
3
string.c
3
string.c
|
@ -1552,7 +1552,8 @@ rb_str_aref(str, indx)
|
|||
* a[1..3] #=> "ell"
|
||||
* a[-3,2] #=> "er"
|
||||
* a[-4..-2] #=> "her"
|
||||
* a[-2..-4] #=> nil
|
||||
* a[12..-1] #=> nil
|
||||
* a[-2..-4] #=> ""
|
||||
* a[/[aeiou](.)\1/] #=> "ell"
|
||||
* a[/[aeiou](.)\1/, 0] #=> "ell"
|
||||
* a[/[aeiou](.)\1/, 1] #=> "l"
|
||||
|
|
Loading…
Add table
Reference in a new issue