unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Type-checking in `scm_c_{read,write}'
@ 2007-12-04 17:55 Ludovic Courtès
  0 siblings, 0 replies; only message in thread
From: Ludovic Courtès @ 2007-12-04 17:55 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 127 bytes --]

Hi,

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

Thanks,
Ludovic.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: The patch --]
[-- Type: text/x-diff, Size: 1189 bytes --]

--- 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)




[-- Attachment #3: Type: text/plain, Size: 143 bytes --]

_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-12-04 17:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-04 17:55 Type-checking in `scm_c_{read,write}' Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).