This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Patch/libgfortran]: Force preconnected steams to O_BINARY if HAVE_CRLF


danny,

do you have copywrite assignment papers on file with
the FSF ?

thanks for the submission.

--bud

--- Danny Smith <dannysmith@clear.net.nz> wrote:

> Hellop
> As indicated in the bugzilla comment, the problem
> here is that on
> systems that use DOS line endings and define
> HAVE_CRLF, we were opening
> regular output files in O_BINARY mode, and doing the
> /n -> /n/r
> translation ourselves. However, preconnected stdout
> and stderr streams
> were opened in text mode, so the translation was
> done by the runtime as
> well.
> 
> This fixes by using DOS-ish setmode function to
> force preconnected
> output streams to same mode as regular files.
> 
> Tested i686-pc-mingw32.
> 
> :ADDPATCH libfortran:
> 
> 2006-09-21  Danny Smith 
> <dannysmith@users.sourceforge.net>
> 
> 	PR libfortran/27964
> 	* configure.ac : Check for setmode() function.
> 	* configure: Regenerate.
> 	* config.h.in: Regenerate.
> 	* io/unix.c (output_stream): Force stdout to binary
> mode. 
> 	(error_stream): Force stderr to binary mode.
> 
> Index: configure.ac
>
===================================================================
> --- configure.ac	(revision 117095)
> +++ configure.ac	(working copy)
> @@ -172,7 +172,7 @@
>  AC_CHECK_FUNCS(getrusage times mkstemp strtof
> strtold snprintf
> ftruncate chsize)  AC_CHECK_FUNCS(chdir strerror
> getlogin gethostname
> kill link symlink perror)  AC_CHECK_FUNCS(sleep time
> ttyname signal
> alarm ctime clock access fork execl)
> -AC_CHECK_FUNCS(wait)
> +AC_CHECK_FUNCS(wait setmode)
>  
>  # Check libc for getgid, getpid, getuid
>
AC_CHECK_LIB([c],[getgid],[AC_DEFINE([HAVE_GETGID],[1],[libc
> includes
> getgid])])
> Index: io/unix.c
>
===================================================================
> --- io/unix.c	(revision 117095)
> +++ io/unix.c	(working copy)
> @@ -1289,6 +1289,9 @@
>  stream *
>  output_stream (void)
>  {
> +#if defined(HAVE_CRLF) && defined(HAVE_SETMODE)
> +  setmode (STDOUT_FILENO, O_BINARY);
> +#endif
>    return fd_to_stream (STDOUT_FILENO, PROT_WRITE);
>  }
>  
> @@ -1299,6 +1302,9 @@
>  stream *
>  error_stream (void)
>  {
> +#if defined(HAVE_CRLF) && defined(HAVE_SETMODE)
> +  setmode (STDERR_FILENO, O_BINARY);
> +#endif
>    return fd_to_stream (STDERR_FILENO, PROT_WRITE);
>  }
>  
> 
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]