1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 05:50:26 +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.
* fports.c (local_fgetc, local_fgets): Renamed from scm_fgetc and
scm_fgets, for consistency.
(scm_fptop, scm_pipob): References updated.
This commit is contained in:
Jim Blandy 1998-10-09 10:01:12 +00:00
parent 0c0669cc73
commit ea9fc30d4b

View file

@ -273,33 +273,19 @@ prinfport (exp, port, pstate)
static int scm_fgetc SCM_P ((FILE * s));
static int static int
scm_fgetc (s) local_fgetc (SCM port)
FILE * s;
{ {
FILE *s = (FILE *) SCM_STREAM (port);
if (feof (s)) if (feof (s))
return EOF; return EOF;
else else
return fgetc (s); return fgetc (s);
} }
/*
* The fgets method must take a port as its argument, rather than
* the underlying file handle. The reason is that we also provide
* a generic fgets method for ports which can't use fgets(3) (e.g.
* string ports). This generic method calls the port's own
* fgetc method. In order for it to know how to get that method,
* we must pass the original Scheme port object.
*/
static char * scm_fgets SCM_P ((SCM port, int *len));
static char * static char *
scm_fgets (port, len) local_fgets (SCM port, int *len)
SCM port;
int *len;
{ {
FILE *f; FILE *f;
@ -384,53 +370,43 @@ pwrite (ptr, size, nitems, port)
* crippled C compilers cope with life. * crippled C compilers cope with life.
*/ */
static int local_fclose SCM_P ((FILE *fp));
static int static int
local_fclose (fp) local_fclose (SCM port)
FILE * fp;
{ {
FILE *fp = (FILE *) SCM_STREAM (port);
return fclose (fp); return fclose (fp);
} }
static int local_fflush SCM_P ((FILE *fp));
static int static int
local_fflush (fp) local_fflush (SCM port)
FILE * fp;
{ {
FILE *fp = (FILE *) SCM_STREAM (port);
return fflush (fp); return fflush (fp);
} }
static int local_fputc SCM_P ((int c, FILE *fp));
static int static int
local_fputc (c, fp) local_fputc (int c, SCM port)
int c;
FILE * fp;
{ {
FILE *fp = (FILE *) SCM_STREAM (port);
return fputc (c, fp); return fputc (c, fp);
} }
static int local_fputs SCM_P ((char *s, FILE *fp));
static int static int
local_fputs (s, fp) local_fputs (char *s, SCM port)
char * s;
FILE * fp;
{ {
FILE *fp = (FILE *) SCM_STREAM (port);
return fputs (s, fp); return fputs (s, fp);
} }
static scm_sizet local_ffwrite SCM_P ((void *ptr, int size, int nitems, FILE *fp));
static scm_sizet static scm_sizet
local_ffwrite (ptr, size, nitems, fp) local_ffwrite (char *ptr,
void * ptr; scm_sizet size,
int size; scm_sizet nitems,
int nitems; SCM port)
FILE * fp;
{ {
FILE *fp = (FILE *) SCM_STREAM (port);
return ffwrite (ptr, size, nitems, fp); return ffwrite (ptr, size, nitems, fp);
} }
@ -441,17 +417,11 @@ print_pipe_port (SCM exp, SCM port, scm_print_state *pstate)
return 1; return 1;
} }
/* On SunOS, there's no declaration for pclose in the headers, so
putting it directly in the initializer for scm_pipob doesn't really
fly. We could add an extern declaration for it, but then it'll
mismatch on some systems that do have a declaration. So we just
wrap it up this way. */
static int static int
local_pclose (fp) local_pclose (SCM port)
FILE * fp;
{ {
FILE *fp = (FILE *) SCM_STREAM (port);
return pclose (fp); return pclose (fp);
} }
@ -459,32 +429,32 @@ local_pclose (fp)
scm_ptobfuns scm_fptob = scm_ptobfuns scm_fptob =
{ {
0, 0,
(int (*) SCM_P ((SCM))) local_fclose, local_fclose,
prinfport, prinfport,
0, 0,
(int (*) SCM_P ((int, SCM))) local_fputc, local_fputc,
(int (*) SCM_P ((char *, SCM))) local_fputs, local_fputs,
(scm_sizet (*) SCM_P ((char *, scm_sizet, scm_sizet, SCM))) local_ffwrite, local_ffwrite,
(int (*) SCM_P ((SCM))) local_fflush, local_fflush,
(int (*) SCM_P ((SCM))) scm_fgetc, local_fgetc,
(char * (*) SCM_P ((SCM, int *))) scm_fgets, local_fgets,
(int (*) SCM_P ((SCM))) local_fclose local_fclose
}; };
/* {Pipe ports} */ /* {Pipe ports} */
scm_ptobfuns scm_pipob = scm_ptobfuns scm_pipob =
{ {
0, 0,
(int (*) SCM_P ((SCM))) local_pclose, local_pclose,
print_pipe_port, print_pipe_port,
0, 0,
(int (*) SCM_P ((int, SCM))) local_fputc, local_fputc,
(int (*) SCM_P ((char *, SCM))) local_fputs, local_fputs,
(scm_sizet (*) SCM_P ((char *, scm_sizet, scm_sizet, SCM))) local_ffwrite, local_ffwrite,
(int (*) SCM_P ((SCM))) local_fflush, local_fflush,
(int (*) SCM_P ((SCM))) scm_fgetc, local_fgetc,
(char * (*) SCM_P ((SCM, int *))) scm_generic_fgets, scm_generic_fgets,
(int (*) SCM_P ((SCM))) local_pclose local_pclose
}; };
void void