[PATCH]: fdopen ignores explicit given bin/textmode flags

Corinna Vinschen corinna@vinschen.de
Tue Jun 13 14:54:00 GMT 2000


Here's a patch to fdopen(). fdopen() currently doesn't care for
explicit given bin/textmode (eg. "rb", "wt" as mode argument).
The below patch solves that problem:

If nobody has any objections, I will check in the patch that



	* libc/stdio/fdopen.c (_fdopen_r): Take explicit given
	bin/textmode into account.

Index: fdopen.c
RCS file: /cvs/src/src/newlib/libc/stdio/fdopen.c,v
retrieving revision 1.3
diff -u -p -r1.3 fdopen.c
--- fdopen.c    2000/05/23 23:51:54     1.3
+++ fdopen.c    2000/06/13 20:25:30
@@ -102,6 +102,11 @@ _DEFUN (_fdopen_r, (ptr, fd, mode),
   fp->_close = __sclose;
 #ifdef __SCLE
+  /* Explicit given mode results in explicit setting mode on fd */
+  if (oflags & O_BINARY)
+    setmode(fp->_file, O_BINARY);
+  else if (oflags & O_TEXT)
+    setmode(fp->_file, O_TEXT);
   if (__stextmode(fp->_file))
     fp->_flags |= __SCLE;

More information about the Newlib mailing list