1 /* Auxiliary program to test a DFA code path that cannot be triggered
3 Copyright 2014-2025 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
26 #include <localeinfo.h>
28 #include "binary-io.h"
31 dfaerror (char const *mesg
)
33 printf ("dfaerror: %s\n", mesg
);
37 static int exit_status
= EXIT_SUCCESS
;
40 dfawarn (char const *mesg
)
42 printf ("dfawarn: %s\n", mesg
);
43 exit_status
= EXIT_FAILURE
;
47 main (int argc
, char **argv
)
52 struct localeinfo localeinfo
;
57 /* This test's fixture needs to compare this program's output with an expected
58 output. On native Windows, the CR-LF newlines would cause this comparison
59 to fail. But we don't want to postprocess this program's output. */
60 set_binary_mode (STDOUT_FILENO
, O_BINARY
);
62 setlocale (LC_ALL
, "");
63 init_localeinfo (&localeinfo
);
66 dfasyntax (dfa
, &localeinfo
, RE_SYNTAX_EGREP
| RE_NO_EMPTY_RANGES
, 0);
67 dfacomp (argv
[1], strlen (argv
[1]), dfa
, 0);
70 end
= argv
[2] + strlen (argv
[2]);
71 allow_nl
= argc
> 3 && atoi (argv
[3]);
73 p
= dfaexec (dfa
, beg
, end
, allow_nl
, NULL
, NULL
);
76 printf ("%zd\n", p
- beg
);