[Gauche-devel-jp] Re: charconv fix

Back to archive index

HIRAUCHI Hideyuki hira****@verys*****
2004年 3月 17日 (水) 04:24:16 JST


度々すいません。どちらのpatchもインデントがずれてたので再送します。

--hira

--- test.scm.org	2004-03-17 03:46:42.377500000 +0900
+++ test.scm	2004-03-17 04:21:01.974625000 +0900
@@ -219,6 +219,16 @@
           '("EUCKR" "UTF-8" "ISO2022KR"))
 
 ;;--------------------------------------------------------------------
+(test-section "open -> #f")
+(test* "input :if-does-not-exist #f" #f
+  (with-input-from-file ":NOT;EXIST:" (lambda () (error "PANIC!"))
+                        :if-does-not-exist #f :encoding "*JP"))
+
+(test* "output :if-does-not-exist #f" #f
+  (with-output-to-file ":NOT;EXIST:" (lambda () (error "PANIC!"))
+                       :if-does-not-exist #f :encoding "UTF-8"))
+
+;;--------------------------------------------------------------------
 (test-section "code guessing")
 
 (define (test-guess file code scheme)

--- charconv.scm.org	2004-03-17 02:59:35.349000000 +0900
+++ charconv.scm	2004-03-17 04:20:46.677750000 +0900
@@ -201,21 +201,25 @@
 (define (open-input-file name . args)
   (cond ((get-keyword :encoding args #f)
          => (lambda (from-code)
-              (open-input-conversion-port
-               (with-module scheme (apply open-input-file name args))
-               from-code
-               :buffer-size (get-keyword :conversion-buffer-size args 0)
-               :owner #t)))
+              (let1 port (with-module scheme (apply open-input-file name args))
+                (and port 
+                     (open-input-conversion-port
+                      port
+                      from-code
+                      :buffer-size (get-keyword :conversion-buffer-size args 0)
+                      :owner #t)))))
         (else (with-module scheme (apply open-input-file name args)))))
 
 (define (open-output-file name . args)
   (cond ((get-keyword :encoding args #f)
          => (lambda (to-code)
-              (open-output-conversion-port
-               (with-module scheme (apply open-output-file name args))
-               to-code
-               :buffer-size (get-keyword :conversion-buffer-size args 0)
-               :owner #t)))
+              (let1 port (with-module scheme (apply open-output-file name args))
+                (and port
+                     (open-output-conversion-port
+                      port
+                      to-code
+                      :buffer-size (get-keyword :conversion-buffer-size args 0)
+                      :owner #t)))))
         (else (with-module scheme (apply open-output-file name args)))))
 
 (define (call-with-input-file filename proc . flags)




Gauche-devel-jp メーリングリストの案内
Back to archive index