This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH: fix fixincludes fake warnings
- To: gcc-patches at gcc dot gnu dot org
- Subject: PATCH: fix fixincludes fake warnings
- From: "Laurynas Biveinis" <lauras at softhome dot net>
- Date: Sun, 28 Jan 2001 13:16:29 +0200
Fixincludes under DJGPP generates tens of following error messages -
error 22 (No such file or directory)) opening output (c:/djgpp/tmp/fxincaa)
for read.
However, this error is completely bogus, because fixer does not make
any output file at all if no patching is required.
Please consider this patch (tested under i686-pc-msdosdjgpp and
i686-pc-linux-gnu):
2001-01-28 Laurynas Biveinis <lauras@softhome.net>
* fixinc/fixincl.c (process): check if pz_temp_file exists
before opening it.
Index: fixincl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.c,v
retrieving revision 1.49
diff -u -u -p -r1.49 fixincl.c
--- fixincl.c 2001/01/05 16:28:58 1.49
+++ fixincl.c 2001/01/28 11:14:36
@@ -1428,21 +1428,23 @@ process ()
pz_file_source = pz_temp_file;
}
- read_fd = open (pz_temp_file, O_RDONLY);
- if (read_fd < 0)
+ if (!access(pz_temp_file, R_OK))
{
- fprintf (stderr, "error %d (%s) opening output (%s) for read\n",
- errno, xstrerror (errno), pz_temp_file);
+ read_fd = open (pz_temp_file, O_RDONLY);
+ if (read_fd < 0)
+ {
+ fprintf (stderr, "error %d (%s) opening output (%s) for read\n",
+ errno, xstrerror (errno), pz_temp_file);
+ }
+ else
+ {
+ test_for_changes (read_fd);
+ /* Unlinking a file while it is still open is a Bad Idea on
+ DOS/Windows. */
+ close (read_fd);
+ unlink (pz_temp_file);
+ }
}
- else
- {
- test_for_changes (read_fd);
- /* Unlinking a file while it is still open is a Bad Idea on
- DOS/Windows. */
- close (read_fd);
- unlink (pz_temp_file);
- }
-
# endif
UNLOAD_DATA();
}