MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlGetLineNoInternal

Function xmlGetLineNoInternal

ThirdParty/libxml2/vtklibxml2/tree.c:4744–4782  ·  view source on GitHub ↗

* xmlGetLineNoInternal: * @node: valid node * @depth: used to limit any risk of recursion * * Get line number of @node. * Try to override the limitation of lines being store in 16 bits ints * * Returns the line number if successful, -1 otherwise */

Source from the content-addressed store, hash-verified

4742 * Returns the line number if successful, -1 otherwise
4743 */
4744static long
4745xmlGetLineNoInternal(const xmlNode *node, int depth)
4746{
4747 long result = -1;
4748
4749 if (depth >= 5)
4750 return(-1);
4751
4752 if (!node)
4753 return result;
4754 if ((node->type == XML_ELEMENT_NODE) ||
4755 (node->type == XML_TEXT_NODE) ||
4756 (node->type == XML_COMMENT_NODE) ||
4757 (node->type == XML_PI_NODE)) {
4758 if (node->line == 65535) {
4759 if ((node->type == XML_TEXT_NODE) && (node->psvi != NULL))
4760 result = (long) (ptrdiff_t) node->psvi;
4761 else if ((node->type == XML_ELEMENT_NODE) &&
4762 (node->children != NULL))
4763 result = xmlGetLineNoInternal(node->children, depth + 1);
4764 else if (node->next != NULL)
4765 result = xmlGetLineNoInternal(node->next, depth + 1);
4766 else if (node->prev != NULL)
4767 result = xmlGetLineNoInternal(node->prev, depth + 1);
4768 }
4769 if ((result == -1) || (result == 65535))
4770 result = (long) node->line;
4771 } else if ((node->prev != NULL) &&
4772 ((node->prev->type == XML_ELEMENT_NODE) ||
4773 (node->prev->type == XML_TEXT_NODE) ||
4774 (node->prev->type == XML_COMMENT_NODE) ||
4775 (node->prev->type == XML_PI_NODE)))
4776 result = xmlGetLineNoInternal(node->prev, depth + 1);
4777 else if ((node->parent != NULL) &&
4778 (node->parent->type == XML_ELEMENT_NODE))
4779 result = xmlGetLineNoInternal(node->parent, depth + 1);
4780
4781 return result;
4782}
4783
4784/**
4785 * xmlGetLineNo:

Callers 1

xmlGetLineNoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected