guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Type-checking in `scm_c_{read,write}'


From: Ludovic Courtès
Subject: Type-checking in `scm_c_{read,write}'
Date: Tue, 04 Dec 2007 18:55:50 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Hi,

I committed the attached patch that adds proper type-checking to
`scm_c_read ()' and `scm_c_write ()'.

Thanks,
Ludovic.

--- orig/libguile/ports.c
+++ mod/libguile/ports.c
@@ -1069,10 +1069,14 @@
 
 size_t
 scm_c_read (SCM port, void *buffer, size_t size)
+#define FUNC_NAME "scm_c_read"
 {
-  scm_t_port *pt = SCM_PTAB_ENTRY (port);
+  scm_t_port *pt;
   size_t n_read = 0, n_available;
 
+  SCM_VALIDATE_OPINPORT (1, port);
+
+  pt = SCM_PTAB_ENTRY (port);
   if (pt->rw_active == SCM_PORT_WRITE)
     scm_ptobs[SCM_PTOBNUM (port)].flush (port);
 
@@ -1109,6 +1113,7 @@
 
   return n_read + size;
 }
+#undef FUNC_NAME
 
 /* scm_c_write
  *
@@ -1120,11 +1125,17 @@
  * Warning: Doesn't update port line and column counts!
  */
 
-void 
+void
 scm_c_write (SCM port, const void *ptr, size_t size)
+#define FUNC_NAME "scm_c_write"
 {
-  scm_t_port *pt = SCM_PTAB_ENTRY (port);
-  scm_t_ptob_descriptor *ptob = &scm_ptobs[SCM_PTOBNUM (port)];
+  scm_t_port *pt;
+  scm_t_ptob_descriptor *ptob;
+
+  SCM_VALIDATE_OPOUTPORT (1, port);
+
+  pt = SCM_PTAB_ENTRY (port);
+  ptob = &scm_ptobs[SCM_PTOBNUM (port)];
 
   if (pt->rw_active == SCM_PORT_READ)
     scm_end_input (port);
@@ -1134,6 +1145,7 @@
   if (pt->rw_random)
     pt->rw_active = SCM_PORT_WRITE;
 }
+#undef FUNC_NAME
 
 void 
 scm_flush (SCM port)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]