mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Centralize the creation of port objects based on stdio FILE * in
fports.c; don't just throw them together anywhere. * fports.c (scm_stdio_to_port): Make NAME a SCM value, which is what the rest of Guile wants. Don't set the revealed count; that's only appropriate for stdin, stdout, stderr. (scm_standard_stream_to_port): This function does set the revealed count. * init.c (scm_init_standard_ports): Use scm_standard_stream_to_port, not scm_stdio_to_port. * filesys.c (scm_open): Call scm_stdio_to_port; don't write it out. * fports.c (scm_open_file): Same. * posix.c (scm_pipe): Same. * socket.c (scm_sock_fd_to_port): Same. * ioext.c (scm_fdopen): Same. (scm_freopen): Moved from here to... * fports.c (scm_freopen): ... here. This is really something that munges the internals of an fport, so it should go here. * fports.h (scm_stdio_to_port): Adjust prototype. (scm_standard_stream_to_port, scm_freopen): New protoypes. * ioext.h (scm_freopen): Prototype removed. * filesys.c (set_element, get_element): This can work on both pipe and file ports, so use SCM_FPORTP to typecheck, instead of testing for scm_tc16_fport.
This commit is contained in:
parent
74d977c610
commit
5621be9997
1 changed files with 3 additions and 17 deletions
|
@ -256,7 +256,6 @@ scm_open (SCM path, SCM flags, SCM mode)
|
|||
|
||||
fd = SCM_INUM (scm_open_fdes (path, flags, mode));
|
||||
iflags = scm_num2long (flags, (char *) SCM_ARG2, s_open_fdes);
|
||||
SCM_NEWCELL (newpt);
|
||||
if (iflags & O_RDWR)
|
||||
port_mode = "r+";
|
||||
else {
|
||||
|
@ -272,17 +271,7 @@ scm_open (SCM path, SCM flags, SCM mode)
|
|||
SCM_SYSCALL (close (fd));
|
||||
scm_syserror (s_open);
|
||||
}
|
||||
{
|
||||
struct scm_port_table * pt;
|
||||
|
||||
pt = scm_add_to_port_table (newpt);
|
||||
SCM_SETPTAB_ENTRY (newpt, pt);
|
||||
SCM_SETCAR (newpt, scm_tc16_fport | scm_mode_bits (port_mode));
|
||||
/* if (SCM_BUF0 & SCM_CAR (newpt))
|
||||
scm_setbuf0 (newpt); */
|
||||
SCM_SETSTREAM (newpt, (SCM)f);
|
||||
SCM_PTAB_ENTRY (newpt)->file_name = path;
|
||||
}
|
||||
newpt = scm_stdio_to_port (f, port_mode, path);
|
||||
SCM_ALLOW_INTS;
|
||||
|
||||
return newpt;
|
||||
|
@ -827,8 +816,7 @@ set_element (SELECT_TYPE *set, SCM element, int arg)
|
|||
{
|
||||
int fd;
|
||||
element = SCM_COERCE_OUTPORT (element);
|
||||
if (SCM_NIMP (element) && SCM_TYP16 (element) == scm_tc16_fport
|
||||
&& SCM_OPPORTP (element))
|
||||
if (SCM_FPORTP (element) && SCM_OPPORTP (element))
|
||||
fd = fileno ((FILE *) SCM_STREAM (element));
|
||||
else {
|
||||
SCM_ASSERT (SCM_INUMP (element), element, arg, s_select);
|
||||
|
@ -873,9 +861,7 @@ static SCM
|
|||
get_element (SELECT_TYPE *set, SCM element, SCM list)
|
||||
{
|
||||
element = SCM_COERCE_OUTPORT (element);
|
||||
if (SCM_NIMP (element)
|
||||
&& (scm_tc16_fport == SCM_TYP16 (element))
|
||||
&& SCM_OPPORTP (element))
|
||||
if (SCM_FPORTP (element) && SCM_OPPORTP (element))
|
||||
{
|
||||
if (FD_ISSET (fileno ((FILE *)SCM_STREAM (element)), set))
|
||||
list = scm_cons (element, list);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue