| 8335 | } |
| 8336 | |
| 8337 | static char *resolve_snippet_source(const char *root_path, const char *file_path, int start, |
| 8338 | int end, char **out_abs_path) { |
| 8339 | *out_abs_path = NULL; |
| 8340 | if (!root_path || !file_path) { |
| 8341 | return NULL; |
| 8342 | } |
| 8343 | size_t apsz = strlen(root_path) + strlen(file_path) + MCP_SEPARATOR; |
| 8344 | char *abs_path = malloc(apsz); |
| 8345 | snprintf(abs_path, apsz, "%s/%s", root_path, file_path); |
| 8346 | |
| 8347 | *out_abs_path = abs_path; |
| 8348 | if (cbm_path_within_root(root_path, abs_path)) { |
| 8349 | return read_file_lines(abs_path, start, end); |
| 8350 | } |
| 8351 | return NULL; |
| 8352 | } |
| 8353 | |
| 8354 | static bool utf8_is_cont(unsigned char c) { |
| 8355 | return (c & 0xC0) == 0x80; |
no test coverage detected