/* Sorry, but this is just a test program. */
char pat
[500]; /* Sorry for that maximum size, too. */
struct re_pattern_buffer buf
;
char fastmap
[(1 << BYTEWIDTH
)];
/* Actually, it might be useful to allow the data file to be standard
input, and to specify the pattern on the command line. */
fprintf (stderr
, "Usage: %s <filename>.\n", argv
[0]);
f
= fopen (filename
, "r");
printf ("Pattern = ", pat
);
compile_ret
= re_compile_pattern (pat
, strlen (pat
), &buf
);
fprintf (stderr
, "%s: %s\n", pat
, compile_ret
);
while (fgets (line
, LINE_MAX
, f
) != NULL
)
size_t len
= strlen (line
);
struct re_registers regs
;
= re_search_2 (&buf
, NULL
, 0, line
, len
, 0, len
, ®s
, len
);
fprintf (stderr
, "%s:%d: re_search failed.\n", filename
, lineno
);
nfound
+= search_ret
!= -1;
printf ("Matches found: %u (out of %u lines).\n", nfound
, lineno
- 1);