Revision: 6031
Author: iratqq
Date: Mon Oct 12 08:04:29 2009
Log: * scm/fileio.scm (file-read-char, file-peek-char)
  (file-read-line):
  - Check fail case.
* uim/fileio.c (c_file_read):
  - Set eof if return value is 0 (on tcp socket, shutdown).
    When error, return #f.

http://code.google.com/p/uim/source/detail?r=6031

Modified:
 /trunk/scm/fileio.scm
 /trunk/uim/fileio.c

=======================================
--- /trunk/scm/fileio.scm       Mon Sep 21 19:27:12 2009
+++ /trunk/scm/fileio.scm       Mon Oct 12 08:04:29 2009
@@ -97,8 +97,8 @@
         (file-ready? (list (fd? port)) -1)
         (inbuf! port ((read? port) (context? port) (inbufsiz? port)))))
   (let ((buf (inbuf? port)))
-    (if (or (eof-object? buf)
-            (null? buf)) ;; disconnect?
+    (if (or (eof-object? buf) ;; disconnect?
+            (not buf))
         buf
         (let ((c (car buf)))
           (inbuf! port (cdr buf))
@@ -108,8 +108,8 @@
   (if (null? (inbuf? port))
       (inbuf! port ((read? port) (context? port) (inbufsiz? port))))
   (let ((buf (inbuf? port)))
-    (if (or (eof-object? buf)
-            (null? buf)) ;; disconnect?
+    (if (or (eof-object? buf) ;; disconnect?
+            (not buf))
         buf
         (let ((c (car buf)))
           (integer->char c)))))
@@ -125,8 +125,8 @@
              (rest '()))
     (cond ((eq? #\newline c)
            (list->string (reverse rest)))
-          ((or (eof-object? c)
-               (null? c)) ;; disconnect?
+          ((or (eof-object? c) ;; disconnect?
+               (not c))
            c)
           (else
            (loop (file-read-char port) (cons c rest))))))
=======================================
--- /trunk/uim/fileio.c Thu Sep 24 15:55:59 2009
+++ /trunk/uim/fileio.c Mon Oct 12 08:04:29 2009
@@ -177,8 +177,10 @@
   char *p;

   buf = uim_malloc(nbytes);
-  if ((nr = read(C_INT(d_), buf, nbytes)) == -1)
+  if ((nr = read(C_INT(d_), buf, nbytes)) == 0)
     return uim_scm_eof();
+  if (nr < 0)
+    return uim_scm_f();

   p = buf;
   ret_ = uim_scm_null();

Reply via email to