2002-01-28 Stefan Jahn <stefan@lkcc.org>
[bpt/guile.git] / libguile / vports.c
index ba4230e..c25bc20 100644 (file)
@@ -1,4 +1,4 @@
-/*     Copyright (C) 1995,1996,1998,1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1995,1996,1998,1999,2000,2001 Free Software Foundation, Inc.
  * 
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -39,8 +39,6 @@
  * whether to permit this exception to apply to your modifications.
  * If you do not wish that, delete this exception notice.  */
 
-/* Software engineering face-lift by Greg J. Badros, 11-Dec-1999,
-   gjb@cs.washington.edu, http://www.cs.washington.edu/homes/gjb */
 
 \f
 
  */
 
 
-static scm_bits_t scm_tc16_sfport;
+static scm_t_bits scm_tc16_sfport;
 
 
 static void
 sf_flush (SCM port)
 {
-  scm_port *pt = SCM_PTAB_ENTRY (port);
+  scm_t_port *pt = SCM_PTAB_ENTRY (port);
   SCM stream = SCM_PACK (pt->stream);
 
   if (pt->write_pos > pt->write_buf)
     {
       /* write the byte. */
-      scm_apply (SCM_VELTS (stream)[0], SCM_MAKE_CHAR (*pt->write_buf),
-                scm_listofnull);
+      scm_call_1 (SCM_VELTS (stream)[0], SCM_MAKE_CHAR (*pt->write_buf));
       pt->write_pos = pt->write_buf;
   
       /* flush the output.  */
@@ -90,7 +87,7 @@ sf_flush (SCM port)
        SCM f = SCM_VELTS (stream)[2];
 
        if (!SCM_FALSEP (f))
-         scm_apply (f, SCM_EOL, SCM_EOL);
+         scm_call_0 (f);
       }
     }
 }
@@ -100,9 +97,7 @@ sf_write (SCM port, const void *data, size_t size)
 {
   SCM p = SCM_PACK (SCM_STREAM (port));
 
-  scm_apply (SCM_VELTS (p)[1], 
-            scm_cons (scm_makfromstr ((char *) data, size, 0), SCM_EOL),
-            SCM_EOL);
+  scm_call_1 (SCM_VELTS (p)[1], scm_mem2string ((char *) data, size));
 }
 
 /* calling the flush proc (element 2) is in case old code needs it,
@@ -116,12 +111,12 @@ sf_fill_input (SCM port)
   SCM p = SCM_PACK (SCM_STREAM (port));
   SCM ans;
 
-  ans = scm_apply (SCM_VELTS (p)[3], SCM_EOL, SCM_EOL); /* get char.  */
+  ans = scm_call_0 (SCM_VELTS (p)[3]); /* get char.  */
   if (SCM_FALSEP (ans) || SCM_EOF_OBJECT_P (ans))
     return EOF;
   SCM_ASSERT (SCM_CHARP (ans), ans, SCM_ARG1, "sf_fill_input");
   {
-    scm_port *pt = SCM_PTAB_ENTRY (port);    
+    scm_t_port *pt = SCM_PTAB_ENTRY (port);    
 
     *pt->read_buf = SCM_CHAR (ans);
     pt->read_pos = pt->read_buf;
@@ -138,7 +133,7 @@ sf_close (SCM port)
   SCM f = SCM_VELTS (p)[4];
   if (SCM_FALSEP (f))
     return 0;
-  f = scm_apply (f, SCM_EOL, SCM_EOL);
+  f = scm_call_0 (f);
   errno = 0;
   return SCM_FALSEP (f) ? EOF : 0;
 }
@@ -190,12 +185,11 @@ SCM_DEFINE (scm_make_soft_port, "make-soft-port", 2, 0, 0,
            "@end lisp")
 #define FUNC_NAME s_scm_make_soft_port
 {
-  scm_port *pt;
+  scm_t_port *pt;
   SCM z;
   SCM_VALIDATE_VECTOR_LEN (1,pv,5);
   SCM_VALIDATE_STRING (2, modes);
-  SCM_STRING_COERCE_0TERMINATION_X (modes);
-  SCM_NEWCELL (z);
+  z = scm_alloc_cell (scm_tc16_sfport, 0);
   SCM_DEFER_INTS;
   pt = scm_add_to_port_table (z);
   scm_port_non_buffer (pt);
@@ -208,10 +202,10 @@ SCM_DEFINE (scm_make_soft_port, "make-soft-port", 2, 0, 0,
 #undef FUNC_NAME
 
 
-static scm_bits_t
+static scm_t_bits
 scm_make_sfptob ()
 {
-  scm_bits_t tc = scm_make_port_type ("soft", sf_fill_input, sf_write);
+  scm_t_bits tc = scm_make_port_type ("soft", sf_fill_input, sf_write);
 
   scm_set_port_mark (tc, scm_markstream);
   scm_set_port_flush (tc, sf_flush);