* syscalls.cc (setmode): change mode of any matching FILE* also.

This commit is contained in:
DJ Delorie 2000-05-19 17:15:02 +00:00
parent f00c1d2ccd
commit ed8387fb4f
2 changed files with 26 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2000-05-19 DJ Delorie <dj@cygnus.com>
* syscalls.cc (setmode): change mode of any matching FILE* also.
Thu May 18 17:28:19 2000 Christopher Faylor <cgf@cygnus.com>
* Makefile.in: Remove external.h dependency.

View File

@ -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;
}