diff options
Diffstat (limited to 'libgfortran/io')
-rw-r--r-- | libgfortran/io/transfer.c | 13 | ||||
-rw-r--r-- | libgfortran/io/unix.c | 9 |
2 files changed, 21 insertions, 1 deletions
diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 59eb22d3dec..9251cf8f24f 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 69101efff04..87b839b6dd3 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) |