mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-25 17:51:01 +00:00
Make handling of accumulated text in 'value' clearer.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@28436 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ec72fa58ba
commit
1d27f3f372
1 changed files with 16 additions and 33 deletions
|
@ -81,6 +81,8 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
||||||
NSString *key;
|
NSString *key;
|
||||||
BOOL inArray;
|
BOOL inArray;
|
||||||
BOOL inDictionary;
|
BOOL inDictionary;
|
||||||
|
BOOL parsed;
|
||||||
|
BOOL success;
|
||||||
id plist;
|
id plist;
|
||||||
NSPropertyListMutabilityOptions opts;
|
NSPropertyListMutabilityOptions opts;
|
||||||
}
|
}
|
||||||
|
@ -119,7 +121,6 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
||||||
{
|
{
|
||||||
if ((self = [super init]) != nil)
|
if ((self = [super init]) != nil)
|
||||||
{
|
{
|
||||||
stack = [[NSMutableArray alloc] initWithCapacity: 10];
|
|
||||||
theParser = [[GSSloppyXMLParser alloc] initWithData: data];
|
theParser = [[GSSloppyXMLParser alloc] initWithData: data];
|
||||||
[theParser setDelegate: self];
|
[theParser setDelegate: self];
|
||||||
opts = options;
|
opts = options;
|
||||||
|
@ -133,10 +134,6 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
||||||
string = [string stringByTrimmingSpaces];
|
string = [string stringByTrimmingSpaces];
|
||||||
if ([string length] > 0)
|
if ([string length] > 0)
|
||||||
{
|
{
|
||||||
if (value == nil)
|
|
||||||
{
|
|
||||||
value = [[NSMutableString alloc] initWithCapacity: 50];
|
|
||||||
}
|
|
||||||
[value appendString: string];
|
[value appendString: string];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -233,15 +230,8 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
||||||
}
|
}
|
||||||
else if ([elementName isEqualToString: @"key"] == YES)
|
else if ([elementName isEqualToString: @"key"] == YES)
|
||||||
{
|
{
|
||||||
if (value == nil)
|
ASSIGNCOPY(key, value);
|
||||||
{
|
[value setString: @""];
|
||||||
ASSIGN(key, @""); // Empty key.
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ASSIGN(key, [value makeImmutableCopyOnFail: NO]);
|
|
||||||
DESTROY(value);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if ([elementName isEqualToString: @"data"])
|
else if ([elementName isEqualToString: @"data"])
|
||||||
|
@ -283,25 +273,11 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
||||||
|
|
||||||
if (opts == NSPropertyListMutableContainersAndLeaves)
|
if (opts == NSPropertyListMutableContainersAndLeaves)
|
||||||
{
|
{
|
||||||
if (value == nil)
|
o = [value mutableCopy];
|
||||||
{
|
|
||||||
o = [NSMutableString string];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
o = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (value == nil)
|
o = [value copy];
|
||||||
{
|
|
||||||
o = @"";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
o = [value makeImmutableCopyOnFail: NO];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ASSIGN(plist, o);
|
ASSIGN(plist, o);
|
||||||
}
|
}
|
||||||
|
@ -323,7 +299,7 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
||||||
}
|
}
|
||||||
else if ([elementName isEqualToString: @"plist"])
|
else if ([elementName isEqualToString: @"plist"])
|
||||||
{
|
{
|
||||||
DESTROY(value);
|
[value setString: @""];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else // invalid tag
|
else // invalid tag
|
||||||
|
@ -347,12 +323,19 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*);
|
||||||
[(NSMutableDictionary*)[stack lastObject] setObject: plist forKey: key];
|
[(NSMutableDictionary*)[stack lastObject] setObject: plist forKey: key];
|
||||||
DESTROY(key);
|
DESTROY(key);
|
||||||
}
|
}
|
||||||
DESTROY(value);
|
[value setString: @""];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) parse
|
- (BOOL) parse
|
||||||
{
|
{
|
||||||
return [theParser parse];
|
if (parsed == NO)
|
||||||
|
{
|
||||||
|
parsed = YES;
|
||||||
|
stack = [[NSMutableArray alloc] initWithCapacity: 10];
|
||||||
|
value = [[NSMutableString alloc] initWithCapacity: 50];
|
||||||
|
success = [theParser parse];
|
||||||
|
}
|
||||||
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) result
|
- (id) result
|
||||||
|
|
Loading…
Reference in a new issue