| 1150 | } |
| 1151 | |
| 1152 | static void jl_detect_indent(const char *text, const jl_object_t *object, jl_slice_t *base, |
| 1153 | jl_slice_t *unit, bool *close_indent_only) { |
| 1154 | static const char spaces[] = " "; |
| 1155 | static const char tab[] = "\t"; |
| 1156 | *close_indent_only = jl_line_indent(text, object->close_pos, base); |
| 1157 | unit->data = spaces; |
| 1158 | unit->length = 2U; |
| 1159 | |
| 1160 | if (object->first_key_start == SIZE_MAX) { |
| 1161 | if (base->length > 0U && base->data[base->length - 1U] == '\t') { |
| 1162 | unit->data = tab; |
| 1163 | unit->length = 1U; |
| 1164 | } |
| 1165 | return; |
| 1166 | } |
| 1167 | jl_slice_t member_indent; |
| 1168 | if (!jl_line_indent(text, object->first_key_start, &member_indent)) { |
| 1169 | return; |
| 1170 | } |
| 1171 | if (member_indent.length > base->length && |
| 1172 | (base->length == 0U || memcmp(member_indent.data, base->data, base->length) == 0)) { |
| 1173 | unit->data = member_indent.data + base->length; |
| 1174 | unit->length = member_indent.length - base->length; |
| 1175 | } else if (member_indent.length > 0U && member_indent.data[member_indent.length - 1U] == '\t') { |
| 1176 | unit->data = tab; |
| 1177 | unit->length = 1U; |
| 1178 | } |
| 1179 | } |
| 1180 | |
| 1181 | static int jl_make_insertion(const char *text, size_t length, size_t object_start, |
| 1182 | const jl_object_t *object, const jl_buffer_t *member, |
no test coverage detected