aboutsummaryrefslogtreecommitdiff
path: root/libgfortran/io
diff options
context:
space:
mode:
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>2005-09-07 23:25:40 +0200
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>2005-09-07 21:25:40 +0000
commit3c12752024a356b71760e09560f5ae6f430fca27 (patch)
tree077176970c902eb386a3e59797dc9538ca553d80 /libgfortran/io
parent2a0abeaf5523ab73d62cd6d84d78e34a25117ecd (diff)
downloadgcc-3c12752024a356b71760e09560f5ae6f430fca27.zip
gcc-3c12752024a356b71760e09560f5ae6f430fca27.tar.gz
gcc-3c12752024a356b71760e09560f5ae6f430fca27.tar.bz2
re PR libfortran/23262 ([mingw32] rewind truncates file)
PR libfortran/23262 * acinclude.m4 (LIBGFOR_CHECK_CRLF): New check. * configure.ac: Use new check. * configure.in: Regenerate. * config.h.in: Regenerate. * configure: Regenerate. * io/transfer.c (next_record_w): Add case for CRLF as line terminator. * io/unix.c (tempfile, regular_file): Open files with O_BINARY on systems with CRLF. From-SVN: r104009
Diffstat (limited to 'libgfortran/io')
-rw-r--r--libgfortran/io/transfer.c13
-rw-r--r--libgfortran/io/unix.c9
2 files changed, 21 insertions, 1 deletions
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c
index 59eb22d..9251cf8 100644
--- a/libgfortran/io/transfer.c
+++ b/libgfortran/io/transfer.c
@@ -1422,13 +1422,24 @@ next_record_w (void)
break;
case FORMATTED_SEQUENTIAL:
+#ifdef HAVE_CRLF
+ length = 2;
+#else
length = 1;
+#endif
p = salloc_w (current_unit->s, &length);
if (!is_internal_unit())
{
if (p)
- *p = '\n'; /* No CR for internal writes. */
+ { /* No new line for internal writes. */
+#ifdef HAVE_CRLF
+ p[0] = '\r';
+ p[1] = '\n';
+#else
+ *p = '\n';
+#endif
+ }
else
goto io_error;
}
diff --git a/libgfortran/io/unix.c b/libgfortran/io/unix.c
index 69101ef..87b839b 100644
--- a/libgfortran/io/unix.c
+++ b/libgfortran/io/unix.c
@@ -1000,7 +1000,12 @@ tempfile (void)
if (mktemp (template))
do
+#ifdef HAVE_CRLF
+ fd = open (template, O_RDWR | O_CREAT | O_EXCL | O_BINARY,
+ S_IREAD | S_IWRITE);
+#else
fd = open (template, O_RDWR | O_CREAT | O_EXCL, S_IREAD | S_IWRITE);
+#endif
while (!(fd == -1 && errno == EEXIST) && mktemp (template));
else
fd = -1;
@@ -1085,6 +1090,10 @@ regular_file (unit_flags *flags)
/* rwflag |= O_LARGEFILE; */
+#ifdef HAVE_CRLF
+ crflag |= O_BINARY;
+#endif
+
mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
fd = open (path, rwflag | crflag, mode);
if (flags->action != ACTION_UNSPECIFIED)