summaryrefslogtreecommitdiff
path: root/libgfortran/acinclude.m4
diff options
context:
space:
mode:
authorfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-07 21:25:40 +0000
committerfxcoudert <fxcoudert@138bc75d-0d04-0410-961f-82ee72b054a4>2005-09-07 21:25:40 +0000
commitcf55c3cf6a36a55f8dcad17b8ddfac168fb7af08 (patch)
tree077176970c902eb386a3e59797dc9538ca553d80 /libgfortran/acinclude.m4
parent488c408f0fd890ce2e9afd87a2e851e00c2b0519 (diff)
downloadgcc-cf55c3cf6a36a55f8dcad17b8ddfac168fb7af08.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104009 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran/acinclude.m4')
-rw-r--r--libgfortran/acinclude.m447
1 files changed, 47 insertions, 0 deletions
diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4
index 4355d3a12fc..f9fcca66659 100644
--- a/libgfortran/acinclude.m4
+++ b/libgfortran/acinclude.m4
@@ -183,3 +183,50 @@ esac])])
if test x"$have_unlink_open_file" = xyes; then
AC_DEFINE(HAVE_UNLINK_OPEN_FILE, 1, [Define if target can unlink open files.])
fi])
+
+dnl Check whether CRLF is the line terminator
+AC_DEFUN([LIBGFOR_CHECK_CRLF], [
+ AC_CACHE_CHECK([whether the target has CRLF as line terminator],
+ have_crlf, [
+ AC_TRY_RUN([
+/* This test program should exit with status 0 if system uses a CRLF as
+ line terminator, and status 1 otherwise.
+ Since it is used to check for mingw systems, and should return 0 in any
+ other case, in case of a failure we will not use CRLF. */
+#include <sys/stat.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+int main ()
+{
+#ifndef O_BINARY
+ exit(1);
+#else
+ int fd, bytes;
+ char buff[5];
+
+ fd = open ("foo", O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
+ if (fd < 0)
+ exit(1);
+ if (write (fd, "\n", 1) < 0)
+ perror ("write");
+
+ close (fd);
+
+ if ((fd = open ("foo", O_RDONLY | O_BINARY, S_IRWXU)) < 0)
+ exit(1);
+ bytes = read (fd, buff, 5);
+ if (bytes == 2 && buff[0] == '\r' && buff[1] == '\n')
+ exit(0);
+ else
+ exit(1);
+#endif
+}], have_crlf=yes, have_crlf=no, [
+case "${target}" in
+ *mingw*) have_crlf=yes ;;
+ *) have_crlf=no;;
+esac])])
+if test x"$have_crlf" = xyes; then
+ AC_DEFINE(HAVE_CRLF, 1, [Define if CRLF is line terminator.])
+fi])