Revision: 6035 Author: iratqq Date: Tue Oct 20 09:48:29 2009 Log: * uim/fileio.c (c_file_read, c_file_write): - Change buffer type (integer list to char list). - This change will reduce overhead of useless conversioning. * uim/openssl.c (c_SSL_read, c_SSL_write): - Ditto. - Apply r6031. * scm/fileio.scm (string->file-buf, file-buf->string) (file-read-char, file-peek-char): - Don't remap.
http://code.google.com/p/uim/source/detail?r=6035 Modified: /trunk/scm/fileio.scm /trunk/uim/fileio.c /trunk/uim/openssl.c ======================================= --- /trunk/scm/fileio.scm Mon Oct 12 08:04:29 2009 +++ /trunk/scm/fileio.scm Tue Oct 20 09:48:29 2009 @@ -54,9 +54,9 @@ (file-set-flag l file-poll-flags-alist)) (define (string->file-buf str) - (map char->integer (string->list str))) + (string->list str)) (define (file-buf->string buf) - (list->string (map integer->char buf))) + (list->string buf)) (define (file-read-string s len) (let ((ret (file-read s len))) (if (eof-object? ret) @@ -102,7 +102,7 @@ buf (let ((c (car buf))) (inbuf! port (cdr buf)) - (integer->char c))))) + c)))) (define (file-peek-char port) (if (null? (inbuf? port)) @@ -112,7 +112,7 @@ (not buf)) buf (let ((c (car buf))) - (integer->char c))))) + c)))) (define (file-display str port) ((write? port) (context? port) (string->file-buf str))) ======================================= --- /trunk/uim/fileio.c Mon Oct 12 08:04:29 2009 +++ /trunk/uim/fileio.c Tue Oct 20 09:48:29 2009 @@ -169,12 +169,12 @@ static uim_lisp c_file_read(uim_lisp d_, uim_lisp nbytes_) { - char *buf; + unsigned char *buf; uim_lisp ret_; int nbytes = C_INT(nbytes_); int i; int nr; - char *p; + unsigned char *p; buf = uim_malloc(nbytes); if ((nr = read(C_INT(d_), buf, nbytes)) == 0) @@ -185,7 +185,7 @@ p = buf; ret_ = uim_scm_null(); for (i = 0; i < nr; i++) { - ret_ = CONS(MAKE_INT(*p & 0xff), ret_); + ret_ = CONS(MAKE_CHAR(*p), ret_); p++; } free(buf); @@ -197,12 +197,12 @@ { int nbytes = uim_scm_length(buf_); uim_lisp ret_; - char *buf; - char *p; + unsigned char *buf; + unsigned char *p; buf = p = uim_malloc(nbytes); while (!NULLP(buf_)) { - *p = (char)C_INT(CAR(buf_)); + *p = C_CHAR(CAR(buf_)); p++; buf_ = CDR(buf_); } ======================================= --- /trunk/uim/openssl.c Mon Oct 12 07:41:45 2009 +++ /trunk/uim/openssl.c Tue Oct 20 09:48:29 2009 @@ -136,26 +136,23 @@ static uim_lisp c_SSL_read(uim_lisp s_, uim_lisp nbytes_) { - char *buf; + unsigned char *buf; uim_lisp ret_; int nbytes = C_INT(nbytes_); int i; int nr; - char *p; + unsigned char *p; buf = uim_malloc(nbytes); - if ((nr = SSL_read(C_PTR(s_), buf, nbytes)) == -1) { - char err[BUFSIZ]; - - snprintf(err, sizeof(err), "SSL-read: %s", strerror(errno)); - uim_notify_fatal(err); - ERROR_OBJ(err, s_); - } + if ((nr = SSL_read(C_PTR(s_), buf, nbytes)) == 0) + return uim_scm_eof(); + if (nr < 0) + return uim_scm_f(); p = buf; ret_ = uim_scm_null(); for (i = 0; i < nr; i++) { - ret_ = CONS(MAKE_INT(*p & 0xff), ret_); + ret_ = CONS(MAKE_CHAR(*p), ret_); p++; } free(buf); @@ -167,12 +164,12 @@ { int nbytes = uim_scm_length(buf_); uim_lisp ret_; - char *buf; - char *p; + unsigned char *buf; + unsigned char *p; buf = p = uim_malloc(nbytes); while (!NULLP(buf_)) { - *p = (char)C_INT(CAR(buf_)); + *p = C_CHAR(CAR(buf_)); p++; buf_ = CDR(buf_); }
