| 8344 | } |
| 8345 | |
| 8346 | static char *resolve_snippet_source(const char *root_path, const char *file_path, int start, |
| 8347 | int end, char **out_abs_path) { |
| 8348 | *out_abs_path = NULL; |
| 8349 | if (!root_path || !file_path) { |
| 8350 | return NULL; |
| 8351 | } |
| 8352 | size_t apsz = strlen(root_path) + strlen(file_path) + MCP_SEPARATOR; |
| 8353 | char *abs_path = malloc(apsz); |
| 8354 | snprintf(abs_path, apsz, "%s/%s", root_path, file_path); |
| 8355 | |
| 8356 | *out_abs_path = abs_path; |
| 8357 | if (cbm_path_within_root(root_path, abs_path)) { |
| 8358 | return read_file_lines(abs_path, start, end); |
| 8359 | } |
| 8360 | return NULL; |
| 8361 | } |
| 8362 | |
| 8363 | static bool utf8_is_cont(unsigned char c) { |
| 8364 | return (c & 0xC0) == 0x80; |
no test coverage detected