diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e04338eb8..59e7b905a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2000-05-19 DJ Delorie + + * syscalls.cc (setmode): change mode of any matching FILE* also. + Thu May 18 17:28:19 2000 Christopher Faylor * Makefile.in: Remove external.h dependency. diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 5eaf301f3..c1ad04b1c 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1430,6 +1430,24 @@ ttyname (int fd) return (char *)(dtable[fd]->ttyname ()); } +/* internal newlib function */ +extern "C" int _fwalk (struct _reent *ptr, int (*function)(FILE *)); + +static int setmode_mode; +static int setmode_file; + +static int +setmode_helper (FILE *f) +{ + if (fileno(f) != setmode_file) + return 0; + if (setmode_mode & O_TEXT) + f->_flags |= __SCLE; + else + f->_flags &= ~__SCLE; + return 0; +} + /* Set a file descriptor into text or binary mode, returning the previous mode. */ @@ -1472,6 +1490,10 @@ setmode (int fd, int mode) p->set_r_binary (0); } + setmode_mode = mode; + setmode_file = fd; + _fwalk(_REENT, setmode_helper); + return res; }