Check files can be opened

This commit is contained in:
Bruce Hill 2020-09-16 21:32:08 -07:00
parent c1bc2999ba
commit e7629990be

1
bpeg.c
View File

@ -52,6 +52,7 @@ static char *getflag(const char *flag, char *argv[], int *i)
static int run_match(grammar_t *g, const char *filename, vm_op_t *pattern, unsigned int flags)
{
file_t *f = load_file(filename);
check(f, "Could not open file: %s", filename);
match_t *m = match(g, f, f->contents, pattern, flags);
if (m != NULL && m->end > m->start + 1) {
print_match(f, m);