ports: Accept `#f' as a transcoder argument.
authorLudovic Courtès <ludo@gnu.org>
Mon, 20 Apr 2009 16:45:59 +0000 (20 18:45 +0200)
committerLudovic Courtès <ludo@gnu.org>
Mon, 20 Apr 2009 16:45:59 +0000 (20 18:45 +0200)
* src/ports.c (scm_r6rs_open_bytevector_input_port,
  scm_r6rs_open_bytevector_output_port): Accept TRANSCODER == #f.

* tests/io-ports.test ("7.2.7 Input Ports"): Call
  `open-bytevector-input-port' with `#f' sometimes.
  ("8.2.10 Output ports"): Likewise.

src/ports.c
tests/io-ports.test

index 6ce6787..c37dcea 100644 (file)
@@ -203,7 +203,7 @@ SCM_DEFINE (scm_r6rs_open_bytevector_input_port,
 #define FUNC_NAME s_scm_r6rs_open_bytevector_input_port
 {
   SCM_VALIDATE_R6RS_BYTEVECTOR (1, bv);
-  if (transcoder != SCM_UNDEFINED)
+  if (!SCM_UNBNDP (transcoder) && !scm_is_false (transcoder))
     transcoders_not_implemented ();
 
   return (make_bip (bv));
@@ -979,7 +979,7 @@ SCM_DEFINE (scm_r6rs_open_bytevector_output_port,
            "containing the data accumulated by the port.")
 #define FUNC_NAME scm_r6rs_open_bytevector_output_port
 {
-  if (transcoder != SCM_UNDEFINED)
+  if (!SCM_UNBNDP (transcoder) && !scm_is_false (transcoder))
     transcoders_not_implemented ();
 
   return (make_bop ());
index b97f4a6..5f56497 100644 (file)
     (let* ((str "Hello Port!")
            (bv (u8-list->bytevector (map char->integer
                                          (string->list str))))
-           (port (open-bytevector-input-port bv)))
+           (port (open-bytevector-input-port bv #f)))
 
       (write "hello" port)))
 
     (let* ((str "Hello Port!")
            (bv (u8-list->bytevector (map char->integer
                                          (string->list str))))
-           (port (open-bytevector-input-port bv)))
+           (port (open-bytevector-input-port bv #f)))
 
       (and (port-has-port-position? port)
            (= 0 (port-position port))
 
   (pass-if "open-bytevector-output-port"
     (let-values (((port get-content)
-                  (open-bytevector-output-port)))
+                  (open-bytevector-output-port #f)))
       (let ((source (make-bytevector 7777)))
         (put-bytevector port source)
         (and (bytevector=? (get-content) source)