From 43da69d1ae8219fd4e4a0063161c6b64ad3ceaa5 Mon Sep 17 00:00:00 2001 From: mccallum Date: Thu, 21 Sep 1995 17:42:46 +0000 Subject: [PATCH] Patched from mail. See ChangeLog git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@612 72102866-910b-0410-8b05-ffd578937521 --- Source/NSArray.m | 10 +++++----- Source/NSBundle.m | 11 +++++++++++ Source/NSGArray.m | 6 ++++++ Source/NSGCString.m | 2 +- Source/NSGData.m | 22 ++++++++++++++++++++++ 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/Source/NSArray.m b/Source/NSArray.m index 40c811135..958a39463 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -214,7 +214,7 @@ static Class NSMutableArray_concrete_class; for (i = 0; i < c; i++) if (anObject == [self objectAtIndex:i]) return i; - return UINT_MAX; + return NSNotFound; } /* Inefficient, should be overridden. */ @@ -224,12 +224,12 @@ static Class NSMutableArray_concrete_class; for (i = 0; i < c; i++) if ([[self objectAtIndex:i] isEqual: anObject]) return i; - return UINT_MAX; + return NSNotFound; } - (BOOL) containsObject: anObject { - return ([self indexOfObject:anObject] != UINT_MAX); + return ([self indexOfObject:anObject] != NSNotFound); } - (BOOL) isEqual: anObject @@ -434,14 +434,14 @@ static Class NSMutableArray_concrete_class; - (void) removeObjectIdenticalTo: anObject { int i = [self indexOfObjectIdenticalTo:anObject]; - assert (i != UINT_MAX); /* xxx should raise an NSException instead */ + assert (i != NSNotFound); /* xxx should raise an NSException instead */ [self removeObjectAtIndex:i]; } - (void) removeObject: anObject { int i = [self indexOfObject:anObject]; - assert (i != UINT_MAX); /* xxx should raise an NSException instead */ + assert (i != NSNotFound); /* xxx should raise an NSException instead */ [self removeObjectAtIndex:i]; } diff --git a/Source/NSBundle.m b/Source/NSBundle.m index 1534b19ef..9020f03c9 100644 --- a/Source/NSBundle.m +++ b/Source/NSBundle.m @@ -281,6 +281,17 @@ _bundle_load_callback(Class theClass, Category *theCategory) /* NOT REACHED */ } + /* Check if we were already initialized for this directory */ + if (_bundles) { + int i; + int count; + count = [_bundles count]; + for (i=0; i < count; i++) { + if ([path isEqual:[[_bundles objectAtIndex:i] bundlePath]]) + return [_bundles objectAtIndex:i]; + } + } + if (stat([path cString], &statbuf) != 0) { [NSException raise:NSGenericException format:@"Could not find path %s", [path cString]]; diff --git a/Source/NSGArray.m b/Source/NSGArray.m index 6315007a6..868e7e543 100644 --- a/Source/NSGArray.m +++ b/Source/NSGArray.m @@ -68,6 +68,12 @@ return _count; } +/* Force message to go to super class rather than the behavior class */ +- (unsigned) indexOfObject: anObject +{ + return [super indexOfObject: anObject]; +} + - objectAtIndex: (unsigned)index { assert(index < _count); /* xxx should raise NSException instead */ diff --git a/Source/NSGCString.m b/Source/NSGCString.m index e592ca63d..cd550b17f 100644 --- a/Source/NSGCString.m +++ b/Source/NSGCString.m @@ -67,7 +67,7 @@ /* Empty copy must empty an allocCopy'ed version of self */ - emptyCopy { - NSGCString *copy = [super emptyCopy]; + NSGCString *copy = [super allocCopy]; OBJC_MALLOC(copy->_contents_chars, char, _count+1); copy->_count = 0; copy->_contents_chars[0] = '\0'; diff --git a/Source/NSGData.m b/Source/NSGData.m index 3fbe49745..455b743e0 100644 --- a/Source/NSGData.m +++ b/Source/NSGData.m @@ -93,6 +93,22 @@ return YES; } +- copyWithZone: (NSZone *)zone +{ + if (NSShouldRetainWithZone(self, zone)) + return [self retain]; + else { + return [[NSData allocWithZone:zone] + initWithBytes:[self bytes] length:[self length]]; + } +} + +- mutableCopyWithZone: (NSZone *)zone +{ + return [[NSMutableData allocWithZone:zone] + initWithBytes:[self bytes] length:[self length]]; +} + @end @@ -141,4 +157,10 @@ [self writeBytes:bytes length:length]; } +- copyWithZone: (NSZone *)zone +{ + return [[NSData allocWithZone:zone] + initWithBytes:[self bytes] length:[self length]]; +} + @end