mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-05 15:10:27 +02:00
Change the definition of the functions in scm_ptobfuns so that
they get passed the port object, not the port's stream. * ports.h (scm_ptobfuns): Rename all `stream' arguments to `port'. * gc.c (scm_gc_sweep): Pass the port itself to the free function. * genio.c (scm_putc, scm_puts, scm_lfwrite, scm_fflush, scm_getc): Pass the port itself to the scm_ptobs function. * ports.c (scm_close_port, scm_force_output, scm_flush_all_ports, scm_generic_fgets): Same. (putc_void_port, puts_void_port, write_void_port, flush_void_port, getc_void_port, fgets_void_port, close_void_port): Just change the argument names; these functions don't really do anything. * fports.c (local_fgetc, local_fgets, local_fclose, local_fflush, local_fputc, local_fputs, local_ffwrite, local_pclose): Take the port as an argument, and use SCM_STREAM to get the stdio FILE *. Also, use prototyped definitions, and get rid of the extra declarations. (scm_fptob, scm_pipob): We don't need casts here any more. * strports.c (prinstpt): Use prototype declarations. (stputc, stwrite, stputs, stgetc): Take the port as an argument, and use SCM_STREAM to get the string info. Also, use prototyped definitions, and get rid of the extra declarations. * vports.c (sfputc, sfwrite, sfputs, sfflush, sfgetc, sfclose, noop0): Same.
This commit is contained in:
parent
ea9fc30d4b
commit
0f88a8f3bd
5 changed files with 48 additions and 81 deletions
|
@ -1220,7 +1220,7 @@ scm_gc_sweep ()
|
||||||
/* Yes, I really do mean scm_ptobs[k].free */
|
/* Yes, I really do mean scm_ptobs[k].free */
|
||||||
/* rather than ftobs[k].close. .close */
|
/* rather than ftobs[k].close. .close */
|
||||||
/* is for explicit CLOSE-PORT by user */
|
/* is for explicit CLOSE-PORT by user */
|
||||||
(scm_ptobs[k].free) (SCM_STREAM (scmptr));
|
(scm_ptobs[k].free) (scmptr);
|
||||||
SCM_SETSTREAM (scmptr, 0);
|
SCM_SETSTREAM (scmptr, 0);
|
||||||
scm_remove_from_port_table (scmptr);
|
scm_remove_from_port_table (scmptr);
|
||||||
scm_gc_ports_collected++;
|
scm_gc_ports_collected++;
|
||||||
|
|
|
@ -59,7 +59,7 @@ scm_putc (c, port)
|
||||||
SCM port;
|
SCM port;
|
||||||
{
|
{
|
||||||
scm_sizet i = SCM_PTOBNUM (port);
|
scm_sizet i = SCM_PTOBNUM (port);
|
||||||
SCM_SYSCALL ((scm_ptobs[i].fputc) (c, SCM_STREAM (port)));
|
SCM_SYSCALL ((scm_ptobs[i].fputc) (c, port));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -68,7 +68,7 @@ scm_puts (s, port)
|
||||||
SCM port;
|
SCM port;
|
||||||
{
|
{
|
||||||
scm_sizet i = SCM_PTOBNUM (port);
|
scm_sizet i = SCM_PTOBNUM (port);
|
||||||
SCM_SYSCALL ((scm_ptobs[i].fputs) (s, SCM_STREAM (port)));
|
SCM_SYSCALL ((scm_ptobs[i].fputs) (s, port));
|
||||||
#ifdef TRANSCRIPT_SUPPORT
|
#ifdef TRANSCRIPT_SUPPORT
|
||||||
if (scm_trans && (port == def_outp || port == cur_errp))
|
if (scm_trans && (port == def_outp || port == cur_errp))
|
||||||
SCM_SYSCALL (fputs (s, scm_trans));
|
SCM_SYSCALL (fputs (s, scm_trans));
|
||||||
|
@ -82,7 +82,7 @@ scm_lfwrite (ptr, size, port)
|
||||||
SCM port;
|
SCM port;
|
||||||
{
|
{
|
||||||
scm_sizet i = SCM_PTOBNUM (port);
|
scm_sizet i = SCM_PTOBNUM (port);
|
||||||
SCM_SYSCALL (scm_ptobs[i].fwrite(ptr, size, 1, SCM_STREAM (port)));
|
SCM_SYSCALL (scm_ptobs[i].fwrite (ptr, size, 1, port));
|
||||||
#ifdef TRANSCRIPT_SUPPORT
|
#ifdef TRANSCRIPT_SUPPORT
|
||||||
if (scm_trans && (port == def_outp || port == cur_errp))
|
if (scm_trans && (port == def_outp || port == cur_errp))
|
||||||
SCM_SYSCALL (fwrite (ptr, size, 1, scm_trans));
|
SCM_SYSCALL (fwrite (ptr, size, 1, scm_trans));
|
||||||
|
@ -95,7 +95,7 @@ scm_fflush (port)
|
||||||
SCM port;
|
SCM port;
|
||||||
{
|
{
|
||||||
scm_sizet i = SCM_PTOBNUM (port);
|
scm_sizet i = SCM_PTOBNUM (port);
|
||||||
(scm_ptobs[i].fflush) (SCM_STREAM (port));
|
(scm_ptobs[i].fflush) (port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ scm_getc (port)
|
||||||
while (n == -1 && errno == EINTR);
|
while (n == -1 && errno == EINTR);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
SCM_SYSCALL (c = (scm_ptobs[i].fgetc) (f));
|
SCM_SYSCALL (c = (scm_ptobs[i].fgetc) (port));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
|
|
|
@ -431,7 +431,7 @@ scm_close_port (port)
|
||||||
SCM_DEFER_INTS;
|
SCM_DEFER_INTS;
|
||||||
if (scm_ptobs[i].fclose)
|
if (scm_ptobs[i].fclose)
|
||||||
{
|
{
|
||||||
SCM_SYSCALL (rv = (scm_ptobs[i].fclose) (SCM_STREAM (port)));
|
SCM_SYSCALL (rv = (scm_ptobs[i].fclose) (port));
|
||||||
/* ports with a closed file descriptor can be reclosed without error. */
|
/* ports with a closed file descriptor can be reclosed without error. */
|
||||||
if (rv < 0 && errno != EBADF)
|
if (rv < 0 && errno != EBADF)
|
||||||
scm_syserror (s_close_port);
|
scm_syserror (s_close_port);
|
||||||
|
@ -530,7 +530,7 @@ scm_force_output (port)
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
scm_sizet i = SCM_PTOBNUM (port);
|
scm_sizet i = SCM_PTOBNUM (port);
|
||||||
SCM_SYSCALL ((scm_ptobs[i].fflush) (SCM_STREAM (port)));
|
SCM_SYSCALL ((scm_ptobs[i].fflush) (port));
|
||||||
return SCM_UNSPECIFIED;
|
return SCM_UNSPECIFIED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -547,7 +547,7 @@ scm_flush_all_ports (void)
|
||||||
if (SCM_OPOUTPORTP (port))
|
if (SCM_OPOUTPORTP (port))
|
||||||
{
|
{
|
||||||
scm_sizet ptob = SCM_PTOBNUM (port);
|
scm_sizet ptob = SCM_PTOBNUM (port);
|
||||||
(scm_ptobs[ptob].fflush) (SCM_STREAM (port));
|
(scm_ptobs[ptob].fflush) (port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SCM_UNSPECIFIED;
|
return SCM_UNSPECIFIED;
|
||||||
|
@ -605,7 +605,6 @@ scm_generic_fgets (port, len)
|
||||||
SCM port;
|
SCM port;
|
||||||
int *len;
|
int *len;
|
||||||
{
|
{
|
||||||
SCM f = SCM_STREAM (port);
|
|
||||||
scm_sizet p = SCM_PTOBNUM (port);
|
scm_sizet p = SCM_PTOBNUM (port);
|
||||||
|
|
||||||
char *buf;
|
char *buf;
|
||||||
|
@ -637,7 +636,7 @@ scm_generic_fgets (port, len)
|
||||||
limit *= 2;
|
limit *= 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = (scm_ptobs[p].fgetc) (f);
|
c = (scm_ptobs[p].fgetc) (port);
|
||||||
if (c != EOF)
|
if (c != EOF)
|
||||||
buf[(*len)++] = c;
|
buf[(*len)++] = c;
|
||||||
|
|
||||||
|
@ -839,19 +838,19 @@ print_void_port (SCM exp, SCM port, scm_print_state *pstate)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
putc_void_port (int c, SCM strm)
|
putc_void_port (int c, SCM port)
|
||||||
{
|
{
|
||||||
return 0; /* vestigial return value */
|
return 0; /* vestigial return value */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
puts_void_port (char *s, SCM strm)
|
puts_void_port (char *s, SCM port)
|
||||||
{
|
{
|
||||||
return 0; /* vestigial return value */
|
return 0; /* vestigial return value */
|
||||||
}
|
}
|
||||||
|
|
||||||
static scm_sizet
|
static scm_sizet
|
||||||
write_void_port (char *ptr, scm_sizet size, scm_sizet nitems, SCM strm)
|
write_void_port (char *ptr, scm_sizet size, scm_sizet nitems, SCM port)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
len = size * nitems;
|
len = size * nitems;
|
||||||
|
@ -860,26 +859,26 @@ write_void_port (char *ptr, scm_sizet size, scm_sizet nitems, SCM strm)
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
flush_void_port (SCM strm)
|
flush_void_port (SCM port)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
getc_void_port (SCM strm)
|
getc_void_port (SCM port)
|
||||||
{
|
{
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
fgets_void_port (SCM strm, int *len)
|
fgets_void_port (SCM port, int *len)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
close_void_port (SCM strm)
|
close_void_port (SCM port)
|
||||||
{
|
{
|
||||||
return 0; /* this is ignored by scm_close_port. */
|
return 0; /* this is ignored by scm_close_port. */
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,26 +59,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static int prinstpt SCM_P ((SCM exp, SCM port, scm_print_state *pstate));
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
prinstpt (exp, port, pstate)
|
prinstpt (SCM exp, SCM port, scm_print_state *pstate)
|
||||||
SCM exp;
|
|
||||||
SCM port;
|
|
||||||
scm_print_state *pstate;
|
|
||||||
{
|
{
|
||||||
scm_prinport (exp, port, "string");
|
scm_prinport (exp, port, "string");
|
||||||
return !0;
|
return !0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int stputc SCM_P ((int c, SCM p));
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
stputc (c, p)
|
stputc (int c, SCM port)
|
||||||
int c;
|
|
||||||
SCM p;
|
|
||||||
{
|
{
|
||||||
|
SCM p = SCM_STREAM (port);
|
||||||
scm_sizet ind = SCM_INUM (SCM_CAR (p));
|
scm_sizet ind = SCM_INUM (SCM_CAR (p));
|
||||||
SCM_DEFER_INTS;
|
SCM_DEFER_INTS;
|
||||||
if (ind >= SCM_LENGTH (SCM_CDR (p)))
|
if (ind >= SCM_LENGTH (SCM_CDR (p)))
|
||||||
|
@ -90,15 +82,14 @@ stputc (c, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static scm_sizet stwrite SCM_P ((char *str, scm_sizet siz, scm_sizet num, SCM p));
|
|
||||||
|
|
||||||
static scm_sizet
|
static scm_sizet
|
||||||
stwrite (str, siz, num, p)
|
stwrite (char *str,
|
||||||
char *str;
|
scm_sizet siz,
|
||||||
scm_sizet siz;
|
scm_sizet num,
|
||||||
scm_sizet num;
|
SCM port)
|
||||||
SCM p;
|
|
||||||
{
|
{
|
||||||
|
SCM p = SCM_STREAM (port);
|
||||||
|
|
||||||
scm_sizet ind = SCM_INUM (SCM_CAR (p));
|
scm_sizet ind = SCM_INUM (SCM_CAR (p));
|
||||||
scm_sizet len = siz * num;
|
scm_sizet len = siz * num;
|
||||||
char *dst;
|
char *dst;
|
||||||
|
@ -114,24 +105,19 @@ stwrite (str, siz, num, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int stputs SCM_P ((char *s, SCM p));
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
stputs (s, p)
|
stputs (char *s, SCM port)
|
||||||
char *s;
|
|
||||||
SCM p;
|
|
||||||
{
|
{
|
||||||
stwrite (s, 1, strlen (s), p);
|
stwrite (s, 1, strlen (s), port);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int stgetc SCM_P ((SCM p));
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
stgetc (p)
|
stgetc (SCM port)
|
||||||
SCM p;
|
|
||||||
{
|
{
|
||||||
|
SCM p = SCM_STREAM (port);
|
||||||
|
|
||||||
scm_sizet ind = SCM_INUM (SCM_CAR (p));
|
scm_sizet ind = SCM_INUM (SCM_CAR (p));
|
||||||
if (ind >= SCM_ROLENGTH (SCM_CDR (p)))
|
if (ind >= SCM_ROLENGTH (SCM_CDR (p)))
|
||||||
return EOF;
|
return EOF;
|
||||||
|
|
|
@ -81,28 +81,21 @@ prinsfpt (exp, port, pstate)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
static int sfputc SCM_P ((int c, SCM p));
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sfputc (c, p)
|
sfputc (int c, SCM port)
|
||||||
int c;
|
|
||||||
SCM p;
|
|
||||||
{
|
{
|
||||||
|
SCM p = SCM_STREAM (port);
|
||||||
|
|
||||||
scm_apply (SCM_VELTS (p)[0], SCM_MAKICHR (c), scm_listofnull);
|
scm_apply (SCM_VELTS (p)[0], SCM_MAKICHR (c), scm_listofnull);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static scm_sizet sfwrite SCM_P ((char *str, scm_sizet siz, scm_sizet num, SCM p));
|
|
||||||
|
|
||||||
static scm_sizet
|
static scm_sizet
|
||||||
sfwrite (str, siz, num, p)
|
sfwrite (char *str, scm_sizet siz, scm_sizet num, SCM port)
|
||||||
char *str;
|
|
||||||
scm_sizet siz;
|
|
||||||
scm_sizet num;
|
|
||||||
SCM p;
|
|
||||||
{
|
{
|
||||||
|
SCM p = SCM_STREAM (port);
|
||||||
SCM sstr;
|
SCM sstr;
|
||||||
sstr = scm_makfromstr (str, siz * num, 0);
|
sstr = scm_makfromstr (str, siz * num, 0);
|
||||||
scm_apply (SCM_VELTS (p)[1], sstr, scm_listofnull);
|
scm_apply (SCM_VELTS (p)[1], sstr, scm_listofnull);
|
||||||
|
@ -111,24 +104,19 @@ sfwrite (str, siz, num, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int sfputs SCM_P ((char *s, SCM p));
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sfputs (s, p)
|
sfputs (char *s, SCM port)
|
||||||
char *s;
|
|
||||||
SCM p;
|
|
||||||
{
|
{
|
||||||
sfwrite (s, 1, strlen (s), p);
|
sfwrite (s, 1, strlen (s), port);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int sfflush SCM_P ((SCM stream));
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sfflush (stream)
|
sfflush (SCM port)
|
||||||
SCM stream;
|
|
||||||
{
|
{
|
||||||
|
SCM stream = SCM_STREAM (port);
|
||||||
|
|
||||||
SCM f = SCM_VELTS (stream)[2];
|
SCM f = SCM_VELTS (stream)[2];
|
||||||
if (SCM_BOOL_F == f)
|
if (SCM_BOOL_F == f)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -138,12 +126,11 @@ sfflush (stream)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int sfgetc SCM_P ((SCM p));
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sfgetc (p)
|
sfgetc (SCM port)
|
||||||
SCM p;
|
|
||||||
{
|
{
|
||||||
|
SCM p = SCM_STREAM (port);
|
||||||
|
|
||||||
SCM ans;
|
SCM ans;
|
||||||
ans = scm_apply (SCM_VELTS (p)[3], SCM_EOL, SCM_EOL);
|
ans = scm_apply (SCM_VELTS (p)[3], SCM_EOL, SCM_EOL);
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
@ -154,12 +141,10 @@ sfgetc (p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int sfclose SCM_P ((SCM p));
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
sfclose (p)
|
sfclose (SCM port)
|
||||||
SCM p;
|
|
||||||
{
|
{
|
||||||
|
SCM p = SCM_STREAM (port);
|
||||||
SCM f = SCM_VELTS (p)[4];
|
SCM f = SCM_VELTS (p)[4];
|
||||||
if (SCM_BOOL_F == f)
|
if (SCM_BOOL_F == f)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -193,11 +178,8 @@ scm_make_soft_port (pv, modes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int noop0 SCM_P ((SCM stream));
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
noop0 (stream)
|
noop0 (SCM port)
|
||||||
SCM stream;
|
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue