From 531dd954e28ec724f6de9e25d13318500ef22ba9 Mon Sep 17 00:00:00 2001 From: fedor Date: Mon, 13 Dec 2004 04:53:01 +0000 Subject: [PATCH] * Changes so additions compiles on older Mac OS X 10.1.5 * Source/Additions/GCArray.m (-copyWithZone:): Use more standard array initialization method. (mutableCopyWithZone:, [GCMutableArray -copyWithZone:], [GCMutableArray -mutableCopyWithZone:]): Idem. * Source/Additions/GSCategories.m ([NSData -hexadecimalRepresentation]): Use identically functioning, but older, standard data initialization. * Source/Additions/GSCategories.m ([NSMutableString -replaceString:withString:]): Rewrite to use older, standard methods. * Tools/AGSHtml.m ([AGSHtml -outputNode:to:]): Use GNUstep addition method to replace string. * Tools/autogsdoc.m (main): Idem. (Patch from Markus Hitter). git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@20448 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 19 ++++++++++++++++ Source/Additions/GCArray.m | 40 +++++++++++++++++++++++++++------ Source/Additions/GSCategories.m | 12 +++++----- Tools/AGSHtml.m | 4 ++-- Tools/autogsdoc.m | 25 ++++++--------------- 5 files changed, 68 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 85895b1f4..7c37206f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2004-12-12 Adam Fedor + + * Changes so additions compiles on older Mac OS X 10.1.5 + * Source/Additions/GCArray.m (-copyWithZone:): Use more standard + array initialization method. + (mutableCopyWithZone:, [GCMutableArray -copyWithZone:], + [GCMutableArray -mutableCopyWithZone:]): Idem. + + * Source/Additions/GSCategories.m ([NSData -hexadecimalRepresentation]): + Use identically functioning, but older, standard data initialization. + * Source/Additions/GSCategories.m ([NSMutableString + -replaceString:withString:]): Rewrite to use older, standard + methods. + + * Tools/AGSHtml.m ([AGSHtml -outputNode:to:]): Use GNUstep addition + method to replace string. + * Tools/autogsdoc.m (main): Idem. + (Patch from Markus Hitter). + 2004-12-12 Adam Fedor * configure.ac: Avoid improper use of -fXXX-runtime. Add -x objective-c diff --git a/Source/Additions/GCArray.m b/Source/Additions/GCArray.m index df2bbfec3..6dd2ef0f9 100644 --- a/Source/Additions/GCArray.m +++ b/Source/Additions/GCArray.m @@ -57,11 +57,26 @@ static Class gcClass = 0; - (id) copyWithZone: (NSZone*)zone { + GCArray *result; + id *objects; + unsigned i, c = [self count]; + if (NSShouldRetainWithZone(self, zone)) { return [self retain]; } - return [[GCArray allocWithZone: zone] initWithArray: self copyItems: YES]; + + objects = NSZoneMalloc(zone, c * sizeof(id)); + /* FIXME: Check if malloc return 0 */ + [self getObjects: objects]; + for (i = 0; i < c; i++) + { + objects[i] = [objects[i] copy]; + } + result = [[GCArray allocWithZone: zone] initWithObjects: objects count: c]; + NSZoneFree(zone, objects); + + return result; } - (unsigned int) count @@ -189,8 +204,7 @@ static Class gcClass = 0; - (id) mutableCopyWithZone: (NSZone*)zone { - return [[GCMutableArray allocWithZone: zone] - initWithArray: self copyItems: NO]; + return [[GCMutableArray allocWithZone: zone] initWithArray: self]; } - (id) objectAtIndex: (unsigned int)index @@ -233,8 +247,21 @@ static Class gcClass = 0; - (id) copyWithZone: (NSZone*)zone { - return [[GCArray allocWithZone: zone] - initWithArray: self copyItems: YES]; + GCArray *result; + id *objects; + unsigned i, c = [self count]; + + objects = NSZoneMalloc(zone, c * sizeof(id)); + /* FIXME: Check if malloc return 0 */ + [self getObjects: objects]; + for (i = 0; i < c; i++) + { + objects[i] = [objects[i] copy]; + } + result = [[GCArray allocWithZone: zone] initWithObjects: objects count: c]; + NSZoneFree(zone, objects); + + return result; } - (id) init @@ -345,8 +372,7 @@ static Class gcClass = 0; - (id) mutableCopyWithZone: (NSZone*)zone { - return [[GCMutableArray allocWithZone: zone] - initWithArray: self copyItems: NO]; + return [[GCMutableArray allocWithZone: zone] initWithArray: self]; } - (void) removeAllObjects diff --git a/Source/Additions/GSCategories.m b/Source/Additions/GSCategories.m index 39c9e2175..3e6693943 100644 --- a/Source/Additions/GSCategories.m +++ b/Source/Additions/GSCategories.m @@ -135,7 +135,7 @@ dst[dpos++] = hexChars[c & 0x0f]; } data = [NSData allocWithZone: NSDefaultMallocZone()]; - data = [data initWithBytesNoCopy: dst length: dlen freeWhenDone: YES]; + data = [data initWithBytesNoCopy: dst length: dlen]; string = [[NSString alloc] initWithData: data encoding: NSASCIIStringEncoding]; RELEASE(data); @@ -1070,10 +1070,12 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16]) - (void) replaceString: (NSString*)replace withString: (NSString*)by { - [self replaceOccurrencesOfString: replace - withString: by - options: 0 - range: NSMakeRange(0, [self length])]; + NSRange range = [self rangeOfString: replace]; + + while (range.location != NSNotFound) { + [self replaceCharactersInRange: range withString: by]; + range = [self rangeOfString: replace]; + } } /** diff --git a/Tools/AGSHtml.m b/Tools/AGSHtml.m index 4949a31af..443c7f67d 100644 --- a/Tools/AGSHtml.m +++ b/Tools/AGSHtml.m @@ -1561,8 +1561,8 @@ static NSString *mainFont = nil; // get rid of nbsps put in for readability above linkRef = [NSMutableString stringWithCapacity: [sel length]]; [linkRef setString:sel]; - [linkRef replaceOccurrencesOfString:@" " withString:@"" - options: 0 range: NSMakeRange(0, [sel length])]; + [linkRef replaceString: @" " withString: @""]; + s = [self makeLink: linkRef ofType: @"method" inUnit: nil isRef: NO]; if (s != nil) { diff --git a/Tools/autogsdoc.m b/Tools/autogsdoc.m index 9f7a8aede..7b841cd04 100644 --- a/Tools/autogsdoc.m +++ b/Tools/autogsdoc.m @@ -1779,10 +1779,8 @@ main(int argc, char **argv, char **env) @" \n" @" \n" @"\n"]; - [tocSkel replaceOccurrencesOfString: @"[prjName]" withString: project - options: 0 - range: NSMakeRange(0, [tocSkel length])]; - + [tocSkel replaceString: @"[prjName]" withString: project]; + // file for top-left frame (header only; rest appended below) idxIndexFile = [@"MainIndex" stringByAppendingPathExtension: @"html"]; [idxIndex setString: @"\n \n" @@ -1806,10 +1804,8 @@ main(int argc, char **argv, char **env) @" \n" @" \n" @"\n"]; - [frameset replaceOccurrencesOfString: @"[prjName]" withString: project - options: 0 - range: NSMakeRange(0, [frameset length])]; - + [frameset replaceString: @"[prjName]" withString: project]; + // generate the table of contents gsdoc files for (i = 0; i < [idxTypes count]; i++) { @@ -1824,12 +1820,8 @@ main(int argc, char **argv, char **env) typeU = [@"Class" isEqualToString: typeU] ? [typeU stringByAppendingString: @"es"] : [typeU stringByAppendingString: @"s"]; - [contents replaceOccurrencesOfString: @"[typeL]" withString: typeL - options: 0 - range: NSMakeRange(0,[contents length])]; - [contents replaceOccurrencesOfString: @"[typeU]" withString: typeU - options: 0 - range: NSMakeRange(0,[contents length])]; + [contents replaceString: @"[typeL]" withString: typeL]; + [contents replaceString: @"[typeU]" withString: typeU]; gsdocFile = [[typeU stringByAppendingString: @"TOC"] stringByAppendingPathExtension: @"gsdoc"]; htmlFile = [[typeU stringByAppendingString: @"TOC"] @@ -1894,10 +1886,7 @@ main(int argc, char **argv, char **env) @" \n" @" \n" @"\n"]; - [prjFileContents replaceOccurrencesOfString: @"[prjName]" - withString: project - options: 0 - range: NSMakeRange(0, [prjFileContents length])]; + [prjFileContents replaceString: @"[prjName]" withString: project]; [prjFileContents writeToFile: [documentationDirectory stringByAppendingPathComponent: prjFile] atomically: YES];