mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
Alter initialisation order to make plist generation more robust.
This commit is contained in:
parent
314a609fe8
commit
9e86902ba1
1 changed files with 44 additions and 21 deletions
|
@ -2379,30 +2379,46 @@ static BOOL classInitialized = NO;
|
|||
|
||||
+ (void) initialize
|
||||
{
|
||||
if (classInitialized == NO)
|
||||
NSMutableCharacterSet *s;
|
||||
|
||||
if (Nil == NSStringClass) NSStringClass = [NSString class];
|
||||
if (Nil == GSStringClass) GSStringClass = [GSString class];
|
||||
if (Nil == NSMutableStringClass)
|
||||
NSMutableStringClass = [NSMutableString class];
|
||||
if (Nil == GSMutableStringClass)
|
||||
GSMutableStringClass = [GSMutableString class];
|
||||
|
||||
if (Nil == NSArrayClass) NSArrayClass = [NSArray class];
|
||||
if (Nil == plArray)
|
||||
{
|
||||
NSMutableCharacterSet *s;
|
||||
|
||||
classInitialized = YES;
|
||||
|
||||
NSStringClass = [NSString class];
|
||||
NSMutableStringClass = [NSMutableString class];
|
||||
NSDataClass = [NSData class];
|
||||
NSDateClass = [NSDate class];
|
||||
NSNumberClass = [NSNumber class];
|
||||
NSArrayClass = [NSArray class];
|
||||
NSDictionaryClass = [NSDictionary class];
|
||||
GSStringClass = [GSString class];
|
||||
GSMutableStringClass = [GSMutableString class];
|
||||
|
||||
plArray = [GSMutableArray class];
|
||||
plAdd = (id (*)(id, SEL, id))
|
||||
[plArray instanceMethodForSelector: @selector(addObject:)];
|
||||
}
|
||||
|
||||
if (Nil == NSDictionaryClass) NSDictionaryClass = [NSDictionary class];
|
||||
if (Nil == plDictionary)
|
||||
{
|
||||
plDictionary = [GSMutableDictionary class];
|
||||
plSet = (id (*)(id, SEL, id, id))
|
||||
[plDictionary instanceMethodForSelector: @selector(setObject:forKey:)];
|
||||
}
|
||||
|
||||
if (Nil == NSDataClass) NSDataClass = [NSData class];
|
||||
if (Nil == NSNumberClass) NSNumberClass = [NSNumber class];
|
||||
if (nil == boolN)
|
||||
{
|
||||
boolN = [[NSNumber numberWithBool: NO] retain];
|
||||
[[NSObject leakAt: &boolN] release];
|
||||
}
|
||||
if (nil == boolY)
|
||||
{
|
||||
boolY = [[NSNumber numberWithBool: YES] retain];
|
||||
[[NSObject leakAt: &boolY] release];
|
||||
}
|
||||
|
||||
if (nil == oldQuotables)
|
||||
{
|
||||
/* The '$', '.', '/' and '_' characters used to be OK to use in
|
||||
* property lists, but OSX now quotes them, so we follow suite.
|
||||
*/
|
||||
|
@ -2413,7 +2429,10 @@ static BOOL classInitialized = NO;
|
|||
[s invert];
|
||||
oldQuotables = s;
|
||||
[[NSObject leakAt: &oldQuotables] release];
|
||||
}
|
||||
|
||||
if (nil == xmlQuotables)
|
||||
{
|
||||
s = [NSMutableCharacterSet new];
|
||||
[s addCharactersInString: @"&<>'\\\""];
|
||||
[s addCharactersInRange: NSMakeRange(0x0001, 0x001f)];
|
||||
|
@ -2423,13 +2442,17 @@ static BOOL classInitialized = NO;
|
|||
[s addCharactersInRange: NSMakeRange(0xFFFE, 0x0002)];
|
||||
xmlQuotables = s;
|
||||
[[NSObject leakAt: &xmlQuotables] release];
|
||||
|
||||
boolN = [[NSNumber numberWithBool: NO] retain];
|
||||
[[NSObject leakAt: &boolN] release];
|
||||
|
||||
boolY = [[NSNumber numberWithBool: YES] retain];
|
||||
[[NSObject leakAt: &boolY] release];
|
||||
}
|
||||
|
||||
/* Initialize the date class last as it has external dependencies on
|
||||
* time zone data.
|
||||
*/
|
||||
if (Nil == NSDateClass)
|
||||
{
|
||||
NSDateClass = [NSDate class];
|
||||
}
|
||||
|
||||
classInitialized = YES;
|
||||
}
|
||||
|
||||
+ (NSData*) dataFromPropertyList: (id)aPropertyList
|
||||
|
|
Loading…
Reference in a new issue