diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-11-09 09:11:52 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-11-09 09:11:52 +0000 |
commit | ee5ab9cc136baf18756abc6bd5d136a0231f973e (patch) | |
tree | abdc351cbffd7b67f63f41ea08f544819af0a28b /array.c | |
parent | dc8da69e7cbc54f020ef1182fd28e57bbaa40fc3 (diff) |
1.1c7
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@316 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -370,32 +370,29 @@ beg_len(range, begp, lenp, len) int len; { int beg, end; + int b, e; if (!range_beg_end(range, &beg, &end)) return FALSE; - - if ((beg > 0 && end > 0 || beg < 0 && end < 0) && beg > end) { - IndexError("end smaller than beg [%d..%d]", beg, end); - } + b = beg; e = end; if (beg < 0) { beg = len + beg; if (beg < 0) beg = 0; } + if (end < 0) { + end = len + end; + if (end < 0) end = -1; + } + if (beg > end) { + IndexError("end smaller than beg [%d..%d]", b, e); + } + *begp = beg; if (beg > len) { *lenp = 0; } else { - if (end < 0) { - end = len + end; - if (end < 0) end = -1; - } - if (beg > end) { - *lenp = 0; - } - else { - *lenp = end - beg +1; - } + *lenp = end - beg +1; } return TRUE; } |