diff --git a/ChangeLog b/ChangeLog index e0c1f49d0..72dd9c90d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,9 @@ * Source/NSPropertyList.m: Always write date using GMT timezone for 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 diff --git a/Headers/Foundation/NSIndexSet.h b/Headers/Foundation/NSIndexSet.h index b36da41a1..5d91a73fe 100644 --- a/Headers/Foundation/NSIndexSet.h +++ b/Headers/Foundation/NSIndexSet.h @@ -94,6 +94,8 @@ * Only copies index values present in aRange and copies them in order.
* Returns the number of index values placed in aVuffer.
* Modifies aRange to start after the last index value copied.
+ * If aRange is a null pointer, this method attempts to get all + * index values from the set (and of course no range can be returned in it). */ - (unsigned int) getIndexes: (unsigned int*)aBuffer maxCount: (unsigned int)aCount diff --git a/Source/NSIndexSet.m b/Source/NSIndexSet.m index 1a961bfa5..4a9f1eb5f 100644 --- a/Source/NSIndexSet.m +++ b/Source/NSIndexSet.m @@ -280,14 +280,20 @@ static unsigned posForIndex(GSIArray array, unsigned index) unsigned pos; unsigned i = 0; NSRange r; + NSRange fullRange; - if (aBuffer == 0 || aRange == 0) + if (aBuffer == 0) { [NSException raise: NSInvalidArgumentException format: @"[%@-%@]: nul pointer argument", 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 format: @"[%@-%@]: Bad range",