| 1730 | } |
| 1731 | |
| 1732 | static int yaml_decode_scalar(const char *data, size_t start, size_t end, char **out_value) { |
| 1733 | start = yaml_skip_spaces(data, start, end); |
| 1734 | end = yaml_trim_spaces_end(data, start, end); |
| 1735 | if (start == end || end - start > YAML_ITEM_MAX) { |
| 1736 | return YAML_ERROR; |
| 1737 | } |
| 1738 | |
| 1739 | yaml_buf_t decoded = {0}; |
| 1740 | int rc = 0; |
| 1741 | if (data[start] == '\'') { |
| 1742 | rc = yaml_decode_single_quoted(data, start, end, &decoded); |
| 1743 | } else if (data[start] == '"') { |
| 1744 | rc = yaml_decode_double_quoted(data, start, end, &decoded); |
| 1745 | } else { |
| 1746 | rc = yaml_decode_plain(data, start, end, &decoded); |
| 1747 | } |
| 1748 | |
| 1749 | if (rc != 0 || decoded.len == 0U || yaml_validate_utf8(decoded.data, decoded.len) != 0) { |
| 1750 | yaml_buf_free(&decoded); |
| 1751 | return YAML_ERROR; |
| 1752 | } |
| 1753 | *out_value = decoded.data; |
| 1754 | return 0; |
| 1755 | } |
| 1756 | |
| 1757 | static void yaml_item_vec_free(yaml_item_vec_t *items) { |
| 1758 | for (size_t i = 0; i < items->len; i++) { |
no test coverage detected