From 184b42c85be3d42c958173c550ea442baf96a8cd Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 4 Dec 2013 09:30:08 +0100 Subject: output: do not generate source files when early errors are caught Reported by Alexandre Duret-Lutz as "second problem" in: http://lists.gnu.org/archive/html/bug-bison/2013-09/msg00015.html One problem is that some errors are caught early, before the generation of output files, while others can only be detected afterwards (since, for instance, skeletons can raise errors themselves). This will be addressed in two steps: early errors do not generate source files at all, while later errors will remove the files that have already been generated. * src/scan-skel.l (yyout): Open to /dev/null when there are errors. * tests/output.at (AT_CHECK_FILES): Factored out of... (AT_CHECK_OUTPUT): this. Fuse the "SHELLIO" argument in the "FLAGS" one. Use $5 to denote the expected exit status. Add a test case for early errors. --- src/scan-skel.l | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/scan-skel.l b/src/scan-skel.l index f13ee813..48c5e46a 100644 --- a/src/scan-skel.l +++ b/src/scan-skel.l @@ -245,7 +245,8 @@ at_output (int argc, char *argv[], char **out_namep, int *out_linenop) } *out_namep = xstrdup (argv[1]); output_file_name_check (out_namep); - yyout = xfopen (*out_namep, "w"); + /* If there were errors, do not generate the output. */ + yyout = xfopen (complaint_status ? "/dev/null" : *out_namep, "w"); *out_linenop = 1; } -- cgit v1.2.1