| 8278 | } |
| 8279 | |
| 8280 | static char *resolve_snippet_source(const char *root_path, const char *file_path, int start, |
| 8281 | int end, char **out_abs_path) { |
| 8282 | *out_abs_path = NULL; |
| 8283 | if (!root_path || !file_path) { |
| 8284 | return NULL; |
| 8285 | } |
| 8286 | size_t apsz = strlen(root_path) + strlen(file_path) + MCP_SEPARATOR; |
| 8287 | char *abs_path = malloc(apsz); |
| 8288 | snprintf(abs_path, apsz, "%s/%s", root_path, file_path); |
| 8289 | |
| 8290 | *out_abs_path = abs_path; |
| 8291 | if (cbm_path_within_root(root_path, abs_path)) { |
| 8292 | return read_file_lines(abs_path, start, end); |
| 8293 | } |
| 8294 | return NULL; |
| 8295 | } |
| 8296 | |
| 8297 | static bool utf8_is_cont(unsigned char c) { |
| 8298 | return (c & 0xC0) == 0x80; |
no test coverage detected