1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-18 01:30:27 +02:00

* ioext.h: fix up prototypes.

* ioext.c (scm_dup_to_fdes): renamed from scm_primitive_dup2.
Scheme name is now dup->fdes.
(scm_dup_to_fdes): make the second argument optional and
fold in the functionality of scm_primitive_dup.
(scm_primitive_dup): deleted.
* fports.h (SCM_P): prototypes for scm_setvbuf, scm_setfileno.
* fports.c (scm_setbuf0): don't disable the setbuf if MSDOS or
ultrix are defined.  Use setvbuf instead of setbuf.
(scm_setvbuf): new procedure.
(scm_init_fports): intern _IOFBF, _IOLBF, _IONBF.
(scm_setfileno): moved from ioext.c.
(scm_fgets): cast SCM_STREAM to (FILE *), remove unused lp variable.
(top of file): Delete 25 lines of probably obsolete CPP hair for MSDOS.

* boot-9.scm (move->fdes, dup->port): use dup->fdes, not primitive-dup.
(dup->fdes): deleted, now done in C.
This commit is contained in:
Gary Houston 1997-07-29 02:21:08 +00:00
parent a0cb6cb0ec
commit 7a6f1ffa10
8 changed files with 131 additions and 91 deletions

View file

@ -302,9 +302,9 @@ scm_primitive_dup (SCM fd_or_port)
return SCM_MAKINUM (newfd);
}
SCM_PROC (s_primitive_dup2, "primitive-dup2", 2, 0, 0, scm_primitive_dup2);
SCM_PROC (s_dup_to_fdes, "dup->fdes", 1, 1, 0, scm_dup_to_fdes);
SCM
scm_primitive_dup2 (SCM fd_or_port, SCM fd)
scm_dup_to_fdes (SCM fd_or_port, SCM fd)
{
int oldfd, newfd, rv;
@ -314,23 +314,31 @@ scm_primitive_dup2 (SCM fd_or_port, SCM fd)
else
{
SCM_ASSERT (SCM_NIMP (fd_or_port) && SCM_OPPORTP (fd_or_port),
fd_or_port, SCM_ARG1, s_primitive_dup2);
fd_or_port, SCM_ARG1, s_dup_to_fdes);
oldfd = fileno ((FILE *)SCM_STREAM (fd_or_port));
if (oldfd == -1)
scm_syserror (s_primitive_dup2);
scm_syserror (s_dup_to_fdes);
}
SCM_ASSERT (SCM_INUMP (fd), fd, SCM_ARG2, s_primitive_dup2);
newfd = SCM_INUM (fd);
if (oldfd == newfd)
if (SCM_UNBNDP (fd))
{
SCM_ALLOW_INTS;
return fd;
SCM_SYSCALL (newfd = dup (oldfd));
if (newfd == -1)
scm_syserror (s_primitive_dup);
fd = SCM_MAKINUM (newfd);
}
else
{
SCM_ASSERT (SCM_INUMP (fd), fd, SCM_ARG2, s_dup_to_fdes);
newfd = SCM_INUM (fd);
if (oldfd != newfd)
{
scm_evict_ports (newfd); /* see scsh manual. */
SCM_SYSCALL (rv = dup2 (oldfd, newfd));
if (rv == -1)
scm_syserror (s_dup_to_fdes);
}
}
scm_evict_ports (newfd); /* see scsh manual. */
SCM_SYSCALL (rv = dup2 (oldfd, newfd));
if (rv == -1)
scm_syserror (s_primitive_dup2);
SCM_ALLOW_INTS;
return fd;
}
@ -436,23 +444,6 @@ scm_primitive_move_to_fdes (port, fd)
return SCM_BOOL_T;
}
#ifdef FD_SETTER
#define SET_FILE_FD_FIELD(F,D) ((F)->FD_SETTER = (D))
#endif
void
scm_setfileno (fs, fd)
FILE *fs;
int fd;
{
#ifdef SET_FILE_FD_FIELD
SET_FILE_FD_FIELD(fs, fd);
#else
scm_misc_error ("scm_setfileno", "Not fully implemented on this platform",
SCM_EOL);
#endif
}
/* Return a list of ports using a given file descriptor. */
SCM_PROC(s_fdes_to_ports, "fdes->ports", 1, 0, 0, scm_fdes_to_ports);