mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
* Source/NSXMLNode.m (-copyWithZone_): Use value 1 instead of 2
for deep copy. Bug found by Doug Simons <doug.simons@testplant.com>. * Source/NSXMLNode.m (-rootDocument): Don't return the private document. * Source/NSXMLNode.m (-nextSibling, -previousSibling): Protect against namspace nodes. * Tests/base/NSXMLNode/transfer.m: New test case for problem reported by Doug Simons. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34988 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
887362645d
commit
511ebc6580
3 changed files with 72 additions and 4 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2012-03-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSXMLNode.m (-copyWithZone_): Use value 1 instead of 2
|
||||
for deep copy. Bug found by Doug Simons <doug.simons@testplant.com>.
|
||||
* Source/NSXMLNode.m (-rootDocument): Don't return the private document.
|
||||
* Source/NSXMLNode.m (-nextSibling, -previousSibling): Protect
|
||||
against namspace nodes.
|
||||
* Tests/base/NSXMLNode/transfer.m: New test case for problem
|
||||
reported by Doug Simons.
|
||||
|
||||
2012-03-22 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSXMLElement.m,
|
||||
|
|
|
@ -1147,7 +1147,7 @@ execute_xpath(NSXMLNode *xmlNode, NSString *xpath_exp, NSString *nmspaces)
|
|||
- (id) copyWithZone: (NSZone*)zone
|
||||
{
|
||||
NSXMLNode *c = [[self class] allocWithZone: zone];
|
||||
xmlNodePtr newNode = xmlCopyNode([self _node], 2); // make a deep copy
|
||||
xmlNodePtr newNode = xmlCopyNode([self _node], 1); // make a deep copy
|
||||
clearPrivatePointers(newNode);
|
||||
|
||||
c = [c _initWithNode: newNode kind: internal->kind];
|
||||
|
@ -1591,7 +1591,17 @@ execute_xpath(NSXMLNode *xmlNode, NSString *xpath_exp, NSString *nmspaces)
|
|||
|
||||
- (NSXMLNode*) nextSibling
|
||||
{
|
||||
return [NSXMLNode _objectForNode: internal->node->next];
|
||||
xmlNodePtr node = internal->node;
|
||||
|
||||
if (NULL == node)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
if (XML_NAMESPACE_DECL == node->type)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return [NSXMLNode _objectForNode: node->next];
|
||||
}
|
||||
|
||||
- (id) objectValue
|
||||
|
@ -1648,13 +1658,40 @@ execute_xpath(NSXMLNode *xmlNode, NSString *xpath_exp, NSString *nmspaces)
|
|||
|
||||
- (NSXMLNode*) previousSibling
|
||||
{
|
||||
return [NSXMLNode _objectForNode: internal->node->prev];
|
||||
xmlNodePtr node = internal->node;
|
||||
|
||||
if (NULL == node)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
if (XML_NAMESPACE_DECL == node->type)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
return [NSXMLNode _objectForNode: node->prev];
|
||||
}
|
||||
|
||||
- (NSXMLDocument*) rootDocument
|
||||
{
|
||||
xmlNodePtr node = internal->node;
|
||||
|
||||
if (NULL == node)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
if (XML_NAMESPACE_DECL == node->type)
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
if (NULL == node->parent)
|
||||
{
|
||||
// This is a standalone node, we still may have a private document,
|
||||
// but we don't want to return this.
|
||||
return nil;
|
||||
}
|
||||
|
||||
return
|
||||
(NSXMLDocument *)[NSXMLNode _objectForNode: (xmlNodePtr)(internal->node->doc)];
|
||||
(NSXMLDocument *)[NSXMLNode _objectForNode: (xmlNodePtr)(node->doc)];
|
||||
}
|
||||
|
||||
- (NSString*) stringValue
|
||||
|
|
21
Tests/base/NSXMLElement/transfer.m
Normal file
21
Tests/base/NSXMLElement/transfer.m
Normal file
|
@ -0,0 +1,21 @@
|
|||
#import "ObjectTesting.h"
|
||||
#import <Foundation/NSAutoreleasePool.h>
|
||||
#import <Foundation/NSXMLDocument.h>
|
||||
#import <Foundation/NSXMLElement.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
NSAutoreleasePool *arp = [NSAutoreleasePool new];
|
||||
NSXMLElement *elem1 = [[NSXMLElement alloc] initWithXMLString: @"<num>6</num>" error: NULL];
|
||||
NSXMLElement *elem2 = [[NSXMLElement alloc] initWithXMLString: @"<num>7</num>" error: NULL];
|
||||
NSXMLElement *copy1 = [elem1 copy];
|
||||
NSXMLElement *copy2 = [elem2 copy];
|
||||
|
||||
[copy1 setStringValue: @"7"];
|
||||
PASS_EQUAL(copy1, copy2, "equal after setStringValue:");
|
||||
|
||||
[arp drain];
|
||||
arp = nil;
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue