Implement (and document) a MacOS-X compatibility behavior

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@19909 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2004-08-24 05:20:40 +00:00
parent 2ef86a582f
commit 0d8ec1ee0f
3 changed files with 13 additions and 2 deletions

View file

@ -2,6 +2,9 @@
* Source/NSPropertyList.m: Always write date using GMT timezone for * Source/NSPropertyList.m: Always write date using GMT timezone for
consistency. Make XML representation MacOS-X compatible. consistency. Make XML representation MacOS-X compatible.
* Source/NSIndexSet.m: ([getIndexes:maxCount:inIndexRange:]) accept
null pointer for index range. Consistent with undocumented MacOS-X
feature (but we document it).
2004-08-23 Richard Frith-Macdonald <rfm@gnu.org> 2004-08-23 Richard Frith-Macdonald <rfm@gnu.org>

View file

@ -94,6 +94,8 @@
* Only copies index values present in aRange and copies them in order.<br /> * Only copies index values present in aRange and copies them in order.<br />
* Returns the number of index values placed in aVuffer.<br /> * Returns the number of index values placed in aVuffer.<br />
* Modifies aRange to start after the last index value copied.<br /> * Modifies aRange to start after the last index value copied.<br />
* If aRange is a null pointer, this method attempts to get <em>all</em>
* index values from the set (and of course no range can be returned in it).
*/ */
- (unsigned int) getIndexes: (unsigned int*)aBuffer - (unsigned int) getIndexes: (unsigned int*)aBuffer
maxCount: (unsigned int)aCount maxCount: (unsigned int)aCount

View file

@ -280,14 +280,20 @@ static unsigned posForIndex(GSIArray array, unsigned index)
unsigned pos; unsigned pos;
unsigned i = 0; unsigned i = 0;
NSRange r; NSRange r;
NSRange fullRange;
if (aBuffer == 0 || aRange == 0) if (aBuffer == 0)
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"[%@-%@]: nul pointer argument", format: @"[%@-%@]: nul pointer argument",
NSStringFromClass([self class]), NSStringFromSelector(_cmd)]; NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
} }
if (NSNotFound - aRange->length < aRange->location) if (aRange == 0)
{
fullRange = (NSRange){0, NSNotFound};
aRange = &fullRange;
}
else if (NSNotFound - aRange->length < aRange->location)
{ {
[NSException raise: NSInvalidArgumentException [NSException raise: NSInvalidArgumentException
format: @"[%@-%@]: Bad range", format: @"[%@-%@]: Bad range",