* Source/NSXMLDocument.m:

* Source/NSXMLDTD.m:
* Source/NSXMLNode.m:
* Source/NSXMLDTDNode.m:
* Source/NSXMLElement.m: Remove compiler warnings for clang
reported by David Chisnall.
* Tests/base/NSAutoreleasePool/basic.m: Get to compile again
without -C99.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35043 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2012-04-06 22:27:55 +00:00
parent 4bc62f73ee
commit 9629278d59
7 changed files with 320 additions and 299 deletions

View file

@ -1,3 +1,14 @@
2012-04-07 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSXMLDocument.m:
* Source/NSXMLDTD.m:
* Source/NSXMLNode.m:
* Source/NSXMLDTDNode.m:
* Source/NSXMLElement.m: Remove compiler warnings for clang
reported by David Chisnall.
* Tests/base/NSAutoreleasePool/basic.m: Get to compile again
without -C99.
2012-04-06 12:37 theraven 2012-04-06 12:37 theraven
* libs/base/trunk/Source/NSConnection.m, * libs/base/trunk/Source/NSConnection.m,

View file

@ -57,18 +57,18 @@ GS_PRIVATE_INTERNAL(NSXMLDTD)
- (NSXMLDTDNode*) attributeDeclarationForName: (NSString*)name - (NSXMLDTDNode*) attributeDeclarationForName: (NSString*)name
elementName: (NSString*)elementName elementName: (NSString*)elementName
{ {
xmlDtdPtr node = internal->node; xmlDtdPtr theNode = internal->node;
xmlNodePtr children = NULL; xmlNodePtr children = NULL;
const xmlChar *xmlName = XMLSTRING(name); const xmlChar *xmlName = XMLSTRING(name);
const xmlChar *xmlElementName = XMLSTRING(elementName); const xmlChar *xmlElementName = XMLSTRING(elementName);
if ((node == NULL) || if ((theNode == NULL) ||
(node->children == NULL)) (theNode->children == NULL))
{ {
return nil; return nil;
} }
for (children = node->children; children; children = children->next) for (children = theNode->children; children; children = children->next)
{ {
if (children->type == XML_ATTRIBUTE_DECL) if (children->type == XML_ATTRIBUTE_DECL)
{ {
@ -87,17 +87,17 @@ GS_PRIVATE_INTERNAL(NSXMLDTD)
- (NSXMLDTDNode*) elementDeclarationForName: (NSString*)name - (NSXMLDTDNode*) elementDeclarationForName: (NSString*)name
{ {
xmlDtdPtr node = internal->node; xmlDtdPtr theNode = internal->node;
xmlNodePtr children = NULL; xmlNodePtr children = NULL;
const xmlChar *xmlName = XMLSTRING(name); const xmlChar *xmlName = XMLSTRING(name);
if ((node == NULL) || if ((theNode == NULL) ||
(node->children == NULL)) (theNode->children == NULL))
{ {
return nil; return nil;
} }
for (children = node->children; children; children = children->next) for (children = theNode->children; children; children = children->next)
{ {
if (children->type == XML_ELEMENT_DECL) if (children->type == XML_ELEMENT_DECL)
{ {
@ -116,17 +116,17 @@ GS_PRIVATE_INTERNAL(NSXMLDTD)
- (NSXMLDTDNode*) entityDeclarationForName: (NSString*)name - (NSXMLDTDNode*) entityDeclarationForName: (NSString*)name
{ {
//xmlGetEntityFromDtd //xmlGetEntityFromDtd
xmlDtdPtr node = internal->node; xmlDtdPtr theNode = internal->node;
xmlNodePtr children = NULL; xmlNodePtr children = NULL;
const xmlChar *xmlName = XMLSTRING(name); const xmlChar *xmlName = XMLSTRING(name);
if ((node == NULL) || if ((theNode == NULL) ||
(node->children == NULL)) (theNode->children == NULL))
{ {
return nil; return nil;
} }
for (children = node->children; children; children = children->next) for (children = theNode->children; children; children = children->next)
{ {
if (children->type == XML_ENTITY_DECL) if (children->type == XML_ENTITY_DECL)
{ {
@ -192,36 +192,38 @@ GS_PRIVATE_INTERNAL(NSXMLDTD)
return self; return self;
} }
- (id) initWithKind: (NSXMLNodeKind)kind options: (NSUInteger)theOptions - (id) initWithKind: (NSXMLNodeKind)theKind options: (NSUInteger)theOptions
{ {
if (NSXMLDTDKind == kind) if (NSXMLDTDKind == theKind)
{ {
return [super initWithKind: kind options: theOptions]; return [super initWithKind: theKind options: theOptions];
} }
else else
{ {
[self release]; [self release];
return [[NSXMLNode alloc] initWithKind: kind // This cast is here to keep clang quite that expects an init* method to
options: theOptions]; // return an object of the same class, which is not true here.
return (NSXMLDTD*)[[NSXMLNode alloc] initWithKind: theKind
options: theOptions];
} }
} }
- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index - (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index
{ {
NSXMLNodeKind kind = [child kind]; NSXMLNodeKind theKind = [child kind];
NSUInteger childCount = [self childCount]; NSUInteger childCount = [self childCount];
// Check to make sure this is a valid addition... // Check to make sure this is a valid addition...
NSAssert(nil != child, NSInvalidArgumentException); NSAssert(nil != child, NSInvalidArgumentException);
NSAssert(index <= childCount, NSInvalidArgumentException); NSAssert(index <= childCount, NSInvalidArgumentException);
NSAssert(nil == [child parent], NSInvalidArgumentException); NSAssert(nil == [child parent], NSInvalidArgumentException);
NSAssert(NSXMLAttributeKind != kind, NSInvalidArgumentException); NSAssert(NSXMLAttributeKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLDTDKind != kind, NSInvalidArgumentException); NSAssert(NSXMLDTDKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLDocumentKind != kind, NSInvalidArgumentException); NSAssert(NSXMLDocumentKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLElementKind != kind, NSInvalidArgumentException); NSAssert(NSXMLElementKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLInvalidKind != kind, NSInvalidArgumentException); NSAssert(NSXMLInvalidKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLNamespaceKind != kind, NSInvalidArgumentException); NSAssert(NSXMLNamespaceKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLTextKind != kind, NSInvalidArgumentException); NSAssert(NSXMLTextKind != theKind, NSInvalidArgumentException);
[self _insertChild: child atIndex: index]; [self _insertChild: child atIndex: index];
} }
@ -239,17 +241,17 @@ GS_PRIVATE_INTERNAL(NSXMLDTD)
- (NSXMLDTDNode*) notationDeclarationForName: (NSString*)name - (NSXMLDTDNode*) notationDeclarationForName: (NSString*)name
{ {
xmlDtdPtr node = internal->node; xmlDtdPtr theNode = internal->node;
xmlNodePtr children = NULL; xmlNodePtr children = NULL;
const xmlChar *xmlName = XMLSTRING(name); const xmlChar *xmlName = XMLSTRING(name);
if ((node == NULL) || if ((theNode == NULL) ||
(node->children == NULL)) (theNode->children == NULL))
{ {
return nil; return nil;
} }
for (children = node->children; children; children = children->next) for (children = theNode->children; children; children = children->next)
{ {
if (children->type == XML_NOTATION_NODE) if (children->type == XML_NOTATION_NODE)
{ {
@ -265,9 +267,9 @@ GS_PRIVATE_INTERNAL(NSXMLDTD)
- (NSString*) publicID - (NSString*) publicID
{ {
xmlDtd *node = internal->node; xmlDtd *theNode = internal->node;
return StringFromXMLStringPtr(node->ExternalID); return StringFromXMLStringPtr(theNode->ExternalID);
} }
- (void) removeChildAtIndex: (NSUInteger)index - (void) removeChildAtIndex: (NSUInteger)index
@ -284,9 +286,9 @@ GS_PRIVATE_INTERNAL(NSXMLDTD)
[child detach]; [child detach];
} }
- (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)node - (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)theNode
{ {
[self insertChild: node atIndex: index]; [self insertChild: theNode atIndex: index];
[self removeChildAtIndex: index + 1]; [self removeChildAtIndex: index + 1];
} }
@ -304,23 +306,23 @@ GS_PRIVATE_INTERNAL(NSXMLDTD)
- (void) setPublicID: (NSString*)publicID - (void) setPublicID: (NSString*)publicID
{ {
xmlDtd *node = internal->node; xmlDtd *theNode = internal->node;
node->ExternalID = XMLStringCopy(publicID); theNode->ExternalID = XMLStringCopy(publicID);
} }
- (void) setSystemID: (NSString*)systemID - (void) setSystemID: (NSString*)systemID
{ {
xmlDtd *node = internal->node; xmlDtd *theNode = internal->node;
node->SystemID = XMLStringCopy(systemID); theNode->SystemID = XMLStringCopy(systemID);
} }
- (NSString*) systemID - (NSString*) systemID
{ {
xmlDtd *node = internal->node; xmlDtd *theNode = internal->node;
return StringFromXMLStringPtr(node->SystemID); return StringFromXMLStringPtr(theNode->SystemID);
} }
@end @end

View file

@ -53,19 +53,21 @@ GS_PRIVATE_INTERNAL(NSXMLDTDNode)
GS_CREATE_INTERNAL(NSXMLDTDNode); GS_CREATE_INTERNAL(NSXMLDTDNode);
} }
- (id) initWithKind: (NSXMLNodeKind)kind options: (NSUInteger)theOptions - (id) initWithKind: (NSXMLNodeKind)theKind options: (NSUInteger)theOptions
{ {
if (NSXMLEntityDeclarationKind == kind if (NSXMLEntityDeclarationKind == theKind
|| NSXMLElementDeclarationKind == kind || NSXMLElementDeclarationKind == theKind
|| NSXMLNotationDeclarationKind == kind) || NSXMLNotationDeclarationKind == theKind)
{ {
return [super initWithKind: kind options: theOptions]; return [super initWithKind: theKind options: theOptions];
} }
else else
{ {
[self release]; [self release];
return [[NSXMLNode alloc] initWithKind: kind // This cast is here to keep clang quite that expects an init* method to
options: theOptions]; // return an object of the same class, which is not true here.
return (NSXMLDTDNode*)[[NSXMLNode alloc] initWithKind: theKind
options: theOptions];
} }
} }
@ -79,7 +81,7 @@ GS_PRIVATE_INTERNAL(NSXMLDTDNode)
error: &error]; error: &error];
if (tempDoc != nil) if (tempDoc != nil)
{ {
result = RETAIN([tempDoc childAtIndex: 0]); result = (NSXMLDTDNode*)RETAIN([tempDoc childAtIndex: 0]);
[result detach]; // detach from document. [result detach]; // detach from document.
} }
[tempDoc release]; [tempDoc release];

View file

@ -120,16 +120,16 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
{ {
char *url = NULL; char *url = NULL;
char *encoding = NULL; // "UTF8"; char *encoding = NULL; // "UTF8";
int options = XML_PARSE_NOERROR; int xmlOptions = XML_PARSE_NOERROR;
xmlDocPtr doc = NULL; xmlDocPtr doc = NULL;
if (!(mask & NSXMLNodePreserveWhitespace)) if (!(mask & NSXMLNodePreserveWhitespace))
{ {
options |= XML_PARSE_NOBLANKS; xmlOptions |= XML_PARSE_NOBLANKS;
//xmlKeepBlanksDefault(0); //xmlKeepBlanksDefault(0);
} }
doc = xmlReadMemory([data bytes], [data length], doc = xmlReadMemory([data bytes], [data length],
url, encoding, options); url, encoding, xmlOptions);
if (doc == NULL) if (doc == NULL)
{ {
DESTROY(self); DESTROY(self);
@ -155,17 +155,19 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
return self; return self;
} }
- (id) initWithKind: (NSXMLNodeKind)kind options: (NSUInteger)theOptions - (id) initWithKind: (NSXMLNodeKind)theKind options: (NSUInteger)theOptions
{ {
if (NSXMLDocumentKind == kind) if (NSXMLDocumentKind == theKind)
{ {
return [super initWithKind: kind options: theOptions]; return [super initWithKind: theKind options: theOptions];
} }
else else
{ {
[self release]; [self release];
return [[NSXMLNode alloc] initWithKind: kind // This cast is here to keep clang quite that expects an init* method to
options: theOptions]; // return an object of the same class, which is not true here.
return (NSXMLDocument*)[[NSXMLNode alloc] initWithKind: theKind
options: theOptions];
} }
} }
@ -227,9 +229,9 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
internal->node->encoding = XMLStringCopy(encoding); internal->node->encoding = XMLStringCopy(encoding);
} }
- (void) setDocumentContentKind: (NSXMLDocumentContentKind)kind - (void) setDocumentContentKind: (NSXMLDocumentContentKind)theContentKind
{ {
internal->contentKind = kind; internal->contentKind = theContentKind;
} }
- (void) setDTD: (NSXMLDTD*)documentTypeDeclaration - (void) setDTD: (NSXMLDTD*)documentTypeDeclaration
@ -246,9 +248,9 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
[self addChild: documentTypeDeclaration]; [self addChild: documentTypeDeclaration];
} }
- (void) setMIMEType: (NSString*)MIMEType - (void) setMIMEType: (NSString*)theMIMEType
{ {
ASSIGNCOPY(internal->MIMEType, MIMEType); ASSIGNCOPY(internal->MIMEType, theMIMEType);
} }
- (void) setRootElement: (NSXMLNode*)root - (void) setRootElement: (NSXMLNode*)root
@ -282,22 +284,22 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
- (void) setURI: (NSString*)URI - (void) setURI: (NSString*)URI
{ {
xmlDocPtr node = internal->node; xmlDocPtr theNode = internal->node;
if (node->URL != NULL) if (theNode->URL != NULL)
{ {
xmlFree((xmlChar *)node->URL); xmlFree((xmlChar *)theNode->URL);
} }
node->URL = XMLStringCopy(URI); theNode->URL = XMLStringCopy(URI);
} }
- (NSString*) URI - (NSString*) URI
{ {
xmlDocPtr node = internal->node; xmlDocPtr theNode = internal->node;
if (node->URL) if (theNode->URL)
{ {
return StringFromXMLStringPtr(node->URL); return StringFromXMLStringPtr(theNode->URL);
} }
else else
{ {
@ -309,13 +311,13 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
{ {
if ([version isEqualToString: @"1.0"] || [version isEqualToString: @"1.1"]) if ([version isEqualToString: @"1.0"] || [version isEqualToString: @"1.1"])
{ {
xmlDocPtr node = internal->node; xmlDocPtr theNode = internal->node;
if (node->version != NULL) if (theNode->version != NULL)
{ {
xmlFree((xmlChar *)node->version); xmlFree((xmlChar *)theNode->version);
} }
node->version = XMLStringCopy(version); theNode->version = XMLStringCopy(version);
} }
else else
{ {
@ -326,32 +328,31 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
- (NSString*) version - (NSString*) version
{ {
xmlDocPtr node = internal->node; xmlDocPtr theNode = internal->node;
if (node->version) if (theNode->version)
return StringFromXMLStringPtr(node->version); return StringFromXMLStringPtr(theNode->version);
else else
return @"1.0"; return @"1.0";
} }
- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index - (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index
{ {
NSXMLNodeKind kind = [child kind]; NSXMLNodeKind theKind = [child kind];
NSUInteger childCount = [self childCount]; NSUInteger childCount = [self childCount];
// Check to make sure this is a valid addition... // Check to make sure this is a valid addition...
NSAssert(nil != child, NSInvalidArgumentException); NSAssert(nil != child, NSInvalidArgumentException);
NSAssert(index <= childCount, NSInvalidArgumentException); NSAssert(index <= childCount, NSInvalidArgumentException);
NSAssert(nil == [child parent], NSInvalidArgumentException); NSAssert(nil == [child parent], NSInvalidArgumentException);
kind = [child kind]; NSAssert(NSXMLAttributeKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLAttributeKind != kind, NSInvalidArgumentException); NSAssert(NSXMLDTDKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLDTDKind != kind, NSInvalidArgumentException); NSAssert(NSXMLDocumentKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLDocumentKind != kind, NSInvalidArgumentException); NSAssert(NSXMLElementDeclarationKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLElementDeclarationKind != kind, NSInvalidArgumentException); NSAssert(NSXMLEntityDeclarationKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLEntityDeclarationKind != kind, NSInvalidArgumentException); NSAssert(NSXMLInvalidKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLInvalidKind != kind, NSInvalidArgumentException); NSAssert(NSXMLNamespaceKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLNamespaceKind != kind, NSInvalidArgumentException); NSAssert(NSXMLNotationDeclarationKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLNotationDeclarationKind != kind, NSInvalidArgumentException);
[self _insertChild: child atIndex: index]; [self _insertChild: child atIndex: index];
} }
@ -398,9 +399,9 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
[self insertChild: child atIndex: [self childCount]]; [self insertChild: child atIndex: [self childCount]];
} }
- (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)node - (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)theNode
{ {
[self insertChild: node atIndex: index]; [self insertChild: theNode atIndex: index];
[self removeChildAtIndex: index + 1]; [self removeChildAtIndex: index + 1];
} }
@ -409,9 +410,9 @@ GS_PRIVATE_INTERNAL(NSXMLDocument)
return [self XMLDataWithOptions: NSXMLNodeOptionsNone]; return [self XMLDataWithOptions: NSXMLNodeOptionsNone];
} }
- (NSData *) XMLDataWithOptions: (NSUInteger)options - (NSData *) XMLDataWithOptions: (NSUInteger)theOptions
{ {
NSString *xmlString = [self XMLStringWithOptions: options]; NSString *xmlString = [self XMLStringWithOptions: theOptions];
return [xmlString dataUsingEncoding: NSUTF8StringEncoding return [xmlString dataUsingEncoding: NSUTF8StringEncoding
allowLossyConversion: NO]; allowLossyConversion: NO];

View file

@ -70,17 +70,19 @@ extern void ensure_oldNs(xmlNodePtr node);
return [self initWithKind: NSXMLElementKind options: 0]; return [self initWithKind: NSXMLElementKind options: 0];
} }
- (id) initWithKind: (NSXMLNodeKind)kind options: (NSUInteger)theOptions - (id) initWithKind: (NSXMLNodeKind)theKind options: (NSUInteger)theOptions
{ {
if (NSXMLElementKind == kind) if (NSXMLElementKind == theKind)
{ {
return [super initWithKind: kind options: theOptions]; return [super initWithKind: theKind options: theOptions];
} }
else else
{ {
[self release]; [self release];
return [[NSXMLNode alloc] initWithKind: kind // This cast is here to keep clang quite that expects an init* method to
options: theOptions]; // return an object of the same class, which is not true here.
return (NSXMLElement*)[[NSXMLNode alloc] initWithKind: theKind
options: theOptions];
} }
} }
@ -176,8 +178,8 @@ extern void ensure_oldNs(xmlNodePtr node);
((cur->ns == NULL) || (cur->ns->prefix == NULL) || ((cur->ns == NULL) || (cur->ns->prefix == NULL) ||
(xmlStrcmp(cur->ns->prefix, (const xmlChar*)"") == 0))) (xmlStrcmp(cur->ns->prefix, (const xmlChar*)"") == 0)))
{ {
NSXMLNode *node = [NSXMLNode _objectForNode: cur]; NSXMLNode *theNode = [NSXMLNode _objectForNode: cur];
[results addObject: node]; [results addObject: theNode];
} }
} }
} }
@ -214,8 +216,8 @@ extern void ensure_oldNs(xmlNodePtr node);
(xmlStrcmp(childNS->prefix, (const xmlChar*)"") == 0)))) || (xmlStrcmp(childNS->prefix, (const xmlChar*)"") == 0)))) ||
((cur->ns != NULL) && (xmlStrcmp(cur->ns->href, href) == 0))) ((cur->ns != NULL) && (xmlStrcmp(cur->ns->href, href) == 0)))
{ {
NSXMLNode *node = [NSXMLNode _objectForNode: cur]; NSXMLNode *theNode = [NSXMLNode _objectForNode: cur];
[results addObject: node]; [results addObject: theNode];
} }
} }
} }
@ -226,7 +228,7 @@ extern void ensure_oldNs(xmlNodePtr node);
- (void) addAttribute: (NSXMLNode*)attribute - (void) addAttribute: (NSXMLNode*)attribute
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
xmlAttrPtr attr = (xmlAttrPtr)[attribute _node]; xmlAttrPtr attr = (xmlAttrPtr)[attribute _node];
xmlAttrPtr oldAttr; xmlAttrPtr oldAttr;
@ -244,7 +246,7 @@ extern void ensure_oldNs(xmlNodePtr node);
if (ns->href == NULL) if (ns->href == NULL)
{ {
xmlNsPtr newNs = xmlSearchNs(node->doc, node, ns->prefix); xmlNsPtr newNs = xmlSearchNs(theNode->doc, theNode, ns->prefix);
if (newNs != NULL) if (newNs != NULL)
{ {
@ -255,7 +257,7 @@ extern void ensure_oldNs(xmlNodePtr node);
} }
else //if (ns->prefix == NULL) else //if (ns->prefix == NULL)
{ {
xmlNsPtr newNs = xmlSearchNsByHref(node->doc, node, ns->href); xmlNsPtr newNs = xmlSearchNsByHref(theNode->doc, theNode, ns->href);
if (newNs != NULL) if (newNs != NULL)
{ {
@ -292,8 +294,8 @@ extern void ensure_oldNs(xmlNodePtr node);
} }
// Insert in new // Insert in new
ensure_oldNs(node); ensure_oldNs(theNode);
oldNs1 = node->doc->oldNs; oldNs1 = theNode->doc->oldNs;
while (oldNs1) while (oldNs1)
{ {
if (oldNs1->next == NULL) if (oldNs1->next == NULL)
@ -307,17 +309,17 @@ extern void ensure_oldNs(xmlNodePtr node);
#if LIBXML_VERSION >= 20620 #if LIBXML_VERSION >= 20620
xmlDOMWrapAdoptNode(NULL, attr->doc, (xmlNodePtr)attr, xmlDOMWrapAdoptNode(NULL, attr->doc, (xmlNodePtr)attr,
node->doc, node, 0); theNode->doc, theNode, 0);
#else #else
xmlSetTreeDoc((xmlNodePtr)attr, node->doc); xmlSetTreeDoc((xmlNodePtr)attr, theNode->doc);
#endif #endif
xmlFreeDoc(tmp); xmlFreeDoc(tmp);
oldAttr = xmlHasNsProp(node, attr->name, ns->href); oldAttr = xmlHasNsProp(theNode, attr->name, ns->href);
} }
else else
{ {
oldAttr = xmlHasProp(node, attr->name); oldAttr = xmlHasProp(theNode, attr->name);
} }
if (NULL != oldAttr) if (NULL != oldAttr)
@ -344,7 +346,7 @@ extern void ensure_oldNs(xmlNodePtr node);
} }
} }
} }
xmlAddChild(node, (xmlNodePtr)attr); xmlAddChild(theNode, (xmlNodePtr)attr);
[self _addSubNode: attribute]; [self _addSubNode: attribute];
} }
@ -390,8 +392,8 @@ extern void ensure_oldNs(xmlNodePtr node);
- (NSArray*) attributes - (NSArray*) attributes
{ {
NSMutableArray *attributes = [NSMutableArray array]; NSMutableArray *attributes = [NSMutableArray array];
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
xmlAttrPtr attributeNode = node->properties; xmlAttrPtr attributeNode = theNode->properties;
while (attributeNode) while (attributeNode)
{ {
@ -423,8 +425,8 @@ extern void ensure_oldNs(xmlNodePtr node);
{ {
NSXMLNode *result = nil; NSXMLNode *result = nil;
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
xmlAttrPtr attributeNode = xmlHasProp(node, XMLSTRING(name)); xmlAttrPtr attributeNode = xmlHasProp(theNode, XMLSTRING(name));
if (NULL != attributeNode) if (NULL != attributeNode)
{ {
@ -439,8 +441,8 @@ extern void ensure_oldNs(xmlNodePtr node);
URI: (NSString*)URI URI: (NSString*)URI
{ {
NSXMLNode *result = nil; NSXMLNode *result = nil;
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
xmlAttrPtr attributeNode = xmlHasNsProp(node, XMLSTRING(localName), xmlAttrPtr attributeNode = xmlHasNsProp(theNode, XMLSTRING(localName),
XMLSTRING(URI)); XMLSTRING(URI));
if (NULL != attributeNode) if (NULL != attributeNode)
@ -454,16 +456,16 @@ extern void ensure_oldNs(xmlNodePtr node);
- (void) addNamespace: (NSXMLNode*)aNamespace - (void) addNamespace: (NSXMLNode*)aNamespace
{ {
xmlNsPtr ns = xmlCopyNamespace((xmlNsPtr)[aNamespace _node]); xmlNsPtr ns = xmlCopyNamespace((xmlNsPtr)[aNamespace _node]);
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
const xmlChar *prefix = ns->prefix; const xmlChar *prefix = ns->prefix;
if (node->nsDef == NULL) if (theNode->nsDef == NULL)
{ {
node->nsDef = ns; theNode->nsDef = ns;
} }
else else
{ {
xmlNsPtr cur = node->nsDef; xmlNsPtr cur = theNode->nsDef;
xmlNsPtr last = NULL; xmlNsPtr last = NULL;
while (cur != NULL) while (cur != NULL)
@ -487,13 +489,13 @@ extern void ensure_oldNs(xmlNodePtr node);
if (cur->href == NULL) if (cur->href == NULL)
{ {
// This was a fake namespace we added // This was a fake namespace we added
if (node->ns == cur) if (theNode->ns == cur)
{ {
node->ns = ns; theNode->ns = ns;
} }
if (last == NULL) if (last == NULL)
{ {
node->nsDef = ns; theNode->nsDef = ns;
} }
else else
{ {
@ -505,22 +507,22 @@ extern void ensure_oldNs(xmlNodePtr node);
} }
// Are we setting a default namespace? // Are we setting a default namespace?
if ((node->ns == NULL) && (xmlStrcmp(prefix, (const xmlChar*)"") == 0)) if ((theNode->ns == NULL) && (xmlStrcmp(prefix, (const xmlChar*)"") == 0))
{ {
node->ns = ns; theNode->ns = ns;
} }
// Need to replace fake namespaces in subnodes // Need to replace fake namespaces in subnodes
cleanup_namespaces(node, ns); cleanup_namespaces(theNode, ns);
} }
- (void) removeNamespaceForPrefix: (NSString*)name - (void) removeNamespaceForPrefix: (NSString*)name
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (node->nsDef != NULL) if (theNode->nsDef != NULL)
{ {
xmlNsPtr cur = node->nsDef; xmlNsPtr cur = theNode->nsDef;
xmlNsPtr last = NULL; xmlNsPtr last = NULL;
const xmlChar *prefix = XMLSTRING(name); const xmlChar *prefix = XMLSTRING(name);
@ -538,9 +540,9 @@ extern void ensure_oldNs(xmlNodePtr node);
last->next = cur->next; last->next = cur->next;
} }
cur->next = NULL; cur->next = NULL;
if (node->ns == cur) if (theNode->ns == cur)
{ {
node->ns = NULL; theNode->ns = NULL;
} }
xmlFreeNs(cur); xmlFreeNs(cur);
return; return;
@ -593,14 +595,14 @@ extern void ensure_oldNs(xmlNodePtr node);
if (name != nil) if (name != nil)
{ {
const xmlChar *prefix = XMLSTRING(name); const xmlChar *prefix = XMLSTRING(name);
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
xmlNsPtr ns; xmlNsPtr ns;
ns = xmlSearchNs(node->doc, node, prefix); ns = xmlSearchNs(theNode->doc, theNode, prefix);
if ((ns == NULL) && ([name length] == 0)) if ((ns == NULL) && ([name length] == 0))
{ {
prefix = NULL; prefix = NULL;
ns = xmlSearchNs(node->doc, node, prefix); ns = xmlSearchNs(theNode->doc, theNode, prefix);
} }
if (ns != NULL) if (ns != NULL)
@ -640,21 +642,21 @@ extern void ensure_oldNs(xmlNodePtr node);
- (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index - (void) insertChild: (NSXMLNode*)child atIndex: (NSUInteger)index
{ {
NSXMLNodeKind kind = [child kind]; NSXMLNodeKind theKind = [child kind];
NSUInteger childCount = [self childCount]; NSUInteger childCount = [self childCount];
// Check to make sure this is a valid addition... // Check to make sure this is a valid addition...
NSAssert(nil != child, NSInvalidArgumentException); NSAssert(nil != child, NSInvalidArgumentException);
NSAssert(index <= childCount, NSInvalidArgumentException); NSAssert(index <= childCount, NSInvalidArgumentException);
NSAssert(nil == [child parent], NSInvalidArgumentException); NSAssert(nil == [child parent], NSInvalidArgumentException);
NSAssert(NSXMLAttributeKind != kind, NSInvalidArgumentException); NSAssert(NSXMLAttributeKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLDTDKind != kind, NSInvalidArgumentException); NSAssert(NSXMLDTDKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLDocumentKind != kind, NSInvalidArgumentException); NSAssert(NSXMLDocumentKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLElementDeclarationKind != kind, NSInvalidArgumentException); NSAssert(NSXMLElementDeclarationKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLEntityDeclarationKind != kind, NSInvalidArgumentException); NSAssert(NSXMLEntityDeclarationKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLInvalidKind != kind, NSInvalidArgumentException); NSAssert(NSXMLInvalidKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLNamespaceKind != kind, NSInvalidArgumentException); NSAssert(NSXMLNamespaceKind != theKind, NSInvalidArgumentException);
NSAssert(NSXMLNotationDeclarationKind != kind, NSInvalidArgumentException); NSAssert(NSXMLNotationDeclarationKind != theKind, NSInvalidArgumentException);
[self _insertChild: child atIndex: index]; [self _insertChild: child atIndex: index];
} }
@ -701,9 +703,9 @@ extern void ensure_oldNs(xmlNodePtr node);
[self insertChild: child atIndex: [self childCount]]; [self insertChild: child atIndex: [self childCount]];
} }
- (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)node - (void) replaceChildAtIndex: (NSUInteger)index withNode: (NSXMLNode*)theNode
{ {
[self insertChild: node atIndex: index]; [self insertChild: theNode atIndex: index];
[self removeChildAtIndex: index + 1]; [self removeChildAtIndex: index + 1];
} }
@ -740,23 +742,23 @@ joinTextNodes(xmlNodePtr nodeA, xmlNodePtr nodeB, NSMutableArray *nodesToDelete)
while ((subNode = [subEnum nextObject])) while ((subNode = [subEnum nextObject]))
{ {
xmlNodePtr node = [subNode _node]; xmlNodePtr theNode = [subNode _node];
xmlNodePtr prev = node->prev; xmlNodePtr prev = theNode->prev;
xmlNodePtr next = node->next; xmlNodePtr next = theNode->next;
if (node->type == XML_ELEMENT_NODE) if (theNode->type == XML_ELEMENT_NODE)
{ {
[(NSXMLElement *)subNode [(NSXMLElement *)subNode
normalizeAdjacentTextNodesPreservingCDATA:preserve]; normalizeAdjacentTextNodesPreservingCDATA:preserve];
} }
else if (node->type == XML_TEXT_NODE else if (theNode->type == XML_TEXT_NODE
|| (node->type == XML_CDATA_SECTION_NODE && !preserve)) || (theNode->type == XML_CDATA_SECTION_NODE && !preserve))
{ {
if (next && (next->type == XML_TEXT_NODE if (next && (next->type == XML_TEXT_NODE
|| (next->type == XML_CDATA_SECTION_NODE && !preserve))) || (next->type == XML_CDATA_SECTION_NODE && !preserve)))
{ {
//combine node & node->next //combine node & node->next
joinTextNodes(node, node->next, nodesToDelete); joinTextNodes(theNode, theNode->next, nodesToDelete);
} }
if (prev && (prev->type == XML_TEXT_NODE if (prev && (prev->type == XML_TEXT_NODE
|| (prev->type == XML_CDATA_SECTION_NODE && !preserve))) || (prev->type == XML_CDATA_SECTION_NODE && !preserve)))
@ -772,7 +774,7 @@ joinTextNodes(xmlNodePtr nodeA, xmlNodePtr nodeB, NSMutableArray *nodesToDelete)
* from our subNodes when we're done iterating it) * from our subNodes when we're done iterating it)
* (or maybe we need to turn it into an NSInvalidNode too??) * (or maybe we need to turn it into an NSInvalidNode too??)
*/ */
joinTextNodes(node->prev, node, nodesToDelete); joinTextNodes(theNode->prev, theNode, nodesToDelete);
} }
} }

View file

@ -470,13 +470,13 @@ isEqualTree(xmlNodePtr nodeA, xmlNodePtr nodeB)
GS_CREATE_INTERNAL(NSXMLNode); GS_CREATE_INTERNAL(NSXMLNode);
} }
- (id) _initWithNode: (xmlNodePtr)node kind: (NSXMLNodeKind)kind - (id) _initWithNode: (xmlNodePtr)theNode kind: (NSXMLNodeKind)theKind
{ {
if ((self = [super init])) if ((self = [super init]))
{ {
[self _createInternal]; [self _createInternal];
[self _setNode: node]; [self _setNode: theNode];
internal->kind = kind; internal->kind = theKind;
} }
return self; return self;
} }
@ -484,16 +484,16 @@ isEqualTree(xmlNodePtr nodeA, xmlNodePtr nodeB)
- (xmlNodePtr) _childNodeAtIndex: (NSUInteger)index - (xmlNodePtr) _childNodeAtIndex: (NSUInteger)index
{ {
NSUInteger count = 0; NSUInteger count = 0;
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
xmlNodePtr children; xmlNodePtr children;
if ((node->type == XML_NAMESPACE_DECL) || if ((theNode->type == XML_NAMESPACE_DECL) ||
(node->type == XML_ATTRIBUTE_NODE)) (theNode->type == XML_ATTRIBUTE_NODE))
{ {
return NULL; return NULL;
} }
children = node->children; children = theNode->children;
if (!children) if (!children)
return NULL; // the Cocoa docs say it returns nil if there are no children return NULL; // the Cocoa docs say it returns nil if there are no children
@ -1096,20 +1096,20 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
{ {
NSUInteger count = 0; NSUInteger count = 0;
xmlNodePtr children = NULL; xmlNodePtr children = NULL;
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (!node) if (!theNode)
{ {
return 0; return 0;
} }
if ((node->type == XML_NAMESPACE_DECL) || if ((theNode->type == XML_NAMESPACE_DECL) ||
(node->type == XML_ATTRIBUTE_NODE)) (theNode->type == XML_ATTRIBUTE_NODE))
{ {
return 0; return 0;
} }
for (children = node->children; children; children = children->next) for (children = theNode->children; children; children = children->next)
{ {
count++; count++;
} }
@ -1128,18 +1128,18 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
else else
{ {
xmlNodePtr children = NULL; xmlNodePtr children = NULL;
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if ((node == NULL) || if ((theNode == NULL) ||
(node->type == XML_NAMESPACE_DECL) || (theNode->type == XML_NAMESPACE_DECL) ||
(node->type == XML_ATTRIBUTE_NODE) || (theNode->type == XML_ATTRIBUTE_NODE) ||
(node->children == NULL)) (theNode->children == NULL))
{ {
return nil; return nil;
} }
childrenArray = [NSMutableArray array]; childrenArray = [NSMutableArray array];
for (children = node->children; children; children = children->next) for (children = theNode->children; children; children = children->next)
{ {
NSXMLNode *n = [NSXMLNode _objectForNode: children]; NSXMLNode *n = [NSXMLNode _objectForNode: children];
[childrenArray addObject: n]; [childrenArray addObject: n];
@ -1186,49 +1186,49 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
{ {
if (GS_EXISTS_INTERNAL) if (GS_EXISTS_INTERNAL)
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
NSArray *subNodes = [internal->subNodes copy]; NSArray *theSubNodes = [internal->subNodes copy];
NSEnumerator *enumerator = [subNodes objectEnumerator]; NSEnumerator *enumerator = [theSubNodes objectEnumerator];
NSXMLNode *subNode; NSXMLNode *subNode;
while ((subNode = [enumerator nextObject]) != nil) while ((subNode = [enumerator nextObject]) != nil)
{ {
[subNode detach]; [subNode detach];
} }
[subNodes release]; [theSubNodes release];
[internal->objectValue release]; [internal->objectValue release];
[internal->subNodes release]; [internal->subNodes release];
if (node) if (theNode)
{ {
if (node->type == XML_NAMESPACE_DECL) if (theNode->type == XML_NAMESPACE_DECL)
{ {
((xmlNsPtr)node)->_private = NULL; ((xmlNsPtr)theNode)->_private = NULL;
// FIXME: Not sure when to free the node here, // FIXME: Not sure when to free the node here,
// the same namespace node might be referenced // the same namespace node might be referenced
// from other places. // from other places.
xmlFreeNode(node); xmlFreeNode(theNode);
} }
else else
{ {
node->_private = NULL; theNode->_private = NULL;
if (node->parent == NULL) if (theNode->parent == NULL)
{ {
// the top level node frees the entire tree // the top level node frees the entire tree
if (node->type == XML_DOCUMENT_NODE) if (theNode->type == XML_DOCUMENT_NODE)
{ {
xmlFreeDoc((xmlDocPtr)node); xmlFreeDoc((xmlDocPtr)theNode);
} }
else if (node->type == XML_ENTITY_DECL && else if (theNode->type == XML_ENTITY_DECL &&
((xmlEntityPtr)node)->etype == XML_INTERNAL_PREDEFINED_ENTITY) ((xmlEntityPtr)theNode)->etype == XML_INTERNAL_PREDEFINED_ENTITY)
{ {
// Don't free internal entity nodes // Don't free internal entity nodes
} }
else else
{ {
xmlDocPtr tmp = node->doc; xmlDocPtr tmp = theNode->doc;
xmlFreeNode(node); xmlFreeNode(theNode);
// Free the private document we allocated in detach // Free the private document we allocated in detach
if (tmp) if (tmp)
{ {
@ -1245,19 +1245,19 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
- (void) detach - (void) detach
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (node) if (theNode)
{ {
NSXMLNode *parent = [self parent]; NSXMLNode *parent = [self parent];
if (node->type == XML_NAMESPACE_DECL) if (theNode->type == XML_NAMESPACE_DECL)
{ {
// FIXME // FIXME
} }
else else
{ {
if (node->doc) if (theNode->doc)
{ {
/* Create a private document and move the node over. /* Create a private document and move the node over.
* This is needed so that the strings of the nodes subtree * This is needed so that the strings of the nodes subtree
@ -1268,15 +1268,15 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
xmlDocPtr tmp = xmlNewDoc((xmlChar *)"1.0"); xmlDocPtr tmp = xmlNewDoc((xmlChar *)"1.0");
#if LIBXML_VERSION >= 20620 #if LIBXML_VERSION >= 20620
xmlDOMWrapAdoptNode(NULL, node->doc, node, tmp, NULL, 0); xmlDOMWrapAdoptNode(NULL, theNode->doc, theNode, tmp, NULL, 0);
#else #else
xmlSetTreeDoc(node, tmp); xmlSetTreeDoc(theNode, tmp);
#endif #endif
} }
else else
{ {
// separate our node from its parent and siblings // separate our node from its parent and siblings
xmlUnlinkNode(node); xmlUnlinkNode(theNode);
} }
} }
@ -1294,15 +1294,15 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
- (NSUInteger) index - (NSUInteger) index
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
int count = 0; int count = 0;
if (node->type == XML_NAMESPACE_DECL) if (theNode->type == XML_NAMESPACE_DECL)
{ {
return 0; return 0;
} }
while ((node = node->prev)) while ((theNode = theNode->prev))
{ {
count++; // count our earlier sibling nodes count++; // count our earlier sibling nodes
} }
@ -1315,20 +1315,20 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
return [self initWithKind: NSXMLInvalidKind]; return [self initWithKind: NSXMLInvalidKind];
} }
- (id) initWithKind: (NSXMLNodeKind) kind - (id) initWithKind: (NSXMLNodeKind)theKind
{ {
return [self initWithKind: kind options: 0]; return [self initWithKind: theKind options: 0];
} }
- (id) initWithKind: (NSXMLNodeKind)kind options: (NSUInteger)theOptions - (id) initWithKind: (NSXMLNodeKind)theKind options: (NSUInteger)theOptions
{ {
Class theSubclass = [NSXMLNode class]; Class theSubclass = [NSXMLNode class];
void *node = NULL; void *theNode = NULL;
/* /*
* We find the correct subclass for specific node kinds: * We find the correct subclass for specific node kinds:
*/ */
switch (kind) switch (theKind)
{ {
case NSXMLDocumentKind: case NSXMLDocumentKind:
theSubclass = [NSXMLDocument class]; theSubclass = [NSXMLDocument class];
@ -1367,7 +1367,7 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
return nil; return nil;
default: default:
kind = NSXMLInvalidKind; theKind = NSXMLInvalidKind;
theSubclass = [NSXMLNode class]; theSubclass = [NSXMLNode class];
break; break;
} }
@ -1380,26 +1380,26 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
if (NO == [self isKindOfClass: theSubclass]) if (NO == [self isKindOfClass: theSubclass])
{ {
[self release]; [self release];
return [[theSubclass alloc] initWithKind: kind return [[theSubclass alloc] initWithKind: theKind
options: theOptions]; options: theOptions];
} }
/* If we are initializing for the correct class, we can actually perform /* If we are initializing for the correct class, we can actually perform
* initializations: * initializations:
*/ */
switch (kind) switch (theKind)
{ {
case NSXMLDocumentKind: case NSXMLDocumentKind:
node = xmlNewDoc((xmlChar *)"1.0"); theNode = xmlNewDoc((xmlChar *)"1.0");
break; break;
case NSXMLInvalidKind: case NSXMLInvalidKind:
case NSXMLElementKind: case NSXMLElementKind:
node = xmlNewNode(NULL,(xmlChar *)""); theNode = xmlNewNode(NULL,(xmlChar *)"");
break; break;
case NSXMLDTDKind: case NSXMLDTDKind:
node = xmlNewDtd(NULL, (xmlChar *)"", (xmlChar *)"",(xmlChar *)""); theNode = xmlNewDtd(NULL, (xmlChar *)"", (xmlChar *)"",(xmlChar *)"");
break; break;
case NSXMLElementDeclarationKind: case NSXMLElementDeclarationKind:
@ -1409,14 +1409,14 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
memset(ret, 0, sizeof(xmlElement)); memset(ret, 0, sizeof(xmlElement));
ret->type = XML_ELEMENT_DECL; ret->type = XML_ELEMENT_DECL;
ret->name = xmlStrdup((xmlChar *)""); ret->name = xmlStrdup((xmlChar *)"");
node = ret; theNode = ret;
break; break;
} }
case NSXMLEntityDeclarationKind: case NSXMLEntityDeclarationKind:
#if LIBXML_VERSION >= 20700 #if LIBXML_VERSION >= 20700
node = xmlNewEntity(NULL, (xmlChar *)"", 0, (xmlChar *)"", theNode = xmlNewEntity(NULL, (xmlChar *)"", 0, (xmlChar *)"",
(xmlChar *)"", (xmlChar *)""); (xmlChar *)"", (xmlChar *)"");
#else #else
{ {
xmlEntityPtr ret; xmlEntityPtr ret;
@ -1427,41 +1427,41 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
ret->ExternalID = xmlStrdup((xmlChar *)""); ret->ExternalID = xmlStrdup((xmlChar *)"");
ret->SystemID = xmlStrdup((xmlChar *)""); ret->SystemID = xmlStrdup((xmlChar *)"");
ret->content = xmlStrdup((xmlChar *)""); ret->content = xmlStrdup((xmlChar *)"");
node = ret; theNode = ret;
} }
#endif #endif
break; break;
case NSXMLNotationDeclarationKind: case NSXMLNotationDeclarationKind:
// FIXME // FIXME
node = xmlNewNode(NULL, (xmlChar *)""); theNode = xmlNewNode(NULL, (xmlChar *)"");
break; break;
case NSXMLProcessingInstructionKind: case NSXMLProcessingInstructionKind:
node = xmlNewPI((xmlChar *)"", (xmlChar *)""); theNode = xmlNewPI((xmlChar *)"", (xmlChar *)"");
break; break;
case NSXMLCommentKind: case NSXMLCommentKind:
node = xmlNewComment((xmlChar *)""); theNode = xmlNewComment((xmlChar *)"");
break; break;
case NSXMLTextKind: case NSXMLTextKind:
node = xmlNewText((xmlChar *)""); theNode = xmlNewText((xmlChar *)"");
break; break;
case NSXMLNamespaceKind: case NSXMLNamespaceKind:
node = xmlNewNs(NULL,(xmlChar *)"",(xmlChar *)""); theNode = xmlNewNs(NULL,(xmlChar *)"",(xmlChar *)"");
break; break;
case NSXMLAttributeKind: case NSXMLAttributeKind:
node = xmlNewProp(NULL,(xmlChar *)"",(xmlChar *)""); theNode = xmlNewProp(NULL,(xmlChar *)"",(xmlChar *)"");
break; break;
default: default:
break; break;
} }
if (nil == (self = [self _initWithNode: node kind: kind])) if (nil == (self = [self _initWithNode: theNode kind: theKind]))
{ {
return nil; return nil;
} }
@ -1505,20 +1505,20 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
- (NSString*) localName - (NSString*) localName
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (NSXMLInvalidKind == internal->kind) if (NSXMLInvalidKind == internal->kind)
{ {
return nil; return nil;
} }
if (node->type == XML_NAMESPACE_DECL) if (theNode->type == XML_NAMESPACE_DECL)
{ {
return StringFromXMLStringPtr(((xmlNs *)node)->prefix); return StringFromXMLStringPtr(((xmlNs *)theNode)->prefix);
} }
else else
{ {
return StringFromXMLStringPtr(node->name); return StringFromXMLStringPtr(theNode->name);
} }
} }
@ -1543,7 +1543,7 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
{ {
NSXMLNode *ancestor = self; NSXMLNode *ancestor = self;
NSXMLNode *candidate = nil; NSXMLNode *candidate = nil;
NSXMLNodeKind kind; NSXMLNodeKind theKind;
if (forward) if (forward)
{ {
@ -1588,8 +1588,8 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
} }
/* Sanity check: Namespace and attribute nodes are skipped: */ /* Sanity check: Namespace and attribute nodes are skipped: */
kind = [candidate kind]; theKind = [candidate kind];
if ((NSXMLAttributeKind == kind) || (NSXMLNamespaceKind == kind)) if ((NSXMLAttributeKind == theKind) || (NSXMLNamespaceKind == theKind))
{ {
return [candidate _nodeFollowingInNaturalDirection: forward]; return [candidate _nodeFollowingInNaturalDirection: forward];
} }
@ -1603,17 +1603,17 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
- (NSXMLNode*) nextSibling - (NSXMLNode*) nextSibling
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (NULL == node) if (NULL == theNode)
{ {
return nil; return nil;
} }
if (XML_NAMESPACE_DECL == node->type) if (XML_NAMESPACE_DECL == theNode->type)
{ {
return nil; return nil;
} }
return [NSXMLNode _objectForNode: node->next]; return [NSXMLNode _objectForNode: theNode->next];
} }
- (id) objectValue - (id) objectValue
@ -1624,43 +1624,43 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
- (NSXMLNode*) parent - (NSXMLNode*) parent
{ {
xmlNodePtr parent = NULL; xmlNodePtr parent = NULL;
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (NULL == node) if (NULL == theNode)
{ {
return nil; return nil;
} }
if (XML_NAMESPACE_DECL == node->type) if (XML_NAMESPACE_DECL == theNode->type)
{ {
return nil; return nil;
} }
parent = node->parent; parent = theNode->parent;
return [NSXMLNode _objectForNode: parent]; return [NSXMLNode _objectForNode: parent];
} }
- (NSString*) prefix - (NSString*) prefix
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (NULL == node) if (NULL == theNode)
{ {
return nil; return nil;
} }
if (XML_NAMESPACE_DECL == node->type) if (XML_NAMESPACE_DECL == theNode->type)
{ {
return @""; return @"";
} }
if (XML_ELEMENT_NODE != node->type) if (XML_ELEMENT_NODE != theNode->type)
{ {
return @""; return @"";
} }
if (node->ns == NULL) if (theNode->ns == NULL)
{ {
return @""; return @"";
} }
return StringFromXMLStringPtr(node->ns->prefix); return StringFromXMLStringPtr(theNode->ns->prefix);
} }
- (NSXMLNode*) previousNode - (NSXMLNode*) previousNode
@ -1670,32 +1670,32 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
- (NSXMLNode*) previousSibling - (NSXMLNode*) previousSibling
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (NULL == node) if (NULL == theNode)
{ {
return nil; return nil;
} }
if (XML_NAMESPACE_DECL == node->type) if (XML_NAMESPACE_DECL == theNode->type)
{ {
return nil; return nil;
} }
return [NSXMLNode _objectForNode: node->prev]; return [NSXMLNode _objectForNode: theNode->prev];
} }
- (NSXMLDocument*) rootDocument - (NSXMLDocument*) rootDocument
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (NULL == node) if (NULL == theNode)
{ {
return nil; return nil;
} }
if (XML_NAMESPACE_DECL == node->type) if (XML_NAMESPACE_DECL == theNode->type)
{ {
return nil; return nil;
} }
if ((NULL == node->doc) || (NULL == node->doc->children)) if ((NULL == theNode->doc) || (NULL == theNode->doc->children))
{ {
// This is a standalone node, we still may have a private document, // This is a standalone node, we still may have a private document,
// but we don't want to return this. // but we don't want to return this.
@ -1703,13 +1703,13 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
} }
return return
(NSXMLDocument *)[NSXMLNode _objectForNode: (xmlNodePtr)(node->doc)]; (NSXMLDocument *)[NSXMLNode _objectForNode: (xmlNodePtr)(theNode->doc)];
} }
- (NSString*) stringValue - (NSString*) stringValue
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
xmlChar *content = xmlNodeGetContent(node); xmlChar *content = xmlNodeGetContent(theNode);
NSString *result = nil; NSString *result = nil;
if (NULL != content) if (NULL != content)
@ -1738,16 +1738,16 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
- (void) setName: (NSString *)name - (void) setName: (NSString *)name
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (NSXMLInvalidKind == internal->kind) if (NSXMLInvalidKind == internal->kind)
{ {
return; return;
} }
if (node->type == XML_NAMESPACE_DECL) if (theNode->type == XML_NAMESPACE_DECL)
{ {
xmlNsPtr ns = (xmlNsPtr)node; xmlNsPtr ns = (xmlNsPtr)theNode;
if (ns->prefix != NULL) if (ns->prefix != NULL)
{ {
@ -1763,40 +1763,40 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
if (NULL == xmlName) if (NULL == xmlName)
{ {
xmlNodeSetName(node, (const xmlChar *)""); xmlNodeSetName(theNode, (const xmlChar *)"");
return; return;
} }
localName = xmlSplitQName2(xmlName, &prefix); localName = xmlSplitQName2(xmlName, &prefix);
if (prefix != NULL) if (prefix != NULL)
{ {
if ((node->type == XML_ATTRIBUTE_NODE) || if ((theNode->type == XML_ATTRIBUTE_NODE) ||
(node->type == XML_ELEMENT_NODE)) (theNode->type == XML_ELEMENT_NODE))
{ {
if ((node->ns != NULL && node->ns->prefix == NULL)) if ((theNode->ns != NULL && theNode->ns->prefix == NULL))
{ {
node->ns->prefix = xmlStrdup(prefix); theNode->ns->prefix = xmlStrdup(prefix);
} }
else else
{ {
xmlNsPtr ns; xmlNsPtr ns;
// Set namespace // Set namespace
ns = xmlSearchNs(node->doc, node, prefix); ns = xmlSearchNs(theNode->doc, theNode, prefix);
if (ns) if (ns)
{ {
xmlSetNs(node, ns); xmlSetNs(theNode, ns);
} }
else else
{ {
xmlNsPtr oldNs; xmlNsPtr oldNs;
ensure_oldNs(node); ensure_oldNs(theNode);
// Fake the name space and fix it later // Fake the name space and fix it later
// This function is private, so re reimplemt it. // This function is private, so re reimplemt it.
//ns = xmlDOMWrapStoreNs(node->doc, NULL, prefix); //ns = xmlDOMWrapStoreNs(node->doc, NULL, prefix);
oldNs = node->doc->oldNs; oldNs = theNode->doc->oldNs;
while (oldNs) while (oldNs)
{ {
if (oldNs->prefix != NULL && xmlStrEqual(oldNs->prefix, prefix)) if (oldNs->prefix != NULL && xmlStrEqual(oldNs->prefix, prefix))
@ -1812,18 +1812,18 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
} }
oldNs = oldNs->next; oldNs = oldNs->next;
} }
xmlSetNs(node, ns); xmlSetNs(theNode, ns);
} }
} }
} }
xmlNodeSetName(node, localName); xmlNodeSetName(theNode, localName);
xmlFree(localName); xmlFree(localName);
xmlFree(prefix); xmlFree(prefix);
} }
else else
{ {
xmlNodeSetName(node, xmlName); xmlNodeSetName(theNode, xmlName);
} }
} }
} }
@ -1835,11 +1835,11 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
- (void) setStringValue: (NSString*)string resolvingEntities: (BOOL)resolve - (void) setStringValue: (NSString*)string resolvingEntities: (BOOL)resolve
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (node->type == XML_NAMESPACE_DECL) if (theNode->type == XML_NAMESPACE_DECL)
{ {
xmlNsPtr ns = (xmlNsPtr)node; xmlNsPtr ns = (xmlNsPtr)theNode;
if (ns->href != NULL) if (ns->href != NULL)
{ {
xmlFree((xmlChar *)ns->href); xmlFree((xmlChar *)ns->href);
@ -1851,8 +1851,8 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
// Remove all child nodes except attributes // Remove all child nodes except attributes
if (internal->subNodes) if (internal->subNodes)
{ {
NSArray *subNodes = [internal->subNodes copy]; NSArray *theSubNodes = [internal->subNodes copy];
NSEnumerator *enumerator = [subNodes objectEnumerator]; NSEnumerator *enumerator = [theSubNodes objectEnumerator];
NSXMLNode *subNode; NSXMLNode *subNode;
while ((subNode = [enumerator nextObject]) != nil) while ((subNode = [enumerator nextObject]) != nil)
@ -1862,18 +1862,19 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
[subNode detach]; [subNode detach];
} }
} }
[theSubNodes release];
} }
if (resolve == NO) if (resolve == NO)
{ {
xmlNodeSetContent(node, XMLSTRING(string)); xmlNodeSetContent(theNode, XMLSTRING(string));
} }
else else
{ {
// need to actually resolve entities... // need to actually resolve entities...
// is this the right functionality?? xmlEncodeSpecialChars() // is this the right functionality?? xmlEncodeSpecialChars()
xmlChar *newstr = xmlEncodeEntitiesReentrant(node->doc, XMLSTRING(string)); xmlChar *newstr = xmlEncodeEntitiesReentrant(theNode->doc, XMLSTRING(string));
xmlNodeSetContent(node, newstr); xmlNodeSetContent(theNode, newstr);
xmlMemFree(newstr); xmlMemFree(newstr);
} }
} }
@ -1882,49 +1883,49 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
- (void) setURI: (NSString*)URI - (void) setURI: (NSString*)URI
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (NSXMLInvalidKind == internal->kind) if (NSXMLInvalidKind == internal->kind)
{ {
return; return;
} }
if ((node->type == XML_ATTRIBUTE_NODE) || if ((theNode->type == XML_ATTRIBUTE_NODE) ||
(node->type == XML_ELEMENT_NODE)) (theNode->type == XML_ELEMENT_NODE))
{ {
const xmlChar *uri = XMLSTRING(URI); const xmlChar *uri = XMLSTRING(URI);
xmlNsPtr ns; xmlNsPtr ns;
if (uri == NULL) if (uri == NULL)
{ {
node->ns = NULL; theNode->ns = NULL;
return; return;
} }
ns = xmlSearchNsByHref(node->doc, node, uri); ns = xmlSearchNsByHref(theNode->doc, theNode, uri);
if (ns == NULL) if (ns == NULL)
{ {
if ((node->ns != NULL && node->ns->href == NULL)) if ((theNode->ns != NULL && theNode->ns->href == NULL))
{ {
node->ns->href = xmlStrdup(uri); theNode->ns->href = xmlStrdup(uri);
return; return;
} }
/* /*
if (node->type == XML_ELEMENT_NODE) if (theNode->type == XML_ELEMENT_NODE)
{ {
//ns = xmlNewNs(node, uri, (const xmlChar *)""); //ns = xmlNewNs(theNode, uri, (const xmlChar *)"");
ns = xmlNewNs(node, uri, NULL); ns = xmlNewNs(theNode, uri, NULL);
} }
else else
*/ */
{ {
xmlNsPtr oldNs; xmlNsPtr oldNs;
ensure_oldNs(node); ensure_oldNs(theNode);
// Fake the name space and fix it later // Fake the name space and fix it later
// This function is private, so re reimplemt it. // This function is private, so re reimplemt it.
//ns = xmlDOMWrapStoreNs(node->doc, NULL, prefix); //ns = xmlDOMWrapStoreNs(node->doc, NULL, prefix);
oldNs = node->doc->oldNs; oldNs = theNode->doc->oldNs;
while (oldNs) while (oldNs)
{ {
if (oldNs->href != NULL && xmlStrEqual(oldNs->href, uri)) if (oldNs->href != NULL && xmlStrEqual(oldNs->href, uri))
@ -1943,22 +1944,22 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
} }
} }
xmlSetNs(node, ns); xmlSetNs(theNode, ns);
} }
} }
- (NSString*) URI - (NSString*) URI
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (NSXMLInvalidKind == internal->kind) if (NSXMLInvalidKind == internal->kind)
{ {
return nil; return nil;
} }
if ((node->type == XML_ATTRIBUTE_NODE) || if ((theNode->type == XML_ATTRIBUTE_NODE) ||
(node->type == XML_ELEMENT_NODE)) (theNode->type == XML_ELEMENT_NODE))
{ {
xmlNsPtr ns = internal->node->ns; xmlNsPtr ns = theNode->ns;
if ((ns != NULL) && (ns->href != NULL)) if ((ns != NULL) && (ns->href != NULL))
{ {
@ -1974,7 +1975,7 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
return [self XMLStringWithOptions: NSXMLNodeOptionsNone]; return [self XMLStringWithOptions: NSXMLNodeOptionsNone];
} }
- (NSString*) XMLStringWithOptions: (NSUInteger)options - (NSString*) XMLStringWithOptions: (NSUInteger)theOptions
{ {
NSString *string = nil; NSString *string = nil;
xmlChar *buf = NULL; xmlChar *buf = NULL;
@ -1990,20 +1991,20 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
xmlOptions |= XML_SAVE_AS_XML; xmlOptions |= XML_SAVE_AS_XML;
#endif #endif
#if LIBXML_VERSION >= 20708 #if LIBXML_VERSION >= 20708
if (options & NSXMLNodePreserveWhitespace) if (theOptions & NSXMLNodePreserveWhitespace)
{ {
xmlOptions |= XML_SAVE_WSNONSIG; xmlOptions |= XML_SAVE_WSNONSIG;
} }
#endif #endif
#if LIBXML_VERSION >= 20622 #if LIBXML_VERSION >= 20622
//NSXMLNodeExpandEmptyElement is the default //NSXMLNodeExpandEmptyElement is the default
if ((options & NSXMLNodeCompactEmptyElement) == 0) if ((theOptions & NSXMLNodeCompactEmptyElement) == 0)
{ {
xmlOptions |= XML_SAVE_NO_EMPTY; xmlOptions |= XML_SAVE_NO_EMPTY;
} }
#endif #endif
#if LIBXML_VERSION >= 20617 #if LIBXML_VERSION >= 20617
if (options & NSXMLNodePrettyPrint) if (theOptions & NSXMLNodePrettyPrint)
{ {
xmlOptions |= XML_SAVE_FORMAT; xmlOptions |= XML_SAVE_FORMAT;
} }
@ -2051,24 +2052,24 @@ execute_xpath(xmlNodePtr node, NSString *xpath_exp, NSDictionary *constants,
- (NSString*) XPath - (NSString*) XPath
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
return StringFromXMLStringPtr(xmlGetNodePath(node)); return StringFromXMLStringPtr(xmlGetNodePath(theNode));
} }
- (NSArray*) nodesForXPath: (NSString*)anxpath error: (NSError**)error - (NSArray*) nodesForXPath: (NSString*)anxpath error: (NSError**)error
{ {
xmlNodePtr node = internal->node; xmlNodePtr theNode = internal->node;
if (NSXMLInvalidKind == internal->kind) if (NSXMLInvalidKind == internal->kind)
{ {
return nil; return nil;
} }
if (node->type == XML_NAMESPACE_DECL) if (theNode->type == XML_NAMESPACE_DECL)
{ {
return nil; return nil;
} }
return execute_xpath(node, anxpath, nil, YES, error); return execute_xpath(theNode, anxpath, nil, YES, error);
} }
- (NSArray*) objectsForXQuery: (NSString*)xquery - (NSArray*) objectsForXQuery: (NSString*)xquery

View file

@ -16,9 +16,11 @@ int main()
{ {
NSAutoreleasePool *arp = [NSAutoreleasePool new]; NSAutoreleasePool *arp = [NSAutoreleasePool new];
NSObject *o = [NSObject new]; NSObject *o = [NSObject new];
for (unsigned i=0 ; i<1000 ; i++) unsigned i;
for (i = 0; i < 1000; i++)
{ {
[[o retain] autorelease]; [[o retain] autorelease];
} }
NSUInteger totalCount = [arp autoreleaseCount]; NSUInteger totalCount = [arp autoreleaseCount];
PASS(totalCount == 1000, "Autorelease count is correct"); PASS(totalCount == 1000, "Autorelease count is correct");