| 203 | } |
| 204 | |
| 205 | static void fail_mismatch(const char *filename, |
| 206 | const char *raw, const char *pos, |
| 207 | size_t len, struct bolt_file *bolt) |
| 208 | { |
| 209 | unsigned line = linenum(raw, &pos); |
| 210 | char *try; |
| 211 | |
| 212 | fprintf(stderr, "%s:%u:mismatch:%.*s\n", |
| 213 | filename, line, (int)strcspn(pos, "\n"), pos); |
| 214 | /* Try to find longest match, as a hint. */ |
| 215 | try = code_to_regex(pos + strcspn(pos, "\n"), len, false); |
| 216 | while (strlen(try)) { |
| 217 | const char *p = strstr(bolt->contents, try); |
| 218 | if (p) { |
| 219 | fprintf(stderr, "Closest match: %s...[%.20s]\n", |
| 220 | try, p + strlen(try)); |
| 221 | break; |
| 222 | } |
| 223 | try[strlen(try)-1] = '\0'; |
| 224 | } |
| 225 | exit(1); |
| 226 | } |
| 227 | |
| 228 | static void fail_nobolt(const char *filename, |
| 229 | const char *raw, const char *pos, |
no test coverage detected