version 1.30, 2019/04/10 14:22:37 |
version 1.31, 2019/04/10 14:34:08 |
Line 632 xml_attrval(struct parse *p, const char *name) |
|
Line 632 xml_attrval(struct parse *p, const char *name) |
|
* If we're at a text node, roll that one up first. |
* If we're at a text node, roll that one up first. |
*/ |
*/ |
static void |
static void |
xml_elem_end(struct parse *ps, const char *name) |
xml_elem_end(struct parse *p, const char *name) |
{ |
{ |
const struct element *elem; |
const struct element *elem; |
struct pnode *n; |
struct pnode *n; |
Line 643 xml_elem_end(struct parse *ps, const char *name) |
|
Line 643 xml_elem_end(struct parse *ps, const char *name) |
|
* An ancestor is excluded from the tree; |
* An ancestor is excluded from the tree; |
* keep track of the number of levels excluded. |
* keep track of the number of levels excluded. |
*/ |
*/ |
if (ps->del > 1) { |
if (p->del > 1) { |
ps->del--; |
p->del--; |
return; |
return; |
} |
} |
|
|
if (ps->del == 0) |
if (p->del == 0) |
pnode_closetext(ps); |
pnode_closetext(p); |
|
|
if (name != NULL) { |
if (name != NULL) { |
for (elem = elements; elem->name != NULL; elem++) |
for (elem = elements; elem->name != NULL; elem++) |
Line 657 xml_elem_end(struct parse *ps, const char *name) |
|
Line 657 xml_elem_end(struct parse *ps, const char *name) |
|
break; |
break; |
node = elem->node; |
node = elem->node; |
} else |
} else |
node = ps->ncur; |
node = p->ncur; |
|
|
switch (node) { |
switch (node) { |
case NODE_DELETE_WARN: |
case NODE_DELETE_WARN: |
case NODE_DELETE: |
case NODE_DELETE: |
if (ps->del > 0) |
if (p->del > 0) |
ps->del--; |
p->del--; |
break; |
break; |
case NODE_IGNORE: |
case NODE_IGNORE: |
break; |
break; |
case NODE_INCLUDE: |
case NODE_INCLUDE: |
n = ps->cur; |
n = p->cur; |
ps->cur = ps->cur->parent; |
p->cur = p->cur->parent; |
cp = pnode_getattr_raw(n, ATTRKEY_HREF, NULL); |
cp = pnode_getattr_raw(n, ATTRKEY_HREF, NULL); |
if (cp == NULL) |
if (cp == NULL) |
error_msg(ps, "<xi:include> element " |
error_msg(p, "<xi:include> element " |
"without href attribute"); |
"without href attribute"); |
else |
else |
parse_file(ps, -1, cp); |
parse_file(p, -1, cp); |
pnode_unlink(n); |
pnode_unlink(n); |
ps->flags &= ~PFLAG_SPC; |
p->flags &= ~PFLAG_SPC; |
break; |
break; |
case NODE_DOCTYPE: |
case NODE_DOCTYPE: |
ps->flags &= ~PFLAG_EEND; |
p->flags &= ~PFLAG_EEND; |
/* FALLTHROUGH */ |
/* FALLTHROUGH */ |
default: |
default: |
if (ps->cur == NULL || node != ps->cur->node) { |
if (p->cur == NULL || node != p->cur->node) { |
warn_msg(ps, "element not open: </%s>", name); |
warn_msg(p, "element not open: </%s>", name); |
break; |
break; |
} |
} |
|
|
Line 695 xml_elem_end(struct parse *ps, const char *name) |
|
Line 695 xml_elem_end(struct parse *ps, const char *name) |
|
* obviously better than discarding it or crashing. |
* obviously better than discarding it or crashing. |
*/ |
*/ |
|
|
if (ps->cur->parent != NULL || node == NODE_DOCTYPE) { |
if (p->cur->parent != NULL || node == NODE_DOCTYPE) { |
ps->cur = ps->cur->parent; |
p->cur = p->cur->parent; |
if (ps->cur != NULL) |
if (p->cur != NULL) |
ps->ncur = ps->cur->node; |
p->ncur = p->cur->node; |
} else |
} else |
ps->tree->flags |= TREE_CLOSED; |
p->tree->flags |= TREE_CLOSED; |
ps->flags &= ~PFLAG_SPC; |
p->flags &= ~PFLAG_SPC; |
break; |
break; |
} |
} |
assert(ps->del == 0); |
assert(p->del == 0); |
} |
} |
|
|
struct parse * |
struct parse * |