MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xo_depth_change

Function xo_depth_change

tools/libxo/libxo/libxo.c:6834–6897  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6832}
6833
6834static void
6835xo_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;

Callers 11

xo_do_open_containerFunction · 0.85
xo_do_close_containerFunction · 0.85
xo_do_open_listFunction · 0.85
xo_do_close_listFunction · 0.85
xo_do_open_leaf_listFunction · 0.85
xo_do_close_leaf_listFunction · 0.85
xo_do_open_instanceFunction · 0.85
xo_do_close_instanceFunction · 0.85
xo_do_close_allFunction · 0.85
xo_open_marker_hFunction · 0.85
xo_explicit_transitionFunction · 0.85

Calls 6

xo_styleFunction · 0.85
xo_depth_checkFunction · 0.85
xo_stack_set_flagsFunction · 0.85
xo_strndupFunction · 0.85
xo_failureFunction · 0.85
xo_streqFunction · 0.85

Tested by

no test coverage detected