class Corpus {
public:
- Corpus(int fd, IOUringEngine *engine);
+ Corpus(int fd, const char *filename_for_errors, IOUringEngine *engine);
~Corpus();
void find_trigram(uint32_t trgm, function<void(const Trigram *trgmptr, size_t len)> cb);
void get_compressed_filename_block(uint32_t docid, function<void(string_view)> cb) const;
Header hdr;
};
-Corpus::Corpus(int fd, IOUringEngine *engine)
+Corpus::Corpus(int fd, const char *filename_for_errors, IOUringEngine *engine)
: fd(fd), engine(engine)
{
if (flush_cache) {
complete_pread(fd, &hdr, sizeof(hdr), /*offset=*/0);
if (memcmp(hdr.magic, "\0plocate", 8) != 0) {
- fprintf(stderr, "plocate.db is corrupt or an old version; please rebuild it.\n");
+ fprintf(stderr, "%s: database is corrupt or not a plocate database; please rebuild it.\n", filename_for_errors);
exit(1);
}
if (hdr.version != 0 && hdr.version != 1) {
- fprintf(stderr, "plocate.db has version %u, expected 0 or 1; please rebuild it.\n", hdr.version);
+ fprintf(stderr, "%s: has version %u, expected 0 or 1; please rebuild it.\n", filename_for_errors, hdr.version);
exit(1);
}
if (hdr.version == 0) {
}
IOUringEngine engine(/*slop_bytes=*/16); // 16 slop bytes as described in turbopfor.h.
- Corpus corpus(fd, &engine);
+ Corpus corpus(fd, filename.c_str(), &engine);
dprintf("Corpus init done after %.1f ms.\n", 1e3 * duration<float>(steady_clock::now() - start).count());
vector<TrigramDisjunction> trigram_groups;
static const struct option long_options[] = {
{ "help", no_argument, 0, 'h' },
{ "count", no_argument, 0, 'c' },
+ { "all", no_argument, 0, 'A' },
{ "basename", no_argument, 0, 'b' },
{ "database", required_argument, 0, 'd' },
{ "existing", no_argument, 0, 'e' },
setlocale(LC_ALL, "");
for (;;) {
int option_index = 0;
- int c = getopt_long(argc, argv, "bcd:ehil:n:N0rwVD", long_options, &option_index);
+ int c = getopt_long(argc, argv, "Abcd:ehil:n:N0rwVD", long_options, &option_index);
if (c == -1) {
break;
}
switch (c) {
+ case 'A':
+ // Ignored.
+ break;
case 'b':
match_basename = true;
break;
needle.re = compile_regex(needle.str);
} else if (any_wildcard) {
needle.type = Needle::GLOB;
- } else if (ignore_case) {
+ } else if (ignore_case && false) {
// strcasestr() doesn't handle locales correctly (even though LSB
// claims it should), but somehow, fnmatch() does, and it's about
// the same speed as using a regex.