| 6832 | } |
| 6833 | |
| 6834 | static void |
| 6835 | xo_depth_change (xo_handle_t *xop, const char *name, |
| 6836 | int delta, int indent, xo_state_t state, xo_xsf_flags_t flags) |
| 6837 | { |
| 6838 | if (xo_style(xop) == XO_STYLE_HTML || xo_style(xop) == XO_STYLE_TEXT) |
| 6839 | indent = 0; |
| 6840 | |
| 6841 | if (XOF_ISSET(xop, XOF_DTRT)) |
| 6842 | flags |= XSF_DTRT; |
| 6843 | |
| 6844 | if (delta >= 0) { /* Push operation */ |
| 6845 | if (xo_depth_check(xop, xop->xo_depth + delta)) |
| 6846 | return; |
| 6847 | |
| 6848 | xo_stack_t *xsp = &xop->xo_stack[xop->xo_depth + delta]; |
| 6849 | xsp->xs_flags = flags; |
| 6850 | xsp->xs_state = state; |
| 6851 | xo_stack_set_flags(xop); |
| 6852 | |
| 6853 | if (name == NULL) |
| 6854 | name = XO_FAILURE_NAME; |
| 6855 | |
| 6856 | xsp->xs_name = xo_strndup(name, -1); |
| 6857 | |
| 6858 | } else { /* Pop operation */ |
| 6859 | if (xop->xo_depth == 0) { |
| 6860 | if (!XOF_ISSET(xop, XOF_IGNORE_CLOSE)) |
| 6861 | xo_failure(xop, "close with empty stack: '%s'", name); |
| 6862 | return; |
| 6863 | } |
| 6864 | |
| 6865 | xo_stack_t *xsp = &xop->xo_stack[xop->xo_depth]; |
| 6866 | if (XOF_ISSET(xop, XOF_WARN)) { |
| 6867 | const char *top = xsp->xs_name; |
| 6868 | if (top != NULL && name != NULL && !xo_streq(name, top)) { |
| 6869 | xo_failure(xop, "incorrect close: '%s' .vs. '%s'", |
| 6870 | name, top); |
| 6871 | return; |
| 6872 | } |
| 6873 | if ((xsp->xs_flags & XSF_LIST) != (flags & XSF_LIST)) { |
| 6874 | xo_failure(xop, "list close on list confict: '%s'", |
| 6875 | name); |
| 6876 | return; |
| 6877 | } |
| 6878 | if ((xsp->xs_flags & XSF_INSTANCE) != (flags & XSF_INSTANCE)) { |
| 6879 | xo_failure(xop, "list close on instance confict: '%s'", |
| 6880 | name); |
| 6881 | return; |
| 6882 | } |
| 6883 | } |
| 6884 | |
| 6885 | if (xsp->xs_name) { |
| 6886 | xo_free(xsp->xs_name); |
| 6887 | xsp->xs_name = NULL; |
| 6888 | } |
| 6889 | if (xsp->xs_keys) { |
| 6890 | xo_free(xsp->xs_keys); |
| 6891 | xsp->xs_keys = NULL; |
no test coverage detected