Revision: 5999
Author: iratqq
Date: Sat Sep 12 00:08:33 2009
Log: * scm/http-client.scm (http:read-header):
* scm/fileio.scm (file-read-char, file-peek-char)
  (file-read-line):
  - Use eof object.
* uim/fileio.c (c_make_fileio_eof, c_is_fileio_eof):
  - Teate eof object.

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

Modified:
 /trunk/scm/fileio.scm
 /trunk/scm/http-client.scm
 /trunk/uim/fileio.c

=======================================
--- /trunk/scm/fileio.scm       Sun Aug 30 00:51:55 2009
+++ /trunk/scm/fileio.scm       Sat Sep 12 00:08:33 2009
@@ -91,7 +91,7 @@
   (if (null? (inbuf? port))
       (inbuf! port ((read? port) (context? port) (inbufsiz? port))))
   (if (null? (inbuf? port))
-      #f
+      (make-fileio-eof)
       (let ((c (car (inbuf? port))))
         (inbuf! port (cdr (inbuf? port)))
         (integer->char c))))
@@ -100,7 +100,7 @@
   (if (null? (inbuf? port))
       (inbuf! port ((read? port) (context? port) (inbufsiz? port))))
   (if (null? (inbuf? port))
-      #f
+      (make-fileio-eof)
       (let ((c (car (inbuf? port))))
         (integer->char c))))

@@ -115,8 +115,8 @@
              (rest '()))
     (cond ((eq? #\newline c)
            (list->string (reverse rest)))
-          ((eq? #f c)
-           #f)
+          ((fileio-eof-object? c)
+           (make-fileio-eof))
           (else
            (loop (file-read-char port) (cons c rest))))))

=======================================
--- /trunk/scm/http-client.scm  Sat Aug 29 23:52:54 2009
+++ /trunk/scm/http-client.scm  Sat Sep 12 00:08:33 2009
@@ -138,7 +138,8 @@
 (define (http:read-header port)
   (let loop ((str (file-read-line port))
              (rest '()))
-    (if (or (null? str)
+    (if (or (fileio-eof-object? str)
+            (null? str)
             (string=? "\r" str))
         (reverse rest)
         (loop (file-read-line port) (cons str rest)))))
=======================================
--- /trunk/uim/fileio.c Sat Aug 29 22:10:43 2009
+++ /trunk/uim/fileio.c Sat Sep 12 00:08:33 2009
@@ -305,6 +305,22 @@
     return uim_scm_f();
   return CONS(MAKE_INT(fildes[0]), MAKE_INT(fildes[1]));
 }
+
+static int c_fileio_eof;
+
+static uim_lisp
+c_make_fileio_eof(void)
+{
+  return MAKE_PTR(&c_fileio_eof);
+}
+
+static uim_lisp
+c_is_fileio_eof(uim_lisp obj)
+{
+  if (!PTRP(obj))
+    return uim_scm_f();
+  return MAKE_BOOL(&c_fileio_eof == C_PTR(obj));
+}

 void
 uim_plugin_instance_init(void)
@@ -328,6 +344,9 @@
   uim_scm_gc_protect(&uim_lisp_poll_flags);

   uim_scm_init_proc0("create-pipe", c_create_pipe);
+
+  uim_scm_init_proc0("make-fileio-eof", c_make_fileio_eof);
+  uim_scm_init_proc1("fileio-eof-object?", c_is_fileio_eof);
 }

 void

Reply via email to