| 988 | } |
| 989 | |
| 990 | static int toml_append_managed(toml_buffer_t *output, const char *begin_marker, |
| 991 | const char *end_marker, const char *block, const char *newline) { |
| 992 | size_t block_len = strlen(block); |
| 993 | if (toml_buffer_append_cstr(output, begin_marker) != TOML_EDIT_OK || |
| 994 | toml_buffer_append_cstr(output, newline) != TOML_EDIT_OK || |
| 995 | toml_append_normalized_text(output, block, block_len, newline) != TOML_EDIT_OK) { |
| 996 | return TOML_EDIT_ERR; |
| 997 | } |
| 998 | if (block_len != 0 && block[block_len - 1] != '\n' && |
| 999 | toml_buffer_append_cstr(output, newline) != TOML_EDIT_OK) { |
| 1000 | return TOML_EDIT_ERR; |
| 1001 | } |
| 1002 | return toml_buffer_append_cstr(output, end_marker) == TOML_EDIT_OK && |
| 1003 | toml_buffer_append_cstr(output, newline) == TOML_EDIT_OK |
| 1004 | ? TOML_EDIT_OK |
| 1005 | : TOML_EDIT_ERR; |
| 1006 | } |
| 1007 | |
| 1008 | int cbm_toml_escape_basic_string(const char *input, char *out, size_t out_size) { |
| 1009 | if (!input || !out || out_size == 0) { |
no test coverage detected