| 7113 | } |
| 7114 | |
| 7115 | static int |
| 7116 | xo_do_open_list (xo_handle_t *xop, xo_xof_flags_t flags, const char *name) |
| 7117 | { |
| 7118 | ssize_t rc = 0; |
| 7119 | int indent = 0; |
| 7120 | |
| 7121 | xop = xo_default(xop); |
| 7122 | |
| 7123 | const char *ppn = XOF_ISSET(xop, XOF_PRETTY) ? "\n" : ""; |
| 7124 | const char *pre_nl = ""; |
| 7125 | |
| 7126 | switch (xo_style(xop)) { |
| 7127 | case XO_STYLE_JSON: |
| 7128 | |
| 7129 | indent = 1; |
| 7130 | if (!XOF_ISSET(xop, XOF_NO_TOP) |
| 7131 | && !XOIF_ISSET(xop, XOIF_TOP_EMITTED)) |
| 7132 | xo_emit_top(xop, ppn); |
| 7133 | |
| 7134 | if (name == NULL) { |
| 7135 | xo_failure(xop, "NULL passed for list name"); |
| 7136 | name = XO_FAILURE_NAME; |
| 7137 | } |
| 7138 | |
| 7139 | xo_stack_set_flags(xop); |
| 7140 | |
| 7141 | if (xop->xo_stack[xop->xo_depth].xs_flags & XSF_NOT_FIRST) |
| 7142 | pre_nl = XOF_ISSET(xop, XOF_PRETTY) ? ",\n" : ", "; |
| 7143 | xop->xo_stack[xop->xo_depth].xs_flags |= XSF_NOT_FIRST; |
| 7144 | |
| 7145 | rc = xo_printf(xop, "%s%*s\"%s\": [%s", |
| 7146 | pre_nl, xo_indent(xop), "", name, ppn); |
| 7147 | break; |
| 7148 | |
| 7149 | case XO_STYLE_ENCODER: |
| 7150 | rc = xo_encoder_handle(xop, XO_OP_OPEN_LIST, name, NULL, flags); |
| 7151 | break; |
| 7152 | } |
| 7153 | |
| 7154 | xo_depth_change(xop, name, 1, indent, XSS_OPEN_LIST, |
| 7155 | XSF_LIST | xo_stack_flags(flags)); |
| 7156 | |
| 7157 | return rc; |
| 7158 | } |
| 7159 | |
| 7160 | xo_ssize_t |
| 7161 | xo_open_list_hf (xo_handle_t *xop, xo_xof_flags_t flags, const char *name) |
no test coverage detected