[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/KDE/3.5/kdelibs/kjs
From: George Staikos <staikos () kde ! org>
Date: 2005-10-18 5:52:12
Message-ID: 1129614732.848249.10524.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 471553 by staikos:
fix slice() for mozilla testsuite. no regressions in our suite
M +13 -10 string_object.cpp
--- branches/KDE/3.5/kdelibs/kjs/string_object.cpp #471552:471553
@@ -405,20 +405,23 @@
{
// The arg processing is very much like ArrayProtoFunc::Slice
int begin = args[0].toUInt32(exec);
- if (begin < 0)
- begin = maxInt(begin + len, 0);
- else
- begin = minInt(begin, len);
int end = len;
if (args[1].type() != UndefinedType) {
end = args[1].toInteger(exec);
- if (end < 0)
- end = maxInt(len + end, 0);
- else
- end = minInt(end, len);
}
- //printf( "Slicing from %d to %d \n", begin, end );
- result = String(s.substr(begin, end-begin));
+ int from = begin < 0 ? len + begin : begin;
+ int to = end < 0 ? len + end : end;
+ if (to > from && to > 0 && from < len) {
+ if (from < 0) {
+ from = 0;
+ }
+ if (to > len) {
+ to = len;
+ }
+ result = String(s.substr(from, to - from));
+ } else {
+ result = String("");
+ }
break;
}
case Split: {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic