mirror of
https://github.com/zoriya/xmlParser.git
synced 2026-06-05 02:49:34 +00:00
Solving a bug
This commit is contained in:
@@ -28,7 +28,7 @@ INCLUDE = -I ./include
|
|||||||
|
|
||||||
CFLAGS = $(INCLUDE) -Wall -Wextra -Wshadow
|
CFLAGS = $(INCLUDE) -Wall -Wextra -Wshadow
|
||||||
|
|
||||||
LDFLAGS = -lmy -L lib/my/
|
LDFLAGS = -lmy -L ../my
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
|
|
||||||
|
|||||||
@@ -21,4 +21,6 @@ Attributes with semi quotes (') instead of quotes (")
|
|||||||
|
|
||||||
Comments
|
Comments
|
||||||
|
|
||||||
The error handling is not fiable yet.
|
String containing multiples following spaces.
|
||||||
|
|
||||||
|
String containing \n, \r or \t (theses specials chars are removed)
|
||||||
@@ -51,8 +51,6 @@ int xml_parsechild(node *n, char **nodestr, bool has_child)
|
|||||||
*p = '\0';
|
*p = '\0';
|
||||||
depth++;
|
depth++;
|
||||||
n->child = xml_parsenode(nodestr);
|
n->child = xml_parsenode(nodestr);
|
||||||
if (!n->child)
|
|
||||||
return (-1);
|
|
||||||
if (xml_checkclosing(n, nodestr) < 0)
|
if (xml_checkclosing(n, nodestr) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
depth--;
|
depth--;
|
||||||
|
|||||||
@@ -56,8 +56,6 @@ node *xml_getnode(node *parent, const char *name)
|
|||||||
if (!my_strcmp(parent->name, name))
|
if (!my_strcmp(parent->name, name))
|
||||||
return (parent);
|
return (parent);
|
||||||
for (node *n = parent->child; n; n = n->next) {
|
for (node *n = parent->child; n; n = n->next) {
|
||||||
if (!my_strcmp(n->name, name))
|
|
||||||
return (n);
|
|
||||||
tmp = xml_getnode(n, name);
|
tmp = xml_getnode(n, name);
|
||||||
if (tmp != NULL)
|
if (tmp != NULL)
|
||||||
return (tmp);
|
return (tmp);
|
||||||
|
|||||||
+1
-1
@@ -13,7 +13,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
if (argc != 2)
|
if (argc != 2)
|
||||||
return (printf("Usage: %s xml_path\n", argv[0]), 0);
|
return (printf("Usage: %s xml_path\n", argv[0]), 0);
|
||||||
node *n = xmlparse(argv[1]);
|
node *n = xml_parse(argv[1]);
|
||||||
xml_destroy(n);
|
xml_destroy(n);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<yes>
|
<yes>
|
||||||
<nop />
|
<nop />
|
||||||
|
<Test>
|
||||||
|
</Test>
|
||||||
</yes>
|
</yes>
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
Test(xml, complete)
|
Test(xml, complete)
|
||||||
{
|
{
|
||||||
node *n = xmlparse("tests/testprolog.txt");
|
node *n = xml_parse("tests/testprolog.txt");
|
||||||
|
|
||||||
cr_assert_str_eq(n->name, "yes");
|
cr_assert_str_eq(n->name, "yes");
|
||||||
cr_assert_eq(n->next, NULL);
|
cr_assert_eq(n->next, NULL);
|
||||||
@@ -19,12 +19,15 @@ Test(xml, complete)
|
|||||||
cr_assert_str_eq(n->child->name, "nop");
|
cr_assert_str_eq(n->child->name, "nop");
|
||||||
cr_assert_eq(n->child->child, NULL);
|
cr_assert_eq(n->child->child, NULL);
|
||||||
cr_assert_eq(n->child->properties, NULL);
|
cr_assert_eq(n->child->properties, NULL);
|
||||||
cr_assert_eq(n->child->next, NULL);
|
cr_assert_str_eq(n->child->next->name, "Test");
|
||||||
|
cr_assert_eq(n->child->next->properties, NULL);
|
||||||
|
cr_assert_eq(n->child->next->child, NULL);
|
||||||
|
cr_assert_eq(n->child->next->next, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
Test(xml, completewstring)
|
Test(xml, completewstring)
|
||||||
{
|
{
|
||||||
node *n = xmlparse("tests/teststring.txt");
|
node *n = xml_parse("tests/teststring.txt");
|
||||||
|
|
||||||
cr_assert_str_eq(n->name, "entity");
|
cr_assert_str_eq(n->name, "entity");
|
||||||
cr_assert_eq(n->next, NULL);
|
cr_assert_eq(n->next, NULL);
|
||||||
|
|||||||
Reference in New Issue
Block a user