| 832 | } |
| 833 | |
| 834 | int cmark_node_check(cmark_node *node, FILE *out) { |
| 835 | cmark_node *cur; |
| 836 | int errors = 0; |
| 837 | |
| 838 | if (!node) { |
| 839 | return 0; |
| 840 | } |
| 841 | |
| 842 | cur = node; |
| 843 | for (;;) { |
| 844 | if (cur->first_child) { |
| 845 | if (cur->first_child->prev != NULL) { |
| 846 | S_print_error(out, cur->first_child, "prev"); |
| 847 | cur->first_child->prev = NULL; |
| 848 | ++errors; |
| 849 | } |
| 850 | if (cur->first_child->parent != cur) { |
| 851 | S_print_error(out, cur->first_child, "parent"); |
| 852 | cur->first_child->parent = cur; |
| 853 | ++errors; |
| 854 | } |
| 855 | cur = cur->first_child; |
| 856 | continue; |
| 857 | } |
| 858 | |
| 859 | next_sibling: |
| 860 | if (cur == node) { |
| 861 | break; |
| 862 | } |
| 863 | if (cur->next) { |
| 864 | if (cur->next->prev != cur) { |
| 865 | S_print_error(out, cur->next, "prev"); |
| 866 | cur->next->prev = cur; |
| 867 | ++errors; |
| 868 | } |
| 869 | if (cur->next->parent != cur->parent) { |
| 870 | S_print_error(out, cur->next, "parent"); |
| 871 | cur->next->parent = cur->parent; |
| 872 | ++errors; |
| 873 | } |
| 874 | cur = cur->next; |
| 875 | continue; |
| 876 | } |
| 877 | |
| 878 | if (cur->parent->last_child != cur) { |
| 879 | S_print_error(out, cur->parent, "last_child"); |
| 880 | cur->parent->last_child = cur; |
| 881 | ++errors; |
| 882 | } |
| 883 | cur = cur->parent; |
| 884 | goto next_sibling; |
| 885 | } |
| 886 | |
| 887 | return errors; |
| 888 | } |
no test coverage detected