mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-03 10:00:51 +00:00
Fix bug shifting indexes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28701 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1c97fb7e67
commit
7b0573fc9f
2 changed files with 30 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2009-09-17 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
|
* Source/NSIndexSet.m:
|
||||||
|
([-shiftIndexesStartingAtIndex:by:]) fix to properly merge index
|
||||||
|
ranges when shifting left.
|
||||||
|
|
||||||
2009-09-15 Richard Frith-Macdonald <rfm@gnu.org>
|
2009-09-15 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Headers/Additions/GNUstepBase/GSMime.h:
|
* Headers/Additions/GNUstepBase/GSMime.h:
|
||||||
|
|
|
@ -52,7 +52,14 @@ static void sanity(GSIArray array)
|
||||||
{
|
{
|
||||||
NSRange r = GSIArrayItemAtIndex(array, i).ext;
|
NSRange r = GSIArrayItemAtIndex(array, i).ext;
|
||||||
|
|
||||||
NSCAssert(r.location >= last, @"Overlap ranges");
|
if (i > 0)
|
||||||
|
{
|
||||||
|
NSCAssert(r.location > last, @"Overlap or touching ranges");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NSCAssert(r.location >= last, @"Overlap ranges");
|
||||||
|
}
|
||||||
NSCAssert(NSMaxRange(r) > r.location, @"Bad range length");
|
NSCAssert(NSMaxRange(r) > r.location, @"Bad range length");
|
||||||
last = NSMaxRange(r);
|
last = NSMaxRange(r);
|
||||||
}
|
}
|
||||||
|
@ -1228,6 +1235,22 @@ static NSUInteger posForIndex(GSIArray array, NSUInteger index)
|
||||||
GSIArraySetItemAtIndex(_array, (GSIArrayItem)r, c);
|
GSIArraySetItemAtIndex(_array, (GSIArrayItem)r, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (pos > 0)
|
||||||
|
{
|
||||||
|
c = GSIArrayCount(_array);
|
||||||
|
if (pos < c)
|
||||||
|
{
|
||||||
|
NSRange r0 = GSIArrayItemAtIndex(_array, pos - 1).ext;
|
||||||
|
NSRange r1 = GSIArrayItemAtIndex(_array, pos).ext;
|
||||||
|
|
||||||
|
if (NSMaxRange(r0) == r1.location)
|
||||||
|
{
|
||||||
|
r0.length += r1.length;
|
||||||
|
GSIArraySetItemAtIndex(_array, (GSIArrayItem)r0, pos - 1);
|
||||||
|
GSIArrayRemoveItemAtIndex(_array, pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SANITY();
|
SANITY();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue