[m-dev.] for review: fix Windows text output problem
Fergus Henderson
fjh at cs.mu.OZ.AU
Sun Feb 25 01:49:06 AEDT 2001
For both main and release branches.
----------
Estimated hours taken: 2
Fix a bug reported by Philippos Apollinariou <equus at operamail.com>
where on Windows 95, text output to stdout was being done in binary
mode (\n => CR only) rather than text mode (\n => CR LF).
library/io.m:
When opening mercury_binary_stdin/mercury_binary_stdout, call dup()
before calling fdopen(). Without this, with Cygwin 1.1.8 on
Windows 95 the call to fdopen() ends up changing the mode of
stdin/stdout, rather than just setting the mode of the newly
opened file.
configure.in:
Check for dup().
Workspace: /home/hg/fjh/mercury
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.238.2.3
diff -u -d -r1.238.2.3 configure.in
--- configure.in 2001/02/17 07:22:57 1.238.2.3
+++ configure.in 2001/02/24 13:54:30
@@ -339,7 +339,7 @@
ac_cv_func_mprotect=no ;;
esac
AC_HAVE_FUNCS(sysconf getpagesize memalign mprotect sigaction setitimer)
-AC_HAVE_FUNCS(strerror memmove fileno fdopen fstat)
+AC_HAVE_FUNCS(strerror memmove dup fileno fdopen fstat)
AC_HAVE_FUNCS(vsnprintf _vsnprintf)
#-----------------------------------------------------------------------------#
AC_CHECK_HEADER(unistd.h, HAVE_UNISTD_H=1)
Index: library/io.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/io.m,v
retrieving revision 1.220
diff -u -d -r1.220 io.m
--- library/io.m 2001/01/09 23:30:16 1.220
+++ library/io.m 2001/02/24 13:53:10
@@ -3004,14 +3004,15 @@
MR_mercuryfile_init(NULL, 1, &mercury_stdin_binary);
MR_mercuryfile_init(NULL, 1, &mercury_stdout_binary);
-#if defined(HAVE_FDOPEN) && (defined(HAVE_FILENO) || defined(fileno))
- MR_file(mercury_stdin_binary) = fdopen(fileno(stdin), ""rb"");
+#if defined(HAVE_FDOPEN) && (defined(HAVE_FILENO) || defined(fileno)) && \
+ defined(HAVE_DUP)
+ MR_file(mercury_stdin_binary) = fdopen(dup(fileno(stdin)), ""rb"");
if (MR_file(mercury_stdin_binary) == NULL) {
MR_fatal_error(""error opening standard input stream in ""
""binary mode:\\n\\tfdopen() failed: %s"",
strerror(errno));
}
- MR_file(mercury_stdout_binary) = fdopen(fileno(stdout), ""wb"");
+ MR_file(mercury_stdout_binary) = fdopen(dup(fileno(stdout)), ""wb"");
if (MR_file(mercury_stdout_binary) == NULL) {
MR_fatal_error(""error opening standard output stream in ""
""binary mode:\\n\\tfdopen() failed: %s"",
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list