| 387 | } |
| 388 | |
| 389 | static int grep_file(struct grep_opt *opt, const char *filename) |
| 390 | { |
| 391 | struct strbuf buf = STRBUF_INIT; |
| 392 | struct grep_source gs; |
| 393 | |
| 394 | grep_source_name(opt, filename, 0, &buf); |
| 395 | grep_source_init_file(&gs, buf.buf, filename); |
| 396 | strbuf_release(&buf); |
| 397 | |
| 398 | if (num_threads > 1) { |
| 399 | /* |
| 400 | * add_work() copies gs and thus assumes ownership of |
| 401 | * its fields, so do not call grep_source_clear() |
| 402 | */ |
| 403 | add_work(opt, &gs); |
| 404 | return 0; |
| 405 | } else { |
| 406 | int hit; |
| 407 | |
| 408 | hit = grep_source(opt, &gs); |
| 409 | |
| 410 | grep_source_clear(&gs); |
| 411 | return hit; |
| 412 | } |
| 413 | } |
| 414 | |
| 415 | static void append_path(struct grep_opt *opt, const void *data, size_t len) |
| 416 | { |
no test coverage detected