File: node_remove.pxi

package info (click to toggle)
python-selectolax 0.4.6-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 708 kB
  • sloc: python: 2,239; makefile: 225
file content (29 lines) | stat: -rw-r--r-- 760 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

cdef lxb_dom_node_t * node_remove_deep(lxb_dom_node_t* root):
    cdef lxb_dom_node_t *tmp
    cdef lxb_dom_node_t *node = root

    while node != NULL:
        if node.first_child != NULL:
            node = node.first_child
        else:
            while node != root and node.next == NULL:
                tmp = node.parent
                lxb_dom_node_remove(node)
                node = tmp

            if node == root:
                lxb_dom_node_remove(node)
                break

            tmp = node.next
            lxb_dom_node_remove(node)
            node = tmp

    return NULL

cdef bint node_is_removed(lxb_dom_node_t* node):
    if node.parent == NULL and node.next == NULL \
       and node.prev == NULL:
        return 1
    return 0