diff --git a/libguile/genio.c b/libguile/genio.c index 74bc0d39e..1b04a0ce9 100644 --- a/libguile/genio.c +++ b/libguile/genio.c @@ -90,6 +90,14 @@ scm_lfwrite (ptr, size, port) } +void +scm_fflush (port) + SCM port; +{ + scm_sizet i = SCM_PTOBNUM (port); + (scm_ptobs[i].fflush) (SCM_STREAM (port)); +} + int diff --git a/libguile/genio.h b/libguile/genio.h index 288e60fad..8362d9c45 100644 --- a/libguile/genio.h +++ b/libguile/genio.h @@ -51,6 +51,7 @@ extern void scm_putc SCM_P ((int c, SCM port)); extern void scm_puts SCM_P ((char *str_data, SCM port)); extern void scm_lfwrite SCM_P ((char *ptr, scm_sizet size, SCM port)); +extern void scm_fflush SCM_P ((SCM port)); extern int scm_getc SCM_P ((SCM port)); extern void scm_ungetc SCM_P ((int c, SCM port)); /* FIXME: this is a terrible name. */ diff --git a/libguile/ports.c b/libguile/ports.c index 809be19ca..71824e413 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -39,6 +39,8 @@ * whether to permit this exception to apply to your modifications. * If you do not wish that, delete this exception notice. */ +/* Headers. */ + #include #include "_scm.h" #include "genio.h" @@ -64,7 +66,9 @@ #ifdef HAVE_SYS_IOCTL_H #include #endif + +/* The port kind table --- a dynamically resized array of port types. */ /* scm_ptobs scm_numptob @@ -121,17 +125,6 @@ scm_newptob (ptob) return scm_tc7_port + (scm_numptob - 1) * 256; } - -/* internal SCM call */ - -void -scm_fflush (port) - SCM port; -{ - scm_sizet i = SCM_PTOBNUM (port); - (scm_ptobs[i].fflush) (SCM_STREAM (port)); -} - SCM_PROC(s_char_ready_p, "char-ready?", 0, 1, 0, scm_char_ready_p); @@ -143,7 +136,9 @@ scm_char_ready_p (port) if (SCM_UNBNDP (port)) port = scm_cur_inp; else - SCM_ASSERT (SCM_NIMP (port) && SCM_OPINPORTP (port), port, SCM_ARG1, s_char_ready_p); + SCM_ASSERT (SCM_NIMP (port) && SCM_OPINPORTP (port), port, SCM_ARG1, + s_char_ready_p); + if (SCM_CRDYP (port) || !SCM_FPORTP (port)) return SCM_BOOL_T; return (scm_input_waiting_p ((FILE *) SCM_STREAM (port), s_char_ready_p) @@ -153,10 +148,8 @@ scm_char_ready_p (port) +/* Standard ports --- current input, output, error, and more(!). */ - -/* {Standard Ports} - */ SCM_PROC(s_current_input_port, "current-input-port", 0, 0, 0, scm_current_input_port); SCM @@ -230,10 +223,7 @@ scm_set_current_error_port (port) } - -/* {Ports - in general} - * - */ +/* The port table --- a table of all the open ports. */ /* Array of open ports, required for reliable MOVE->FDES etc. */ struct scm_port_table **scm_port_table; @@ -317,6 +307,9 @@ scm_pt_member (member) #endif + +/* Revealed counts --- an oddity inherited from SCSH. */ + /* Find a port in the table and return its revealed count. Also used by the garbage collector. */ @@ -360,6 +353,10 @@ scm_set_port_revealed_x (port, rcount) return SCM_UNSPECIFIED; } + + +/* Retrieving a port's mode. */ + /* Return the flags that characterize a port based on the mode * string used to open a file for that port. * @@ -408,6 +405,9 @@ scm_port_mode (port) } + +/* Closing ports. */ + /* scm_close_port * Call the close operation on a port object. * see also scm_close. @@ -478,6 +478,10 @@ scm_close_all_ports_except (ports) return SCM_UNSPECIFIED; } + + +/* Utter miscellany. Gosh, we should clean this up some time. */ + SCM_PROC(s_input_port_p, "input-port?", 1, 0, 0, scm_input_port_p); SCM @@ -823,8 +827,7 @@ scm_ports_prehistory () -/* {Void Ports} - */ +/* Void ports. */ int scm_tc16_void_port = 0; diff --git a/libguile/ports.h b/libguile/ports.h index 9226f7290..a7ea3e158 100644 --- a/libguile/ports.h +++ b/libguile/ports.h @@ -149,7 +149,6 @@ extern int scm_port_table_room; extern SCM scm_markstream SCM_P ((SCM ptr)); extern long scm_newptob SCM_P ((scm_ptobfuns *ptob)); -extern void scm_fflush SCM_P ((SCM port)); extern SCM scm_char_ready_p SCM_P ((SCM port)); extern SCM scm_current_input_port SCM_P ((void)); extern SCM scm_current_output_port SCM_P ((void));