Make sure code passes testsuite

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34456 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2012-01-07 13:08:03 +00:00
parent 6e979028e7
commit 1c23e5145d
5 changed files with 87 additions and 33 deletions

View file

@ -57,6 +57,10 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
{
if (GS_EXISTS_INTERNAL)
{
while (internal->childCount > 0)
{
[self removeChildAtIndex: internal->childCount - 1];
}
[internal->encoding release];
[internal->version release];
[internal->docType release];
@ -218,15 +222,18 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
- (void) setRootElement: (NSXMLNode*)root
{
NSArray *children;
if (nil != root)
{
NSArray *children;
NSAssert(internal->rootElement == nil, NSGenericException);
/* this method replaces *all* children with the specified element.
*/
children = [[NSArray alloc] initWithObjects: &root count: 1];
[self setChildren: children];
[children release];
internal->rootElement = (NSXMLElement*)root;
NSAssert(internal->rootElement == nil, NSGenericException);
/* this method replaces *all* children with the specified element.
*/
children = [[NSArray alloc] initWithObjects: &root count: 1];
[self setChildren: children];
[children release];
internal->rootElement = (NSXMLElement*)root;
}
}
- (void) setStandalone: (BOOL)standalone
@ -427,10 +434,23 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
- (id) copyWithZone: (NSZone *)zone
{
NSXMLDocument *c = (NSXMLDocument*)[super copyWithZone: zone];
NSXMLElement *r = [self rootElement];
NSEnumerator *en;
id obj;
[c setStandalone: internal->standalone];
[c setChildren: internal->children];
GSIVar(c, rootElement) = internal->rootElement;
en = [internal->children objectEnumerator];
while ((obj = [en nextObject]) != nil)
{
NSXMLNode *child = [obj copyWithZone: zone];
if ([child isEqual: r])
{
GSIVar(c, rootElement) = (NSXMLElement*)child;
}
[c addChild: child];
[child release];
}
[c setDTD: internal->docType];
[c setMIMEType: internal->MIMEType];
return c;