get the xml code to build on RedHat/CentOS

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@34928 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2012-03-14 10:09:15 +00:00
parent 95c6da91e9
commit e3a0cd2cee
4 changed files with 43 additions and 23 deletions

View file

@ -1,3 +1,10 @@
2012-03-14 Richard Frith-Macdonald & Fred Kiefer
* Source/NSXMLPrivate.h:
* Source/NSXMLNode.m:
* Source/NSXMLElement.m:
Fixups to get the code to build on CentOS/RedHat linux.
2012-03-12 Fred Kiefer <FredKiefer@gmx.de> 2012-03-12 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSXMLNode.m (-detach): Don't handle the namespace case. * Source/NSXMLNode.m (-detach): Don't handle the namespace case.

View file

@ -324,7 +324,7 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
} }
else else
{ {
xmlFreeNode(cur); xmlFreeNs(cur);
} }
return; return;
} }
@ -338,7 +338,6 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
{ {
NSEnumerator *en = [namespaces objectEnumerator]; NSEnumerator *en = [namespaces objectEnumerator];
NSXMLNode *namespace = nil; NSXMLNode *namespace = nil;
xmlNsPtr cur = NULL;
// FIXME: Remove old namespaces // FIXME: Remove old namespaces
// xmlFreeNsList(internal->node->nsDef); // xmlFreeNsList(internal->node->nsDef);
@ -409,7 +408,8 @@ GS_PRIVATE_INTERNAL(NSXMLElement)
if (ns) if (ns)
{ {
const xmlChar *uri = XMLSTRING(namespaceURI); const xmlChar *uri = XMLSTRING(namespaceURI);
xmlNsPtr cur = NULL; xmlNsPtr cur;
for (cur = ns; cur != NULL; cur = cur->next) for (cur = ns; cur != NULL; cur = cur->next)
{ {
if (xmlStrcmp(uri, cur->href) == 0) if (xmlStrcmp(uri, cur->href) == 0)

View file

@ -344,7 +344,7 @@ isEqualTree(xmlNodePtr nodeA, xmlNodePtr nodeB)
} }
if (node->type == XML_NAMESPACE_DECL) if (node->type == XML_NAMESPACE_DECL)
{ {
docNode = ((xmlNsPtr)node)->context; docNode = NULL;
} }
else else
{ {
@ -1016,7 +1016,6 @@ execute_xpath(NSXMLNode *xmlNode, NSString *xpath_exp, NSString *nmspaces)
} }
[subNodes release]; [subNodes release];
[internal->URI release];
[internal->objectValue release]; [internal->objectValue release];
[internal->subNodes release]; [internal->subNodes release];
if (node) if (node)
@ -1355,15 +1354,12 @@ execute_xpath(NSXMLNode *xmlNode, NSString *xpath_exp, NSString *nmspaces)
{ {
return nil; return nil;
} }
if (XML_NAMESPACE_DECL == node->type)
{
return nil;
}
if (node->type == XML_NAMESPACE_DECL) parent = node->parent;
{
parent = (xmlNodePtr)(((xmlNs *)node)->context);
}
else
{
parent = node->parent;
}
return [NSXMLNode _objectForNode: parent]; return [NSXMLNode _objectForNode: parent];
} }
@ -1507,22 +1503,21 @@ execute_xpath(NSXMLNode *xmlNode, NSString *xpath_exp, NSString *nmspaces)
- (NSString*) XMLStringWithOptions: (NSUInteger)options - (NSString*) XMLStringWithOptions: (NSUInteger)options
{ {
NSString *string = nil; NSString *string = nil;
xmlNodePtr node = (xmlNodePtr)[self _node];
xmlChar *buf = NULL; xmlChar *buf = NULL;
xmlDocPtr doc; xmlDocPtr doc;
xmlBufferPtr buffer = xmlBufferCreate(); xmlBufferPtr buffer;
int error = 0; int error = 0;
int len = 0; int len = 0;
if (node->type == XML_NAMESPACE_DECL) if (internal->node->type == XML_NAMESPACE_DECL)
{ {
doc = ((xmlNs *)node)->context; xmlNsPtr ns = (xmlNsPtr)internal->node;
return StringFromXMLStringPtr(ns->href);
} }
else buffer = xmlBufferCreate();
{ doc = internal->node->doc;
doc = node->doc; error = xmlNodeDump(buffer, doc, internal->node, 1, 1);
}
error = xmlNodeDump(buffer, doc, node, 1, 1);
if (-1 == error) if (-1 == error)
{ {
xmlBufferFree(buffer); xmlBufferFree(buffer);
@ -1530,7 +1525,7 @@ execute_xpath(NSXMLNode *xmlNode, NSString *xpath_exp, NSString *nmspaces)
} }
buf = buffer->content; buf = buffer->content;
len = buffer->use; len = buffer->use;
string = StringFromXMLString(buf,len); string = StringFromXMLString(buf, len);
xmlBufferFree(buffer); xmlBufferFree(buffer);
return string; return string;

View file

@ -83,10 +83,28 @@ StringFromXMLString(const unsigned char *bytes, unsigned length)
/* Instance variables for NSXMLNode. This macro needs to be defined before /* Instance variables for NSXMLNode. This macro needs to be defined before
* the NSXMLNode.h header is imported and before GSInternal.h is imported. * the NSXMLNode.h header is imported and before GSInternal.h is imported.
*
* The 'kind' tells us what sort of node this is.
* The 'node' points to the underlying libxml2 node structure.
* The 'nsParent' points to the parent node of a namspace structure, needed
* because older (but still used on at least one major linux distribution)
* versions of libxml2 don't have a link to the parent of a namespace.
* The 'options' field is a bitmask of options for this node.
* The 'objectValue' is the object value set for the node.
*
* The 'subNodes' array is confusing ... what *is* the ownership policy for
* NSXMLNode with respect to the libxml2 tree? The simple/obvious one would
* be that each NSXMLNode owns any NSXMLNode pointed to by children of the
* corresponding libxml2 structure ... in which case there would be no need
* for this array because the references to the owned NSXMLNode instances
* would be the'_private' fields of the libxml2 structures.
*
* URI is probably not needed at all ... I'm not sure
*/ */
#define GS_NSXMLNode_IVARS \ #define GS_NSXMLNode_IVARS \
NSUInteger kind; \ NSUInteger kind; \
GS_XMLNODETYPE *node; \ GS_XMLNODETYPE *node; \
xmlNodePtr nsParent; \
NSUInteger options; \ NSUInteger options; \
id objectValue; \ id objectValue; \
NSString *URI; \ NSString *URI; \