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