From e5f80777d1152f6dcb3259b135722ed182e19900 Mon Sep 17 00:00:00 2001 From: CaS Date: Sat, 8 Sep 2001 05:15:19 +0000 Subject: [PATCH] Fix for writing plists to URLs git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@10852 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 5 +++-- Source/NSArray.m | 20 +++++++++++++++++++- Source/NSDictionary.m | 20 +++++++++++++++++++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index b3d5b6573..f5f996393 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,8 +3,9 @@ * Source/GSCompatibility.m: GSXMLPlMake() unused argument removed. * Source/NSData.m: Unused and commented out XML plist code removed. * Source/NSString.m: ditto - * Source/NSArray.m: Generate XML plists only when writing to file, - not for the -description... methods. This is what MacOS-X does. + * Source/NSArray.m: Generate XML plists only when writing to file + or to URL, not for the -description... methods. + This is what MacOS-X does. * Source/NSDictionary.m: ditto 2001-09-05 Adam Fedor diff --git a/Source/NSArray.m b/Source/NSArray.m index 545416e84..61bcdefe3 100644 --- a/Source/NSArray.m +++ b/Source/NSArray.m @@ -859,11 +859,29 @@ static NSString *indentStrings[] = { - (BOOL) writeToURL: (NSURL *)url atomically: (BOOL)useAuxiliaryFile { + extern BOOL GSMacOSXCompatiblePropertyLists(); NSDictionary *loc; NSString *desc; loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]; - desc = [self descriptionWithLocale: loc indent: 0]; + + if (GSMacOSXCompatiblePropertyLists() == YES) + { + extern NSString *GSXMLPlMake(id obj, NSDictionary *loc); + + desc = GSXMLPlMake(self, loc); + } + else + { + NSMutableString *result; + + result = [[NSMutableString alloc] initWithCapacity: 20*[self count]]; + result = AUTORELEASE(result); + [self descriptionWithLocale: loc + indent: 0 + to: (id)result]; + desc = result; + } return [desc writeToURL: url atomically: useAuxiliaryFile]; } diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m index 5a3ab9333..b6bb12a06 100644 --- a/Source/NSDictionary.m +++ b/Source/NSDictionary.m @@ -651,11 +651,29 @@ compareIt(id o1, id o2, void* context) - (BOOL) writeToURL: (NSURL *)url atomically: (BOOL)useAuxiliaryFile { + extern BOOL GSMacOSXCompatiblePropertyLists(); NSDictionary *loc; NSString *desc; loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]; - desc = [self descriptionWithLocale: loc indent: 0]; + + if (GSMacOSXCompatiblePropertyLists() == YES) + { + extern NSString *GSXMLPlMake(id obj, NSDictionary *loc); + + desc = GSXMLPlMake(self, loc); + } + else + { + NSMutableString *result; + + result = AUTORELEASE([[NSMutableString alloc] initWithCapacity: + 20*[self count]]); + [self descriptionWithLocale: loc + indent: 0 + to: (id)result]; + desc = result; + } return [desc writeToURL: url atomically: useAuxiliaryFile]; }