Skip one recursive function call for leaf nodes at the cost of a bit of code size. Fix comment support in some cases
This commit is contained in:
parent
4e7fde12b3
commit
745277ec4a
3 changed files with 68 additions and 22 deletions
|
@ -60,7 +60,7 @@
|
||||||
<YF23>
|
<YF23>
|
||||||
<script><![CDATA[
|
<script><![CDATA[
|
||||||
# If the ground-roll-heading-hold has been reset (<-999) set:
|
# If the ground-roll-heading-hold has been reset (<-999) set:
|
||||||
if(agl > 50) {
|
if(agl > 50) {};
|
||||||
]]></script>
|
]]></script>
|
||||||
</YF23>
|
</YF23>
|
||||||
</nasal>
|
</nasal>
|
||||||
|
|
|
@ -14,6 +14,31 @@ int main()
|
||||||
if (root_id)
|
if (root_id)
|
||||||
{
|
{
|
||||||
void *path_id, *node_id;
|
void *path_id, *node_id;
|
||||||
|
char *s;
|
||||||
|
|
||||||
|
printf("\nTesting xmlNodeGetString for /Configuration/output/test:\t\t");
|
||||||
|
s = xmlNodeGetString(root_id , "/Configuration/output/test");
|
||||||
|
if (s)
|
||||||
|
{
|
||||||
|
printf("failed.\n\t'%s' should be empty\n", s);
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("succes.\n");
|
||||||
|
|
||||||
|
printf("Testing xmlGetString for Configuration/output/test:\t\t\t");
|
||||||
|
path_id = xmlNodeGet(root_id, "*/*/test");
|
||||||
|
if (path_id)
|
||||||
|
{
|
||||||
|
s = xmlGetString(path_id);
|
||||||
|
if (s)
|
||||||
|
{
|
||||||
|
printf("failed.\n\t'%s' should be empty\n", s);
|
||||||
|
free(s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("succes.\n");
|
||||||
|
}
|
||||||
|
|
||||||
path_id = xmlNodeGet(root_id, PATH);
|
path_id = xmlNodeGet(root_id, PATH);
|
||||||
node_id = xmlNodeGet(root_id, ROOTNODE);
|
node_id = xmlNodeGet(root_id, ROOTNODE);
|
||||||
|
@ -22,20 +47,8 @@ int main()
|
||||||
{
|
{
|
||||||
char buf[BUFLEN];
|
char buf[BUFLEN];
|
||||||
size_t len;
|
size_t len;
|
||||||
char *s;
|
|
||||||
|
|
||||||
len = xmlNodeCopyString(root_id, PATH, buf, BUFLEN);
|
xmlCopyString(path_id, buf, BUFLEN);
|
||||||
printf("%s = '%s'\n", PATH, buf);
|
|
||||||
|
|
||||||
printf("Testing value of /Configuration/output/test:\t\t\t\t");
|
|
||||||
s = xmlNodeGetString(root_id , "/Configuration/output/test");
|
|
||||||
if (s)
|
|
||||||
{
|
|
||||||
printf("failed.\n\t'%s' shoudl be empty\n", s);
|
|
||||||
free(s);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
printf("succes.\n");
|
|
||||||
|
|
||||||
printf("Testing xmlNodeCopyString against xmlGetString:\t\t\t\t");
|
printf("Testing xmlNodeCopyString against xmlGetString:\t\t\t\t");
|
||||||
if ((s = xmlGetString(path_id)) != 0)
|
if ((s = xmlGetString(path_id)) != 0)
|
||||||
|
@ -150,6 +163,7 @@ int main()
|
||||||
|
|
||||||
xmlClose(root_id);
|
xmlClose(root_id);
|
||||||
}
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1511,6 +1511,38 @@ __xmlNodeGet(const char *start, size_t *len, char **name, size_t *rlen, size_t *
|
||||||
cur = new;
|
cur = new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (*cur == '/') /* closing tag of leaf node found */
|
||||||
|
{
|
||||||
|
if (!strncasecmp(new+1, element, elementlen))
|
||||||
|
{
|
||||||
|
if (*(new+elementlen+1) != '>')
|
||||||
|
SET_ERROR_AND_RETURN(new+1, XML_ELEMENT_NO_CLOSING_TAG);
|
||||||
|
|
||||||
|
if (found == num)
|
||||||
|
{
|
||||||
|
if (start_tag)
|
||||||
|
{
|
||||||
|
*len = new-ret-1;
|
||||||
|
open_element = start_tag;
|
||||||
|
cdata = (char *)start;
|
||||||
|
start_tag = 0;
|
||||||
|
}
|
||||||
|
else /* report error */
|
||||||
|
SET_ERROR_AND_RETURN(new, XML_ELEMENT_NO_OPENING_TAG);
|
||||||
|
}
|
||||||
|
found++;
|
||||||
|
}
|
||||||
|
|
||||||
|
new = memchr(cur, '>', restlen);
|
||||||
|
if (!new)
|
||||||
|
SET_ERROR_AND_RETURN(cur, XML_ELEMENT_NO_CLOSING_TAG);
|
||||||
|
|
||||||
|
restlen -= new-cur;
|
||||||
|
cur = new;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* no leaf node, continue */
|
||||||
if (*cur != '/') /* cascading tag found */
|
if (*cur != '/') /* cascading tag found */
|
||||||
{
|
{
|
||||||
char *node = "*";
|
char *node = "*";
|
||||||
|
@ -1617,8 +1649,8 @@ __xmlProcessCDATA(char **start, size_t *len)
|
||||||
new = __xmlCommentSkip(cur, restlen);
|
new = __xmlCommentSkip(cur, restlen);
|
||||||
if (new)
|
if (new)
|
||||||
{
|
{
|
||||||
*start += 3; /* !-- */
|
*start = new;
|
||||||
*len = (*start-cur)-3; /* --> */
|
*len = 0;
|
||||||
}
|
}
|
||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
@ -1640,7 +1672,7 @@ __xmlProcessCDATA(char **start, size_t *len)
|
||||||
{
|
{
|
||||||
if ((restlen > 3) && (memcmp(new, "]]>", 3) == 0))
|
if ((restlen > 3) && (memcmp(new, "]]>", 3) == 0))
|
||||||
{
|
{
|
||||||
*len = new - *start;
|
*len = new-1 - *start;
|
||||||
restlen -= 3;
|
restlen -= 3;
|
||||||
new += 3;
|
new += 3;
|
||||||
break;
|
break;
|
||||||
|
@ -1678,14 +1710,15 @@ __xmlCommentSkip(const char *start, size_t len)
|
||||||
new = memchr(cur, '-', len);
|
new = memchr(cur, '-', len);
|
||||||
if (new)
|
if (new)
|
||||||
{
|
{
|
||||||
len -= new - cur;
|
len -= new-cur;
|
||||||
if ((len >= 3) && (memcmp(new, "-->", 3) == 0))
|
if ((len >= 3) && (memcmp(new, "-->", 3) == 0))
|
||||||
{
|
{
|
||||||
new += 3;
|
new += 3;
|
||||||
len -= 3;
|
/* len -= 3; */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cur = new+1;
|
cur = new+1;
|
||||||
|
len -= cur-new;
|
||||||
}
|
}
|
||||||
else break;
|
else break;
|
||||||
}
|
}
|
||||||
|
@ -1737,11 +1770,10 @@ __xmlPrepareData(char **start, size_t *blocklen)
|
||||||
size_t blocklen = len-1;
|
size_t blocklen = len-1;
|
||||||
if (blocklen >= 6) /* !-- --> */
|
if (blocklen >= 6) /* !-- --> */
|
||||||
{
|
{
|
||||||
char *new = __xmlProcessCDATA(&start, &blocklen);
|
char *new = __xmlProcessCDATA(&start, &len);
|
||||||
if (new)
|
if (new)
|
||||||
{
|
{
|
||||||
ps = start;
|
ps = start;
|
||||||
len = blocklen;
|
|
||||||
pe = ps + len;
|
pe = ps + len;
|
||||||
|
|
||||||
while ((ps<pe) && isspace(*ps)) ps++;
|
while ((ps<pe) && isspace(*ps)) ps++;
|
||||||
|
|
Loading…
Reference in a new issue