This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH,Fortran] Fix libgfortran/io/close.c for !HAVE_UNLINK_OPEN_FILE
- From: Gerald Pfeifer <gerald at pfeifer dot com>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org, Janne Blomqvist <jb at gcc dot gnu dot org>
- Date: Tue, 2 Oct 2018 13:08:42 +0200 (CEST)
- Subject: [PATCH,Fortran] Fix libgfortran/io/close.c for !HAVE_UNLINK_OPEN_FILE
Revision r215307 | jb | 2014-09-16 23:40:28 +0200 (Di, 16 Sep 2014)
PR libfortran/62768 Handle filenames with embedded null characters.
:
made the changes like the following to libgfortran/io/close.c
#if !HAVE_UNLINK_OPEN_FILE
- path = fc_strdup (u->file, u->file_len);
+ path = strdup (u->filename);
#endif
One of our users now reported this build failure for a system where
(for whatever reason) HAVE_UNLINK_OPEN_FILE is not defined:
.../GCC-HEAD/libgfortran/io/close.c:94:11: error: implicit declaration of function ʽstrdupʼ
94 | path = strdup (u->filename);
| ^~~~~~
By #undef-ining HAVE_UNLINK_OPEN_FILE beetween the #include "..." and
#include <...> statements in libgfortran/io/close.c I could reproduce
this on FreeBSD 11/i386.
And I could validate the fix below, both with and without that #undef
in place.
Tested on i386-unknown-freebsd11.1.
Okay to commit?
I'd also like to apply this to older release branches (down to GCC 6)
since it is obviously broken and the fix appears straightforward. If
approved, I'm thinking to wait about a week or two before making each
step backwards (from HEAD to 8, 8 to 7, and 7 to 6).
Gerald
2018-10-02 Gerald Pfeifer <gerald@pfeifer.com>
* io/close.c [!HAVE_UNLINK_OPEN_FILE]: Include <string.h>.
Index: libgfortran/io/close.c
===================================================================
--- libgfortran/io/close.c (revision 264772)
+++ libgfortran/io/close.c (working copy)
@@ -26,6 +26,9 @@ see the files COPYING3 and COPYING.RUNTIME respect
#include "unix.h"
#include "async.h"
#include <limits.h>
+#if !HAVE_UNLINK_OPEN_FILE
+#include <string.h>
+#endif
typedef enum
{ CLOSE_DELETE, CLOSE_KEEP, CLOSE_UNSPECIFIED }