This is the mail archive of the newlib@sourceware.cygnus.com mailing list for the newlib project.


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

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


Hi,

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
Friday.

Corinna

ChangeLog:

	* 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;
 #endif

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