[uim-commit] r2789 - branches/r5rs/sigscheme

yamaken at freedesktop.org yamaken at freedesktop.org
Wed Jan 4 15:48:36 PST 2006


Author: yamaken
Date: 2006-01-04 15:48:33 -0800 (Wed, 04 Jan 2006)
New Revision: 2789

Modified:
   branches/r5rs/sigscheme/TODO
   branches/r5rs/sigscheme/basecport.c
   branches/r5rs/sigscheme/baseport.h
   branches/r5rs/sigscheme/fileport.c
   branches/r5rs/sigscheme/mbcport.c
   branches/r5rs/sigscheme/nullport.c
   branches/r5rs/sigscheme/sbcport.c
   branches/r5rs/sigscheme/strport.c
   branches/r5rs/sigscheme/strport.h
Log:
* sigscheme/basecport.c
  - (basecport_char_readyp): Change return type to scm_bool
* sigscheme/baseport.h
  - (scm_bool): New type
  - (scm_false, scm_true): New macro
  - (ScmCharPortMethod_char_readyp, ScmBytePortMethod_byte_readyp):
    Change return type to scm_bool
* sigscheme/fileport.c
  - (FALSE, TRUE): Removed
  - (struct ScmFilePort_): Change type of member ownership to scm_bool
  - (fileport_new_internal): Change type of arg 'ownership' to
    scm_bool
  - (fileport_byte_readyp): Change return type to scm_bool
  - (scm_fileport_init, fileport_write): Logical cleanup
  - (ScmFilePort_new, ScmFilePort_new_shared): Replace boolean values
    to scm_bool
* sigscheme/strport.h
  - (ScmInputStrPort_finalizer): Change type of arg 'ownership' to
    scm_bool
* sigscheme/strport.c
  - (struct ScmInputStrPort_): Change type of member
    'has_str_ownership' to scm_bool
  - (istrport_new): Change type of arg 'ownership' to scm_bool
  - (istrport_byte_readyp, ostrport_byte_readyp): Change return type
    to scm_bool
  - (scm_strport_init): Cleanup
  - (ScmInputStrPort_new, ScmInputStrPort_new_copying,
    ScmInputStrPort_new_const): Replace boolean values to scm_bool
* sigscheme/nullport.c
  - (nullport_byte_readyp): Change return type to scm_bool
* sigscheme/sbcport.c
  - (sbcport_put_char): Logical cleanup
* sigscheme/mbcport.c
  - (uchar): New type
  - (struct ScmMultiByteCharPort_): Change type of rbuf to uchar to
    prevent MSB loss by human error
  - (mbcport_char_readyp): Change return type to scm_bool
  - (mbcport_fill_rbuf): Change type of arg 'block' to scm_bool
  - (ScmMultiByteCharPort_set_codec, mbcport_get_char,
    mbcport_peek_char, mbcport_fill_rbuf): Follow the changes
  - (mbcport_put_char): Cosmetic change
* sigscheme/TODO
  - Update


Modified: branches/r5rs/sigscheme/TODO
===================================================================
--- branches/r5rs/sigscheme/TODO	2006-01-04 22:40:32 UTC (rev 2788)
+++ branches/r5rs/sigscheme/TODO	2006-01-04 23:48:33 UTC (rev 2789)
@@ -12,9 +12,9 @@
 * Fix all destructive expression on macros
 
 * Review and refactor all functions in syntax.c(listran, vectran,
-  qquote_internal, scm_s_quasiquote, scm_s_do) and *port.[hc]
-  sigschemeinternal.h, storage-fatty.h (other files had already been done
-  except for the destructive exp on macros)
+  qquote_internal, scm_s_quasiquote, scm_s_do), sigschemeinternal.h and
+  storage-fatty.h (other files had already been done except for the destructive
+  exp on macros)
 
 * Investigate behavior of other Scheme implementations about constant vector
   and list

Modified: branches/r5rs/sigscheme/basecport.c
===================================================================
--- branches/r5rs/sigscheme/basecport.c	2006-01-04 22:40:32 UTC (rev 2788)
+++ branches/r5rs/sigscheme/basecport.c	2006-01-04 23:48:33 UTC (rev 2789)
@@ -69,7 +69,7 @@
 static char *basecport_inspect(ScmBaseCharPort *port);
 static int basecport_get_char(ScmBaseCharPort *port);
 static int basecport_peek_char(ScmBaseCharPort *port);
-static int basecport_char_readyp(ScmBaseCharPort *port);
+static scm_bool basecport_char_readyp(ScmBaseCharPort *port);
 static int basecport_vprintf(ScmBaseCharPort *port, const char *str,
                              va_list args);
 static int basecport_puts(ScmBaseCharPort *port, const char *str);
@@ -184,7 +184,7 @@
     return SCM_BYTEPORT_PEEK_BYTE(port->bport);
 }
 
-static int
+static scm_bool
 basecport_char_readyp(ScmBaseCharPort *port)
 {
     return SCM_BYTEPORT_BYTE_READYP(port->bport);

Modified: branches/r5rs/sigscheme/baseport.h
===================================================================
--- branches/r5rs/sigscheme/baseport.h	2006-01-04 22:40:32 UTC (rev 2788)
+++ branches/r5rs/sigscheme/baseport.h	2006-01-04 23:48:33 UTC (rev 2789)
@@ -136,6 +136,12 @@
 /*=======================================
   Type Definitions
 =======================================*/
+#if (!defined(scm_true) && !defined(scm_false))
+typedef int scm_bool;
+#define scm_false 0
+#define scm_true  (!scm_false)
+#endif
+
 typedef struct ScmCharPortVTbl_ ScmCharPortVTbl;
 typedef struct ScmCharPort_     ScmCharPort;
 typedef struct ScmBaseCharPort_ ScmBaseCharPort;
@@ -154,7 +160,7 @@
 /* input */
 typedef int (*ScmCharPortMethod_get_char)(ScmCharPort *cport);
 typedef int (*ScmCharPortMethod_peek_char)(ScmCharPort *cport);
-typedef int (*ScmCharPortMethod_char_readyp)(ScmCharPort *cport);
+typedef scm_bool (*ScmCharPortMethod_char_readyp)(ScmCharPort *cport);
 
 /* output */
 typedef int (*ScmCharPortMethod_vprintf)(ScmCharPort *cport,
@@ -199,7 +205,7 @@
 /* input */
 typedef int (*ScmBytePortMethod_get_byte)(ScmBytePort *bport);
 typedef int (*ScmBytePortMethod_peek_byte)(ScmBytePort *bport);
-typedef int (*ScmBytePortMethod_byte_readyp)(ScmBytePort *bport);
+typedef scm_bool (*ScmBytePortMethod_byte_readyp)(ScmBytePort *bport);
 
 /* output */
 typedef int (*ScmBytePortMethod_vprintf)(ScmBytePort *bport,

Modified: branches/r5rs/sigscheme/fileport.c
===================================================================
--- branches/r5rs/sigscheme/fileport.c	2006-01-04 22:40:32 UTC (rev 2788)
+++ branches/r5rs/sigscheme/fileport.c	2006-01-04 23:48:33 UTC (rev 2789)
@@ -56,13 +56,6 @@
 /*=======================================
   File Local Macro Definitions
 =======================================*/
-#ifndef FALSE
-#define FALSE 0
-#endif /* FALSE */
-#ifndef TRUE
-#define TRUE  (!FALSE)
-#endif /* TRUE */
-
 #define OK 0
 
 /*=======================================
@@ -75,14 +68,14 @@
 
     FILE *file;
     char *aux_info;  /* human readable auxilialy information about the file */
-    int ownership;   /* whether close the file at fileport_close() */
+    scm_bool ownership;  /* whether close the file at fileport_close() */
 };
 
 /*=======================================
   File Local Function Declarations
 =======================================*/
 static ScmBytePort *fileport_new_internal(FILE *file, const char *aux_info,
-                                          int ownership);
+                                          scm_bool ownership);
 
 static ScmBytePort *fileport_dyn_cast(ScmBytePort *bport,
                                       const ScmBytePortVTbl *dest_vptr);
@@ -90,7 +83,7 @@
 static char *fileport_inspect(ScmFilePort *port);
 static int fileport_get_byte(ScmFilePort *bport);
 static int fileport_peek_byte(ScmFilePort *bport);
-static int fileport_byte_readyp(ScmFilePort *bport);
+static scm_bool fileport_byte_readyp(ScmFilePort *bport);
 static int fileport_vprintf(ScmFilePort *bport, const char *str, va_list args);
 static int fileport_puts(ScmFilePort *bport, const char *str);
 static size_t fileport_write(ScmFilePort *bport,
@@ -125,11 +118,10 @@
 void
 scm_fileport_init(void)
 {
-    return;
 }
 
 static ScmBytePort *
-fileport_new_internal(FILE *file, const char *aux_info, int ownership)
+fileport_new_internal(FILE *file, const char *aux_info, scm_bool ownership)
 {
     ScmFilePort *port;
 
@@ -146,13 +138,13 @@
 ScmBytePort *
 ScmFilePort_new(FILE *file, const char *aux_info)
 {
-    return fileport_new_internal(file, aux_info, TRUE);
+    return fileport_new_internal(file, aux_info, scm_true);
 }
 
 ScmBytePort *
 ScmFilePort_new_shared(FILE *file, const char *aux_info)
 {
-    return fileport_new_internal(file, aux_info, FALSE);
+    return fileport_new_internal(file, aux_info, scm_false);
 }
 
 ScmBytePort *
@@ -222,12 +214,12 @@
     return ungetc(ch, port->file);
 }
 
-static int
+static scm_bool
 fileport_byte_readyp(ScmFilePort *port)
 {
     /* does not support a FILE based on a pipe, or opened by fdopen(3) */
     /* FIXME: support stdin properly */
-    return TRUE;
+    return scm_true;
 }
 
 static int
@@ -245,7 +237,7 @@
 static size_t
 fileport_write(ScmFilePort *port, size_t nbytes, const char *buf)
 {
-    return fwrite(buf, 1, nbytes, port->file);
+    return fwrite(buf, sizeof(char), nbytes, port->file);
 }
 
 static int

Modified: branches/r5rs/sigscheme/mbcport.c
===================================================================
--- branches/r5rs/sigscheme/mbcport.c	2006-01-04 22:40:32 UTC (rev 2788)
+++ branches/r5rs/sigscheme/mbcport.c	2006-01-04 23:48:33 UTC (rev 2789)
@@ -66,6 +66,8 @@
 /*=======================================
   File Local Type Definitions
 =======================================*/
+typedef unsigned char uchar;
+
 struct ScmMultiByteCharPort_ {  /* inherits ScmBaseCharPort */
     const ScmCharPortVTbl *vptr;
 
@@ -74,7 +76,7 @@
 
     ScmCharCodec *codec;
     ScmMultibyteState state;
-    char rbuf[SCM_MB_MAX_LEN + sizeof("")];
+    uchar rbuf[SCM_MB_MAX_LEN + sizeof("")];
 };
 
 /*=======================================
@@ -86,11 +88,11 @@
 static char *mbcport_inspect(ScmMultiByteCharPort *port);
 static int mbcport_get_char(ScmMultiByteCharPort *port);
 static int mbcport_peek_char(ScmMultiByteCharPort *port);
-static int mbcport_char_readyp(ScmMultiByteCharPort *port);
+static scm_bool mbcport_char_readyp(ScmMultiByteCharPort *port);
 static int mbcport_put_char(ScmMultiByteCharPort *port, int ch);
 
 static ScmMultibyteCharInfo mbcport_fill_rbuf(ScmMultiByteCharPort *port,
-                                              int block);
+                                              scm_bool block);
 
 /*=======================================
   Variable Declarations
@@ -151,7 +153,7 @@
     mbcport->codec = codec;
     SCM_MBCPORT_CLEAR_STATE(mbcport);
     /* only one byte can be preserved for new codec. otherwise cleared */
-    if (1 < strlen(mbcport->rbuf))
+    if (1 < strlen((char *)mbcport->rbuf))
         mbcport->rbuf[0] = '\0';
 }
 
@@ -182,7 +184,7 @@
     ScmMultibyteCharInfo mbc;
     ScmMultibyteState next_state;
 
-    mbc = mbcport_fill_rbuf(port, TRUE);
+    mbc = mbcport_fill_rbuf(port, scm_true);
     next_state = SCM_MBCINFO_GET_STATE(mbc);
 #endif
 
@@ -205,30 +207,30 @@
     ScmMultibyteCharInfo mbc;
     int size, ch;
 
-    mbc = mbcport_fill_rbuf(port, TRUE);
+    mbc = mbcport_fill_rbuf(port, scm_true);
     size = SCM_MBCINFO_GET_SIZE(mbc);
     if (size)
-        ch = SCM_CHARCODEC_STR2INT(port->codec, port->rbuf, size, port->state);
+        ch = SCM_CHARCODEC_STR2INT(port->codec, (char *)port->rbuf, size,
+                                   port->state);
     else
         ch = EOF;
 
     return ch;
 }
 
-static int
+static scm_bool
 mbcport_char_readyp(ScmMultiByteCharPort *port)
 {
     ScmMultibyteCharInfo mbc;
 
-    mbc = mbcport_fill_rbuf(port, FALSE);
+    mbc = mbcport_fill_rbuf(port, scm_false);
     return !SCM_MBCINFO_INCOMPLETEP(mbc);
 }
 
 static int
 mbcport_put_char(ScmMultiByteCharPort *port, int ch)
 {
-    char wbuf[SCM_MB_MAX_LEN + sizeof("")];
-    char *end;
+    char *end, wbuf[SCM_MB_MAX_LEN + sizeof("")];
 
     /* FIXME: set updated state to port->state */
     end = SCM_CHARCODEC_INT2STR(port->codec, wbuf, ch, port->state);
@@ -238,17 +240,17 @@
 }
 
 static ScmMultibyteCharInfo
-mbcport_fill_rbuf(ScmMultiByteCharPort *port, int block)
+mbcport_fill_rbuf(ScmMultiByteCharPort *port, scm_bool block)
 {
-    char *end;
+    uchar *end;
     int byte;
     ScmMultibyteString mbs;
     ScmMultibyteCharInfo mbc;
 
-    end = strchr(port->rbuf, '\0');
+    end = (uchar *)strchr((char *)port->rbuf, '\0');
     SCM_MBS_SET_STATE(mbs, port->state);
     do {
-        SCM_MBS_SET_STR(mbs, port->rbuf);
+        SCM_MBS_SET_STR(mbs, (char *)port->rbuf);
         SCM_MBS_SET_SIZE(mbs, end - port->rbuf);
 
         mbc = SCM_CHARCODEC_SCAN_CHAR(port->codec, mbs);
@@ -266,7 +268,7 @@
             SCM_MBCINFO_INIT(mbc);
             port->rbuf[0] = '\0';
 #if HANDLE_MBC_START
-            mbc->start = port->rbuf;
+            mbc->start = (char *)port->rbuf;
 #endif
             break;
         }

Modified: branches/r5rs/sigscheme/nullport.c
===================================================================
--- branches/r5rs/sigscheme/nullport.c	2006-01-04 22:40:32 UTC (rev 2788)
+++ branches/r5rs/sigscheme/nullport.c	2006-01-04 23:48:33 UTC (rev 2789)
@@ -71,7 +71,7 @@
 static char *nullport_inspect(ScmNullPort *port);
 static int nullport_get_byte(ScmNullPort *bport);
 static int nullport_peek_byte(ScmNullPort *bport);
-static int nullport_byte_readyp(ScmNullPort *bport);
+static scm_bool nullport_byte_readyp(ScmNullPort *bport);
 static int nullport_vprintf(ScmNullPort *bport, const char *str, va_list args);
 static int nullport_puts(ScmNullPort *bport, const char *str);
 static size_t nullport_write(ScmNullPort *bport,
@@ -150,10 +150,10 @@
     return EOF;
 }
 
-static int
+static scm_bool
 nullport_byte_readyp(ScmNullPort *port)
 {
-    return TRUE;
+    return scm_true;
 }
 
 static int

Modified: branches/r5rs/sigscheme/sbcport.c
===================================================================
--- branches/r5rs/sigscheme/sbcport.c	2006-01-04 22:40:32 UTC (rev 2788)
+++ branches/r5rs/sigscheme/sbcport.c	2006-01-04 23:48:33 UTC (rev 2789)
@@ -143,5 +143,5 @@
     char buf[1];
 
     buf[0] = ch;
-    return SCM_BYTEPORT_WRITE(port->bport, 1, buf);
+    return SCM_BYTEPORT_WRITE(port->bport, sizeof(char), buf);
 }

Modified: branches/r5rs/sigscheme/strport.c
===================================================================
--- branches/r5rs/sigscheme/strport.c	2006-01-04 22:40:32 UTC (rev 2788)
+++ branches/r5rs/sigscheme/strport.c	2006-01-04 23:48:33 UTC (rev 2789)
@@ -68,7 +68,7 @@
 
     char *str;
     const char *cur;
-    int has_str_ownership;
+    scm_bool has_str_ownership;
     void *opaque;  /* client-specific opaque information */
     ScmInputStrPort_finalizer finalize;
 };
@@ -86,7 +86,7 @@
 /*=======================================
   File Local Function Declarations
 =======================================*/
-static ScmBytePort *istrport_new(char *str, int ownership,
+static ScmBytePort *istrport_new(char *str, scm_bool ownership,
                                  ScmInputStrPort_finalizer finalize);
 
 static ScmBytePort *istrport_dyn_cast(ScmBytePort *bport,
@@ -95,7 +95,7 @@
 static char *istrport_inspect(ScmInputStrPort *port);
 static int istrport_get_byte(ScmInputStrPort *port);
 static int istrport_peek_byte(ScmInputStrPort *port);
-static int istrport_byte_readyp(ScmInputStrPort *port);
+static scm_bool istrport_byte_readyp(ScmInputStrPort *port);
 static int istrport_vprintf(ScmInputStrPort *port,
                             const char *str, va_list args);
 static int istrport_puts(ScmInputStrPort *port, const char *str);
@@ -109,7 +109,7 @@
 static char *ostrport_inspect(ScmOutputStrPort *port);
 static int ostrport_get_byte(ScmOutputStrPort *port);
 static int ostrport_peek_byte(ScmOutputStrPort *port);
-static int ostrport_byte_readyp(ScmOutputStrPort *port);
+static scm_bool ostrport_byte_readyp(ScmOutputStrPort *port);
 static int ostrport_vprintf(ScmOutputStrPort *port,
                             const char *str, va_list args);
 static int ostrport_puts(ScmOutputStrPort *port, const char *str);
@@ -162,11 +162,10 @@
 void
 scm_strport_init(void)
 {
-    return;
 }
 
 static ScmBytePort *
-istrport_new(char *str, int ownership, ScmInputStrPort_finalizer finalize)
+istrport_new(char *str, scm_bool ownership, ScmInputStrPort_finalizer finalize)
 {
     ScmInputStrPort *port;
 
@@ -184,21 +183,21 @@
 ScmBytePort *
 ScmInputStrPort_new(char *str, ScmInputStrPort_finalizer finalize)
 {
-    return istrport_new(str, TRUE, finalize);
+    return istrport_new(str, scm_true, finalize);
 }
 
 ScmBytePort *
 ScmInputStrPort_new_copying(const char *str,
                             ScmInputStrPort_finalizer finalize)
 {
-    return istrport_new(strdup(str), TRUE, finalize);
+    return istrport_new(strdup(str), scm_true, finalize);
 }
 
 ScmBytePort *
 ScmInputStrPort_new_const(const char *str, ScmInputStrPort_finalizer finalize)
 {
     /* str is actually treated as const */
-    return istrport_new((char *)str, FALSE, finalize);
+    return istrport_new((char *)str, scm_false, finalize);
 }
 
 void **
@@ -250,10 +249,10 @@
     return (*port->cur) ? *port->cur : EOF;
 }
 
-static int
+static scm_bool
 istrport_byte_readyp(ScmInputStrPort *port)
 {
-    return TRUE;
+    return scm_true;
 }
 
 static int
@@ -362,7 +361,7 @@
     /* NOTREACHED */
 }
 
-static int
+static scm_bool
 ostrport_byte_readyp(ScmOutputStrPort *port)
 {
     SCM_PORT_ERROR_INVALID_OPERATION(BYTE, port, ScmOutputStrPort);

Modified: branches/r5rs/sigscheme/strport.h
===================================================================
--- branches/r5rs/sigscheme/strport.h	2006-01-04 22:40:32 UTC (rev 2788)
+++ branches/r5rs/sigscheme/strport.h	2006-01-04 23:48:33 UTC (rev 2789)
@@ -56,7 +56,7 @@
 /*=======================================
   Type Definitions
 =======================================*/
-typedef void (*ScmInputStrPort_finalizer)(char **str, int ownership,
+typedef void (*ScmInputStrPort_finalizer)(char **str, scm_bool ownership,
                                           void **opaque);
 typedef void (*ScmOutputStrPort_finalizer)(char **str, size_t buf_size,
                                            void **opaque);



More information about the uim-commit mailing list