mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 00:41:02 +00:00
various bugfixes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@30732 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
67334b918f
commit
15f4308a20
4 changed files with 114 additions and 93 deletions
|
@ -2,6 +2,10 @@
|
|||
|
||||
* Source/NSInvocation: For portability, use NSPageSize() to find
|
||||
size for page alignment.
|
||||
* Source/NSString.m: Raise exception on pul pointer passed to
|
||||
+stringWithCString:encoding: as per OSX.
|
||||
* Source/Additions/GSXML.m: Fix minor memory leak
|
||||
* Source/NSArray.m: ([-valueForKey:]) for for @count
|
||||
|
||||
2010-06-15 Riccardo Mottola
|
||||
|
||||
|
|
|
@ -2955,7 +2955,7 @@ warningFunction(void *ctx, const unsigned char *msg, ...)
|
|||
int colNumber = -1;
|
||||
|
||||
va_start(args, msg);
|
||||
estr = [[NSString alloc] initWithFormat: UTF8Str(msg) arguments: args];
|
||||
estr = [NSString stringWithFormat: UTF8Str(msg) arguments: args];
|
||||
va_end(args);
|
||||
|
||||
NSCAssert(ctx,@"No Context");
|
||||
|
@ -2975,7 +2975,7 @@ errorFunction(void *ctx, const unsigned char *msg, ...)
|
|||
int colNumber = -1;
|
||||
|
||||
va_start(args, msg);
|
||||
estr = [[NSString alloc] initWithFormat: UTF8Str(msg) arguments: args];
|
||||
estr = [NSString stringWithFormat: UTF8Str(msg) arguments: args];
|
||||
va_end(args);
|
||||
NSCAssert(ctx,@"No Context");
|
||||
lineNumber = xmlSAX2GetLineNumber(ctx);
|
||||
|
@ -2994,7 +2994,7 @@ fatalErrorFunction(void *ctx, const unsigned char *msg, ...)
|
|||
int colNumber = -1;
|
||||
|
||||
va_start(args, msg);
|
||||
estr = [[NSString alloc] initWithFormat: UTF8Str(msg) arguments: args];
|
||||
estr = [NSString stringWithFormat: UTF8Str(msg) arguments: args];
|
||||
va_end(args);
|
||||
NSCAssert(ctx, @"No Context");
|
||||
lineNumber = xmlSAX2GetLineNumber(ctx);
|
||||
|
|
192
Source/NSArray.m
192
Source/NSArray.m
|
@ -1352,10 +1352,16 @@ compare(id elem1, id elem2, void* context)
|
|||
{
|
||||
id result = nil;
|
||||
|
||||
if ([key isEqualToString: @"count"] == YES)
|
||||
if ([key isEqualToString: @"@count"] == YES)
|
||||
{
|
||||
result = [NSNumber numberWithUnsignedInt: [self count]];
|
||||
}
|
||||
else if ([key isEqualToString: @"count"] == YES)
|
||||
{
|
||||
GSOnceMLog(
|
||||
@"[NSArray-valueForKey:] called wth 'count' is deprecated .. use '@count'");
|
||||
result = [NSNumber numberWithUnsignedInt: [self count]];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSMutableArray *results = nil;
|
||||
|
@ -1622,120 +1628,128 @@ compare(id elem1, id elem2, void* context)
|
|||
return result;
|
||||
}
|
||||
|
||||
- (void)enumerateObjectsUsingBlock: (GSEnumeratorBlock)aBlock
|
||||
- (void) enumerateObjectsUsingBlock: (GSEnumeratorBlock)aBlock
|
||||
{
|
||||
[self enumerateObjectsWithOptions: 0 usingBlock: aBlock];
|
||||
[self enumerateObjectsWithOptions: 0 usingBlock: aBlock];
|
||||
}
|
||||
- (void)enumerateObjectsWithOptions: (NSEnumerationOptions)opts
|
||||
usingBlock: (GSEnumeratorBlock)aBlock
|
||||
- (void) enumerateObjectsWithOptions: (NSEnumerationOptions)opts
|
||||
usingBlock: (GSEnumeratorBlock)aBlock
|
||||
{
|
||||
NSUInteger count = 0;
|
||||
BOOL shouldStop = NO;
|
||||
id<NSFastEnumeration> enumerator = self;
|
||||
NSUInteger count = 0;
|
||||
BOOL shouldStop = NO;
|
||||
id<NSFastEnumeration> enumerator = self;
|
||||
|
||||
/* If we are enumerating in reverse, use the reverse enumerator for fast
|
||||
* enumeration. */
|
||||
if (opts & NSEnumerationReverse)
|
||||
{
|
||||
enumerator = [self reverseObjectEnumerator];
|
||||
}
|
||||
/* If we are enumerating in reverse, use the reverse enumerator for fast
|
||||
* enumeration. */
|
||||
if (opts & NSEnumerationReverse)
|
||||
{
|
||||
enumerator = [self reverseObjectEnumerator];
|
||||
}
|
||||
|
||||
FOR_IN (id, obj, enumerator)
|
||||
CALL_BLOCK(aBlock, obj, count++, &shouldStop);
|
||||
if (shouldStop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
END_FOR_IN(enumerator)
|
||||
}
|
||||
- (void)enumerateObjectsAtIndexes: (NSIndexSet*)indexSet
|
||||
options: (NSEnumerationOptions)opts
|
||||
usingBlock: (GSEnumeratorBlock)block
|
||||
{
|
||||
[[self objectsAtIndexes: indexSet] enumerateObjectsWithOptions: opts
|
||||
usingBlock: block];
|
||||
FOR_IN (id, obj, enumerator)
|
||||
CALL_BLOCK(aBlock, obj, count++, &shouldStop);
|
||||
if (shouldStop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
END_FOR_IN(enumerator)
|
||||
}
|
||||
|
||||
- (NSIndexSet *)indexesOfObjectsWithOptions: (NSEnumerationOptions)opts
|
||||
passingTest: (GSPredicateBlock)predicate
|
||||
- (void) enumerateObjectsAtIndexes: (NSIndexSet*)indexSet
|
||||
options: (NSEnumerationOptions)opts
|
||||
usingBlock: (GSEnumeratorBlock)block
|
||||
{
|
||||
/* TODO: Concurrency. */
|
||||
NSMutableIndexSet *set = [NSMutableIndexSet indexSet];
|
||||
BOOL shouldStop = NO;
|
||||
id<NSFastEnumeration> enumerator = self;
|
||||
NSUInteger count = 0;
|
||||
[[self objectsAtIndexes: indexSet] enumerateObjectsWithOptions: opts
|
||||
usingBlock: block];
|
||||
}
|
||||
|
||||
/* If we are enumerating in reverse, use the reverse enumerator for fast
|
||||
* enumeration. */
|
||||
if (opts & NSEnumerationReverse)
|
||||
{
|
||||
enumerator = [self reverseObjectEnumerator];
|
||||
}
|
||||
- (NSIndexSet *) indexesOfObjectsWithOptions: (NSEnumerationOptions)opts
|
||||
passingTest: (GSPredicateBlock)predicate
|
||||
{
|
||||
/* TODO: Concurrency. */
|
||||
NSMutableIndexSet *set = [NSMutableIndexSet indexSet];
|
||||
BOOL shouldStop = NO;
|
||||
id<NSFastEnumeration> enumerator = self;
|
||||
NSUInteger count = 0;
|
||||
|
||||
FOR_IN (id, obj, self)
|
||||
if (CALL_BLOCK(predicate, obj, count, &shouldStop))
|
||||
{
|
||||
/* TODO: It would be more efficient to collect an NSRange and only
|
||||
* pass it to the index set when CALL_BLOCK returned NO. */
|
||||
[set addIndex: count];
|
||||
}
|
||||
if (shouldStop)
|
||||
{
|
||||
return set;
|
||||
}
|
||||
count++;
|
||||
END_FOR_IN(self)
|
||||
/* If we are enumerating in reverse, use the reverse enumerator for fast
|
||||
* enumeration. */
|
||||
if (opts & NSEnumerationReverse)
|
||||
{
|
||||
enumerator = [self reverseObjectEnumerator];
|
||||
}
|
||||
|
||||
FOR_IN (id, obj, self)
|
||||
if (CALL_BLOCK(predicate, obj, count, &shouldStop))
|
||||
{
|
||||
/* TODO: It would be more efficient to collect an NSRange and only
|
||||
* pass it to the index set when CALL_BLOCK returned NO. */
|
||||
[set addIndex: count];
|
||||
}
|
||||
if (shouldStop)
|
||||
{
|
||||
return set;
|
||||
}
|
||||
count++;
|
||||
END_FOR_IN(self)
|
||||
return set;
|
||||
}
|
||||
- (NSIndexSet*)indexesOfObjectsPassingTest: (GSPredicateBlock)predicate
|
||||
|
||||
- (NSIndexSet*) indexesOfObjectsPassingTest: (GSPredicateBlock)predicate
|
||||
{
|
||||
return [self indexesOfObjectsWithOptions: 0 passingTest: predicate];
|
||||
return [self indexesOfObjectsWithOptions: 0 passingTest: predicate];
|
||||
}
|
||||
- (NSIndexSet*)indexesOfObjectsAtIndexes: (NSIndexSet*)indexSet
|
||||
options: (NSEnumerationOptions)opts
|
||||
passingTest: (GSPredicateBlock)predicate
|
||||
|
||||
- (NSIndexSet*) indexesOfObjectsAtIndexes: (NSIndexSet*)indexSet
|
||||
options: (NSEnumerationOptions)opts
|
||||
passingTest: (GSPredicateBlock)predicate
|
||||
{
|
||||
return [[self objectsAtIndexes: indexSet] indexesOfObjectsWithOptions: opts
|
||||
passingTest: predicate];
|
||||
return [[self objectsAtIndexes: indexSet]
|
||||
indexesOfObjectsWithOptions: opts
|
||||
passingTest: predicate];
|
||||
}
|
||||
|
||||
- (NSUInteger)indexOfObjectWithOptions: (NSEnumerationOptions)opts
|
||||
passingTest: (GSPredicateBlock)predicate
|
||||
passingTest: (GSPredicateBlock)predicate
|
||||
{
|
||||
/* TODO: Concurrency. */
|
||||
id<NSFastEnumeration> enumerator = self;
|
||||
BOOL shouldStop = NO;
|
||||
NSUInteger count = 0;
|
||||
/* TODO: Concurrency. */
|
||||
id<NSFastEnumeration> enumerator = self;
|
||||
BOOL shouldStop = NO;
|
||||
NSUInteger count = 0;
|
||||
|
||||
/* If we are enumerating in reverse, use the reverse enumerator for fast
|
||||
* enumeration. */
|
||||
if (opts & NSEnumerationReverse)
|
||||
{
|
||||
enumerator = [self reverseObjectEnumerator];
|
||||
}
|
||||
/* If we are enumerating in reverse, use the reverse enumerator for fast
|
||||
* enumeration. */
|
||||
if (opts & NSEnumerationReverse)
|
||||
{
|
||||
enumerator = [self reverseObjectEnumerator];
|
||||
}
|
||||
|
||||
FOR_IN (id, obj, self)
|
||||
if (CALL_BLOCK(predicate, obj, count, &shouldStop))
|
||||
{
|
||||
return count;
|
||||
}
|
||||
if (shouldStop)
|
||||
{
|
||||
return NSNotFound;
|
||||
}
|
||||
count++;
|
||||
END_FOR_IN(self)
|
||||
FOR_IN (id, obj, self)
|
||||
if (CALL_BLOCK(predicate, obj, count, &shouldStop))
|
||||
{
|
||||
return count;
|
||||
}
|
||||
if (shouldStop)
|
||||
{
|
||||
return NSNotFound;
|
||||
}
|
||||
count++;
|
||||
END_FOR_IN(self)
|
||||
return NSNotFound;
|
||||
}
|
||||
- (NSUInteger)indexOfObjectPassingTest: (GSPredicateBlock)predicate
|
||||
|
||||
- (NSUInteger) indexOfObjectPassingTest: (GSPredicateBlock)predicate
|
||||
{
|
||||
return [self indexOfObjectWithOptions: 0 passingTest: predicate];
|
||||
return [self indexOfObjectWithOptions: 0 passingTest: predicate];
|
||||
}
|
||||
|
||||
- (NSUInteger)indexOfObjectAtIndexes: (NSIndexSet*)indexSet
|
||||
options: (NSEnumerationOptions)opts
|
||||
passingTest: (GSPredicateBlock)predicate
|
||||
options: (NSEnumerationOptions)opts
|
||||
passingTest: (GSPredicateBlock)predicate
|
||||
{
|
||||
return [[self objectsAtIndexes: indexSet] indexOfObjectWithOptions: 0
|
||||
passingTest: predicate];
|
||||
return [[self objectsAtIndexes: indexSet]
|
||||
indexOfObjectWithOptions: 0
|
||||
passingTest: predicate];
|
||||
}
|
||||
@end
|
||||
|
||||
|
|
|
@ -741,6 +741,9 @@ handle_printf_atsign (FILE *stream,
|
|||
{
|
||||
NSString *obj;
|
||||
|
||||
if (NULL == byteString)
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"[NSString+stringWithCString:encoding:]: NULL cString"];
|
||||
obj = [self allocWithZone: NSDefaultMallocZone()];
|
||||
obj = [obj initWithCString: byteString encoding: encoding];
|
||||
return AUTORELEASE(obj);
|
||||
|
@ -1025,7 +1028,7 @@ handle_printf_atsign (FILE *stream,
|
|||
encoding: (NSStringEncoding)encoding
|
||||
{
|
||||
return [self initWithBytes: byteString
|
||||
length: strlen(byteString)
|
||||
length: (byteString ? strlen(byteString) : 0)
|
||||
encoding: encoding];
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue