ixml: Fix for compiler warnings for size_t and ptrdiff_t.
ixmlparser.c static functions have been reordered. (cherry picked from commit 58c694f57d3cbb67ae1e14221dbba995a34d2cbb)
This commit is contained in:
parent
a15d46e142
commit
297d2ae877
@ -40,8 +40,11 @@ void IxmlPrintf(
|
||||
;
|
||||
#else /* DEBUG */
|
||||
static UPNP_INLINE void IxmlPrintf(
|
||||
const char* FmtStr,
|
||||
...) {}
|
||||
const char *FmtStr,
|
||||
...)
|
||||
{
|
||||
FmtStr = FmtStr;
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
|
||||
|
||||
@ -59,6 +62,8 @@ static UPNP_INLINE void printNodes(
|
||||
IXML_Node *tmpRoot,
|
||||
int depth)
|
||||
{
|
||||
tmpRoot = tmpRoot;
|
||||
depth = depth;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -139,7 +139,7 @@ int ixmlDocument_createElementEx(
|
||||
errCode = IXML_INSUFFICIENT_MEMORY;
|
||||
goto ErrorHandler;
|
||||
}
|
||||
// set the node fields
|
||||
/* set the node fields */
|
||||
newElement->n.nodeType = eELEMENT_NODE;
|
||||
newElement->n.nodeName = strdup(tagName);
|
||||
if (newElement->n.nodeName == NULL) {
|
||||
@ -229,7 +229,7 @@ int ixmlDocument_createTextNodeEx(
|
||||
rc = IXML_INSUFFICIENT_MEMORY;
|
||||
goto ErrorHandler;
|
||||
}
|
||||
// initialize the node
|
||||
/* initialize the node */
|
||||
ixmlNode_init(returnNode);
|
||||
|
||||
returnNode->nodeName = strdup(TEXTNODENAME);
|
||||
@ -239,7 +239,7 @@ int ixmlDocument_createTextNodeEx(
|
||||
rc = IXML_INSUFFICIENT_MEMORY;
|
||||
goto ErrorHandler;
|
||||
}
|
||||
// add in node value
|
||||
/* add in node value */
|
||||
if (data != NULL) {
|
||||
returnNode->nodeValue = strdup(data);
|
||||
if (returnNode->nodeValue == NULL) {
|
||||
@ -295,7 +295,7 @@ int ixmlDocument_createAttributeEx(
|
||||
ixmlAttr_init(attrNode);
|
||||
attrNode->n.nodeType = eATTRIBUTE_NODE;
|
||||
|
||||
// set the node fields
|
||||
/* set the node fields */
|
||||
attrNode->n.nodeName = strdup(name);
|
||||
if (attrNode->n.nodeName == NULL) {
|
||||
ixmlAttr_free(attrNode);
|
||||
@ -343,7 +343,7 @@ int ixmlDocument_createAttributeNSEx(
|
||||
if (errCode != IXML_SUCCESS) {
|
||||
goto ErrorHandler;
|
||||
}
|
||||
// set the namespaceURI field
|
||||
/* set the namespaceURI field */
|
||||
attrNode->n.namespaceURI = strdup(namespaceURI);
|
||||
if (attrNode->n.namespaceURI == NULL) {
|
||||
ixmlAttr_free(attrNode);
|
||||
@ -351,7 +351,7 @@ int ixmlDocument_createAttributeNSEx(
|
||||
errCode = IXML_INSUFFICIENT_MEMORY;
|
||||
goto ErrorHandler;
|
||||
}
|
||||
// set the localName and prefix
|
||||
/* set the localName and prefix */
|
||||
errCode =
|
||||
ixmlNode_setNodeName((IXML_Node *)attrNode, qualifiedName);
|
||||
if (errCode != IXML_SUCCESS) {
|
||||
@ -458,7 +458,7 @@ int ixmlDocument_createElementNSEx(
|
||||
line = __LINE__;
|
||||
goto ErrorHandler;
|
||||
}
|
||||
// set the namespaceURI field
|
||||
/* set the namespaceURI field */
|
||||
newElement->n.namespaceURI = strdup(namespaceURI);
|
||||
if (newElement->n.namespaceURI == NULL) {
|
||||
line = __LINE__;
|
||||
@ -467,7 +467,7 @@ int ixmlDocument_createElementNSEx(
|
||||
ret = IXML_INSUFFICIENT_MEMORY;
|
||||
goto ErrorHandler;
|
||||
}
|
||||
// set the localName and prefix
|
||||
/* set the localName and prefix */
|
||||
ret = ixmlNode_setNodeName((IXML_Node *)newElement, qualifiedName);
|
||||
if (ret != IXML_SUCCESS) {
|
||||
line = __LINE__;
|
||||
|
@ -110,7 +110,7 @@ int ixmlElement_setAttribute(
|
||||
{
|
||||
IXML_Node *attrNode;
|
||||
IXML_Attr *newAttrNode;
|
||||
short errCode = IXML_SUCCESS;
|
||||
int errCode = IXML_SUCCESS;
|
||||
|
||||
if (element == NULL || name == NULL || value == NULL) {
|
||||
errCode = IXML_INVALID_PARAMETER;
|
||||
@ -208,7 +208,8 @@ IXML_Attr *ixmlElement_getAttributeNode(IXML_Element *element, const DOMString n
|
||||
|
||||
attrNode = element->n.firstAttr;
|
||||
while (attrNode != NULL) {
|
||||
if (strcmp(attrNode->nodeName, name) == 0) { // found it
|
||||
if (strcmp(attrNode->nodeName, name) == 0) {
|
||||
/* found it */
|
||||
break;
|
||||
} else {
|
||||
attrNode = attrNode->nextSibling;
|
||||
@ -555,8 +556,8 @@ IXML_Attr *ixmlElement_getAttributeNodeNS(
|
||||
while (attrNode != NULL) {
|
||||
if (strcmp(attrNode->localName, localName) == 0 &&
|
||||
strcmp(attrNode->namespaceURI, namespaceURI) == 0) {
|
||||
// found it
|
||||
break;
|
||||
/* found it */
|
||||
break;
|
||||
} else {
|
||||
attrNode = attrNode->nextSibling;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ int ixml_membuf_insert(
|
||||
size_t buf_len,
|
||||
/*! [in] The point of insertion relative to the beggining of the
|
||||
* ixml_membuf internal buffer. */
|
||||
int index);
|
||||
size_t index);
|
||||
|
||||
|
||||
#endif /* IXML_MEMBUF_H */
|
||||
|
@ -54,37 +54,29 @@ static void copy_with_escape(
|
||||
/*! [in] The string to copy from. */
|
||||
const char *p)
|
||||
{
|
||||
int i;
|
||||
int plen;
|
||||
size_t i;
|
||||
size_t plen;
|
||||
|
||||
if (p == NULL) {
|
||||
if (p == NULL)
|
||||
return;
|
||||
}
|
||||
|
||||
plen = strlen( p );
|
||||
|
||||
for (i = 0; i < plen; i++) {
|
||||
plen = strlen(p);
|
||||
for (i = 0; i < plen; ++i) {
|
||||
switch (p[i]) {
|
||||
case '<':
|
||||
ixml_membuf_append_str(buf, "<");
|
||||
break;
|
||||
|
||||
case '>':
|
||||
ixml_membuf_append_str(buf, ">");
|
||||
break;
|
||||
|
||||
case '&':
|
||||
ixml_membuf_append_str(buf, "&");
|
||||
break;
|
||||
|
||||
case '\'':
|
||||
ixml_membuf_append_str(buf, "'");
|
||||
break;
|
||||
|
||||
case '\"':
|
||||
ixml_membuf_append_str(buf, """);
|
||||
break;
|
||||
|
||||
default:
|
||||
ixml_membuf_append(buf, &p[i]);
|
||||
break;
|
||||
@ -161,11 +153,11 @@ static void ixmlPrintDomTreeRecursive(
|
||||
} else {
|
||||
ixml_membuf_append_str(buf, ">");
|
||||
}
|
||||
// output the children
|
||||
/* output the children */
|
||||
ixmlPrintDomTreeRecursive(
|
||||
ixmlNode_getFirstChild(nodeptr), buf);
|
||||
|
||||
// Done with children. Output the end tag.
|
||||
/* Done with children. Output the end tag. */
|
||||
ixml_membuf_append_str(buf, "</");
|
||||
ixml_membuf_append_str(buf, nodeName);
|
||||
|
||||
@ -242,11 +234,11 @@ static void ixmlPrintDomTree(
|
||||
ixml_membuf_append_str(buf, ">");
|
||||
}
|
||||
|
||||
// output the children
|
||||
/* output the children */
|
||||
ixmlPrintDomTreeRecursive(
|
||||
ixmlNode_getFirstChild(nodeptr), buf);
|
||||
|
||||
// Done with children. Output the end tag.
|
||||
/* Done with children. Output the end tag. */
|
||||
ixml_membuf_append_str(buf, "</");
|
||||
ixml_membuf_append_str(buf, nodeName);
|
||||
ixml_membuf_append_str(buf, ">\r\n");
|
||||
@ -314,10 +306,10 @@ static void ixmlDomTreetoString(
|
||||
ixml_membuf_append_str(buf, ">");
|
||||
}
|
||||
|
||||
// output the children
|
||||
/* output the children */
|
||||
ixmlPrintDomTreeRecursive(ixmlNode_getFirstChild(nodeptr), buf);
|
||||
|
||||
// Done with children. Output the end tag.
|
||||
/* Done with children. Output the end tag. */
|
||||
ixml_membuf_append_str(buf, "</");
|
||||
ixml_membuf_append_str(buf, nodeName);
|
||||
ixml_membuf_append_str(buf, ">");
|
||||
|
@ -75,10 +75,10 @@ static int ixml_membuf_set_size(
|
||||
diff = new_length - m->length;
|
||||
alloc_len = MAXVAL(m->size_inc, diff) + m->capacity;
|
||||
} else {
|
||||
// decrease length
|
||||
/* decrease length */
|
||||
assert(new_length <= m->length);
|
||||
|
||||
// if diff is 0..m->size_inc, don't free
|
||||
/* if diff is 0..m->size_inc, don't free */
|
||||
if ((m->capacity - new_length) <= m->size_inc) {
|
||||
return 0;
|
||||
}
|
||||
@ -135,21 +135,21 @@ int ixml_membuf_assign(
|
||||
|
||||
assert(m != NULL);
|
||||
|
||||
// set value to null
|
||||
/* set value to null */
|
||||
if (buf == NULL) {
|
||||
ixml_membuf_destroy(m);
|
||||
return IXML_SUCCESS;
|
||||
}
|
||||
// alloc mem
|
||||
/* alloc mem */
|
||||
return_code = ixml_membuf_set_size(m, buf_len);
|
||||
if (return_code != 0) {
|
||||
return return_code;
|
||||
}
|
||||
|
||||
// copy
|
||||
/* copy */
|
||||
memcpy(m->buf, buf, buf_len);
|
||||
|
||||
// null-terminate
|
||||
/* null-terminate */
|
||||
m->buf[buf_len] = 0;
|
||||
m->length = buf_len;
|
||||
|
||||
@ -187,13 +187,13 @@ int ixml_membuf_insert(
|
||||
INOUT ixml_membuf *m,
|
||||
IN const void *buf,
|
||||
IN size_t buf_len,
|
||||
int index)
|
||||
size_t index)
|
||||
{
|
||||
int return_code = 0;
|
||||
|
||||
assert(m != NULL);
|
||||
|
||||
if (index < 0 || index > (int)m->length) {
|
||||
if (index > m->length) {
|
||||
return IXML_INDEX_SIZE_ERR;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -85,7 +85,7 @@ IXML_Node *ixmlNamedNodeMap_getNamedItem(
|
||||
IXML_NamedNodeMap *nnMap,
|
||||
const DOMString name)
|
||||
{
|
||||
long index;
|
||||
unsigned long index;
|
||||
|
||||
if (nnMap == NULL || name == NULL) {
|
||||
return NULL;
|
||||
@ -95,7 +95,7 @@ IXML_Node *ixmlNamedNodeMap_getNamedItem(
|
||||
if (index == IXML_INVALID_ITEM_NUMBER) {
|
||||
return NULL;
|
||||
} else {
|
||||
return ixmlNamedNodeMap_item(nnMap, (unsigned long)index);
|
||||
return ixmlNamedNodeMap_item(nnMap, index);
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,7 +165,7 @@ int ixmlNamedNodeMap_addToNamedNodeMap(
|
||||
}
|
||||
|
||||
if (*nnMap == NULL) {
|
||||
// nodelist is empty
|
||||
/* nodelist is empty */
|
||||
*nnMap = (IXML_NamedNodeMap *)malloc(sizeof (IXML_NamedNodeMap));
|
||||
if (*nnMap == NULL) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
|
@ -542,11 +542,11 @@ int ixmlNode_replaceChild(
|
||||
if (ixmlNode_allowChildren(nodeptr, newChild) == FALSE) {
|
||||
return IXML_HIERARCHY_REQUEST_ERR;
|
||||
}
|
||||
// if newChild was created from a different document
|
||||
/* if newChild was created from a different document */
|
||||
if (nodeptr->ownerDocument != newChild->ownerDocument) {
|
||||
return IXML_WRONG_DOCUMENT_ERR;
|
||||
}
|
||||
// if refChild is not a child of nodeptr
|
||||
/* if refChild is not a child of nodeptr */
|
||||
if (ixmlNode_isParent(nodeptr, oldChild) != TRUE) {
|
||||
return IXML_NOT_FOUND_ERR;
|
||||
}
|
||||
@ -763,6 +763,10 @@ static IXML_Element *ixmlNode_cloneElement(
|
||||
/*!
|
||||
* \brief Returns a clone of a document node.
|
||||
*
|
||||
* Currently, the IXML_Document struct is just a node, so this function
|
||||
* just mallocs the IXML_Document, sets the node type and name. Curiously,
|
||||
* the parameter nodeptr is not actually used.
|
||||
*
|
||||
* \return A clone of a document node.
|
||||
*/
|
||||
static IXML_Document *ixmlNode_cloneDoc(
|
||||
@ -781,7 +785,7 @@ static IXML_Document *ixmlNode_cloneDoc(
|
||||
}
|
||||
|
||||
ixmlDocument_init(newDoc);
|
||||
docNode = (IXML_Node *) newDoc;
|
||||
docNode = (IXML_Node *)newDoc;
|
||||
|
||||
rc = ixmlNode_setNodeName(docNode, DOCUMENTNODENAME);
|
||||
if (rc != IXML_SUCCESS) {
|
||||
@ -792,6 +796,7 @@ static IXML_Document *ixmlNode_cloneDoc(
|
||||
newDoc->n.nodeType = eDOCUMENT_NODE;
|
||||
|
||||
return newDoc;
|
||||
nodeptr = nodeptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -57,11 +57,11 @@ IXML_Node *ixmlNodeList_item(
|
||||
IXML_NodeList *next;
|
||||
unsigned int i;
|
||||
|
||||
// if the list ptr is NULL
|
||||
/* if the list ptr is NULL */
|
||||
if (nList == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
// if index is more than list length
|
||||
/* if index is more than list length */
|
||||
if (index > ixmlNodeList_length(nList) - 1) {
|
||||
return NULL;
|
||||
}
|
||||
@ -93,7 +93,7 @@ int ixmlNodeList_addToNodeList(
|
||||
}
|
||||
|
||||
if (*nList == NULL) {
|
||||
// nodelist is empty
|
||||
/* nodelist is empty */
|
||||
*nList = (IXML_NodeList *)malloc(sizeof (IXML_NodeList));
|
||||
if (*nList == NULL) {
|
||||
return IXML_INSUFFICIENT_MEMORY;
|
||||
|
Loading…
x
Reference in New Issue
Block a user