| 86 | } |
| 87 | |
| 88 | static char *jl_read(const char *path) { |
| 89 | FILE *file = cbm_fopen(path, "rb"); |
| 90 | if (!file || fseek(file, 0, SEEK_END) != 0) { |
| 91 | if (file) { |
| 92 | fclose(file); |
| 93 | } |
| 94 | return NULL; |
| 95 | } |
| 96 | long size = ftell(file); |
| 97 | if (size < 0 || fseek(file, 0, SEEK_SET) != 0) { |
| 98 | fclose(file); |
| 99 | return NULL; |
| 100 | } |
| 101 | char *content = malloc((size_t)size + 1U); |
| 102 | if (!content) { |
| 103 | fclose(file); |
| 104 | return NULL; |
| 105 | } |
| 106 | size_t read_count = fread(content, 1U, (size_t)size, file); |
| 107 | int failed = ferror(file); |
| 108 | fclose(file); |
| 109 | if (read_count != (size_t)size || failed) { |
| 110 | free(content); |
| 111 | return NULL; |
| 112 | } |
| 113 | content[read_count] = '\0'; |
| 114 | return content; |
| 115 | } |
| 116 | |
| 117 | static int jl_failed_unchanged(const char *path, const char *original, |
| 118 | const char *const *object_path, size_t path_len, const char *key, |
no test coverage detected