| 491 | `------------------------------------------------------------------------*/ |
| 492 | |
| 493 | static void |
| 494 | swallow_file_in_memory (char const *file_name, BLOCK *block) |
| 495 | { |
| 496 | size_t used_length; /* used length in memory buffer */ |
| 497 | |
| 498 | /* As special cases, a file name which is null or "-" indicates standard |
| 499 | input, which is already opened. In all other cases, open the file from |
| 500 | its name. */ |
| 501 | bool using_stdin = !file_name || !*file_name || streq (file_name, "-"); |
| 502 | if (using_stdin) |
| 503 | block->start = fread_file (stdin, 0, &used_length); |
| 504 | else |
| 505 | block->start = read_file (file_name, 0, &used_length); |
| 506 | |
| 507 | if (!block->start) |
| 508 | error (EXIT_FAILURE, errno, "%s", quotef (using_stdin ? "-" : file_name)); |
| 509 | |
| 510 | if (using_stdin) |
| 511 | clearerr (stdin); |
| 512 | |
| 513 | block->end = block->start + used_length; |
| 514 | } |
| 515 | |
| 516 | /* Sort and search routines. */ |
| 517 |
no outgoing calls
no test coverage detected