Fixups for macos-x compatibility

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@23271 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-08-13 09:17:53 +00:00
parent 476d56e76b
commit 384ab4003a
3 changed files with 26 additions and 22 deletions

View file

@ -4,7 +4,7 @@
multibyte encodings) strings could be truncated at the wrong
precision.
* Source/NSIndexPath.m: ([indexAtPosition:]) return NSNotFound if
given a bad position.
given a bad position. ([compare:]) fix to match MacOS-X
* Source/NSObject.m: implement CRASH_ON_ZOMBIE
* Documentation/Base.gsdoc: document it.

View file

@ -69,7 +69,8 @@
- (void) getIndexes: (unsigned*)aBuffer;
/**
* Return the index at the specified position or raise an exception.
* Return the index at the specified position or NSNotFound if there
* is no index at the specified position.
*/
- (unsigned) indexAtPosition: (unsigned)position;

View file

@ -78,35 +78,38 @@ static NSIndexPath *dummy = nil;
- (NSComparisonResult) compare: (NSIndexPath*)other
{
if (other == self)
{
return NSOrderedSame;
}
else
if (other != self)
{
unsigned olength = other->_length;
unsigned *oindexes = other->_indexes;
unsigned end = (_length > olength) ? _length : olength;
unsigned pos;
for (pos = 0; pos < _length; pos++)
for (pos = 0; pos < end; pos++)
{
if (pos >= other->_length || other->_indexes[pos] < _indexes[pos])
{
return NSOrderedAscending;
}
if (other->_indexes[pos] > _indexes[pos])
if (pos >= _length)
{
return NSOrderedDescending;
}
else if (pos >= olength)
{
return NSOrderedAscending;
}
if (oindexes[pos] < _indexes[pos])
{
return NSOrderedDescending;
}
if (oindexes[pos] > _indexes[pos])
{
return NSOrderedAscending;
}
}
if (_length == other->_length)
{
/*
* Should never get here.
*/
NSLog(@"Argh ... two identical index paths exist!");
return NSOrderedSame;
}
return NSOrderedDescending;
/*
* Should never get here.
*/
NSLog(@"Argh ... two identical index paths exist!");
}
return NSOrderedSame;
}
- (id) copyWithZone: (NSZone*)aZone