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

yamaken at freedesktop.org yamaken at freedesktop.org
Fri Dec 16 17:32:51 PST 2005


Author: yamaken
Date: 2005-12-16 17:32:46 -0800 (Fri, 16 Dec 2005)
New Revision: 2626

Modified:
   branches/r5rs/sigscheme/config.h
   branches/r5rs/sigscheme/error.c
   branches/r5rs/sigscheme/io.c
   branches/r5rs/sigscheme/main.c
   branches/r5rs/sigscheme/operations.c
   branches/r5rs/sigscheme/print.c
   branches/r5rs/sigscheme/read.c
   branches/r5rs/sigscheme/sigscheme.h
   branches/r5rs/sigscheme/storage-gc.c
Log:
* This commit reorganize port API

* sigscheme/sigscheme.h
  - (SCM_PORT_CLOSE_IMPL, SCM_PORT_ENCODING, SCM_PORT_INSPECT,
    SCM_PORT_GET_CHAR, SCM_PORT_PEEK_CHAR, SCM_PORT_CHAR_READYP,
    SCM_PORT_VPRINTF, SCM_PORT_PUTS, SCM_PORT_PUT_CHAR,
    SCM_PORT_FLUSH): Removed
  - (scm_port_close, scm_port_encoding, scm_port_inspect,
    scm_port_get_char, scm_port_peek_char, scm_port_char_readyp,
    scm_port_puts, scm_port_put_char, scm_port_flush): New function decl
* sigscheme/io.c
  - (scm_port_close, scm_port_encoding, scm_port_inspect,
    scm_port_get_char, scm_port_peek_char, scm_port_char_readyp,
    scm_port_puts, scm_port_put_char, scm_port_flush): New function
  - (scm_port_vprintf, scm_port_newline, scm_p_close_input_port,
    scm_p_close_output_port, scm_p_read_char, scm_p_peek_char,
    scm_p_char_readyp, scm_load_internal, parse_script_prelude):
    Follow the reorganization
* sigscheme/read.c
  - (DISCARD_LOOKAHEAD, skip_comment_and_space, read_sequence,
    read_token, read_sexpression, read_list, read_char, read_string,
    read_number_or_symbol): Ditto
* sigscheme/print.c
  - (scm_write_to_port, scm_display_to_port, print_obj, print_char,
    print_string, print_list, print_vector, print_port,
    print_constant, print_errobj): Ditto
* sigscheme/storage-gc.c
  - (free_cell): Ditto
* sigscheme/error.c
  - (scm_p_inspect_error): Ditto
* sigscheme/operations.c
  - (scm_p_make_string, scm_p_list2string): Ditto
* sigscheme/main.c
  - (repl_loop): Ditto


Modified: branches/r5rs/sigscheme/config.h
===================================================================
--- branches/r5rs/sigscheme/config.h	2005-12-17 01:30:58 UTC (rev 2625)
+++ branches/r5rs/sigscheme/config.h	2005-12-17 01:32:46 UTC (rev 2626)
@@ -101,7 +101,7 @@
 /*===========================================================================
   Debugging
 ===========================================================================*/
-#define SCM_DEBUG               1  /* enable debugging features */
+#define SCM_DEBUG               0  /* enable debugging features */
 #define SCM_DEBUG_GC            0  /* enable GC debugging */
 #define SCM_DEBUG_PORT          1  /* enable port debugging */
 #define SCM_DEBUG_PARSER        0  /* enable parser debugging */

Modified: branches/r5rs/sigscheme/error.c
===================================================================
--- branches/r5rs/sigscheme/error.c	2005-12-17 01:30:58 UTC (rev 2625)
+++ branches/r5rs/sigscheme/error.c	2005-12-17 01:32:46 UTC (rev 2626)
@@ -264,9 +264,9 @@
         if (ERROBJP(err_obj)) {
             scm_display_to_port(scm_current_error_port, err_obj);
         } else {
-            SCM_PORT_PUTS(scm_current_error_port,
+            scm_port_puts(scm_current_error_port,
                           SCM_ERRMSG_UNHANDLED_EXCEPTION);
-            SCM_PORT_PUTS(scm_current_error_port, ": ");
+            scm_port_puts(scm_current_error_port, ": ");
             scm_write_to_port(scm_current_error_port, err_obj);
         }
         scm_error_newline();

Modified: branches/r5rs/sigscheme/io.c
===================================================================
--- branches/r5rs/sigscheme/io.c	2005-12-17 01:30:58 UTC (rev 2625)
+++ branches/r5rs/sigscheme/io.c	2005-12-17 01:32:46 UTC (rev 2626)
@@ -145,17 +145,18 @@
 void
 scm_port_vprintf(ScmObj port, const char *fmt, va_list args)
 {
-    SCM_PORT_VPRINTF(port, fmt, args);
+    SCM_ASSERT_LIVE_PORT(port);
+    SCM_CHARPORT_VPRINTF(SCM_PORT_IMPL(port), fmt, args);
 #if SCM_VOLATILE_OUTPUT
-    SCM_PORT_FLUSH(port);
+    scm_port_flush(port);
 #endif
 }
 
 void
 scm_port_newline(ScmObj port)
 {
-    SCM_PORT_PUTS(port, SCM_NEWLINE_STR);
-    SCM_PORT_FLUSH(port);  /* required */
+    scm_port_puts(port, SCM_NEWLINE_STR);
+    scm_port_flush(port);  /* required */
 }
 
 void
@@ -180,6 +181,73 @@
     scm_port_newline(scm_current_error_port);
 }
 
+int
+scm_port_close(ScmObj port)
+{
+    int err;
+
+    err = SCM_CHARPORT_CLOSE(SCM_PORT_IMPL(port));
+    SCM_PORT_SET_IMPL(port, NULL);
+
+    return err;
+}
+
+const char *
+scm_port_encoding(ScmObj port)
+{
+    SCM_ASSERT_LIVE_PORT(port);
+    return SCM_CHARPORT_ENCODING(SCM_PORT_IMPL(port));
+}
+
+char *
+scm_port_inspect(ScmObj port)
+{
+    SCM_ASSERT_LIVE_PORT(port);
+    return SCM_CHARPORT_INSPECT(SCM_PORT_IMPL(port));
+}
+
+int
+scm_port_get_char(ScmObj port)
+{
+    SCM_ASSERT_LIVE_PORT(port);
+    return SCM_CHARPORT_GET_CHAR(SCM_PORT_IMPL(port));
+}
+
+int
+scm_port_peek_char(ScmObj port)
+{
+    SCM_ASSERT_LIVE_PORT(port);
+    return SCM_CHARPORT_PEEK_CHAR(SCM_PORT_IMPL(port));
+}
+
+int
+scm_port_char_readyp(ScmObj port)
+{
+    SCM_ASSERT_LIVE_PORT(port);
+    return SCM_CHARPORT_CHAR_READYP(SCM_PORT_IMPL(port));
+}
+
+int
+scm_port_puts(ScmObj port, const char *str)
+{
+    SCM_ASSERT_LIVE_PORT(port);
+    return SCM_CHARPORT_PUTS(SCM_PORT_IMPL(port), str);
+}
+
+int
+scm_port_put_char(ScmObj port, int ch)
+{
+    SCM_ASSERT_LIVE_PORT(port);
+    return SCM_CHARPORT_PUT_CHAR(SCM_PORT_IMPL(port), ch);
+}
+
+int
+scm_port_flush(ScmObj port)
+{
+    SCM_ASSERT_LIVE_PORT(port);
+    return SCM_CHARPORT_FLUSH(SCM_PORT_IMPL(port));
+}
+
 /*=======================================
   R5RS : 6.6 Input and Output
 =======================================*/
@@ -339,7 +407,7 @@
     flag = SCM_PORT_FLAG(port) & ~SCM_PORTFLAG_LIVE_INPUT;
     SCM_PORT_SET_FLAG(port, flag);
     if (!(flag & SCM_PORTFLAG_ALIVENESS_MASK) && SCM_PORT_IMPL(port))
-        SCM_PORT_CLOSE_IMPL(port);
+        scm_port_close(port);
 
     return SCM_UNDEF;
 }
@@ -355,7 +423,7 @@
     flag = SCM_PORT_FLAG(port) & ~SCM_PORTFLAG_LIVE_OUTPUT;
     SCM_PORT_SET_FLAG(port, flag);
     if (!(flag & SCM_PORTFLAG_ALIVENESS_MASK) && SCM_PORT_IMPL(port))
-        SCM_PORT_CLOSE_IMPL(port);
+        scm_port_close(port);
 
     return SCM_UNDEF;
 }
@@ -392,7 +460,7 @@
 
     PREPARE_PORT(port, args, scm_current_input_port);
 
-    ch = SCM_PORT_GET_CHAR(port);
+    ch = scm_port_get_char(port);
     if (ch == EOF)
         return SCM_EOF;
 
@@ -408,7 +476,7 @@
 
     PREPARE_PORT(port, args, scm_current_input_port);
 
-    ch = SCM_PORT_PEEK_CHAR(port);
+    ch = scm_port_peek_char(port);
     if (ch == EOF)
         return SCM_EOF;
 
@@ -431,7 +499,7 @@
 
     PREPARE_PORT(port, args, scm_current_input_port);
 
-    return (SCM_PORT_CHAR_READYP(port))? SCM_TRUE : SCM_FALSE;
+    return (scm_port_char_readyp(port))? SCM_TRUE : SCM_FALSE;
 }
 
 /*===========================================================================
@@ -527,7 +595,7 @@
 
     saved_codec = scm_current_char_codec;
 #if SCM_USE_SRFI22
-    if (SCM_PORT_PEEK_CHAR(port) == '#')
+    if (scm_port_peek_char(port) == '#')
         interpret_script_prelude(port);
 #endif
 
@@ -623,7 +691,7 @@
     DECLARE_INTERNAL_FUNCTION("parse_script_prelude");
 
     for (p = line; p < &line[SCRIPT_PRELUDE_MAXLEN]; p++) {
-        c = SCM_PORT_GET_CHAR(port);
+        c = scm_port_get_char(port);
         if (!isascii(c))
             ERR("non-ASCII char appeared in UNIX script prelude");
         if (c == SCM_NEWLINE_STR[0]) {

Modified: branches/r5rs/sigscheme/main.c
===================================================================
--- branches/r5rs/sigscheme/main.c	2005-12-17 01:30:58 UTC (rev 2625)
+++ branches/r5rs/sigscheme/main.c	2005-12-17 01:32:46 UTC (rev 2626)
@@ -111,7 +111,7 @@
 
     for (;;) {
         if (show_promptp())
-            SCM_PORT_PUTS(scm_current_output_port, PROMPT_STR);
+            scm_port_puts(scm_current_output_port, PROMPT_STR);
 
 #if SCM_USE_SRFI34
         /* error-proof read */

Modified: branches/r5rs/sigscheme/operations.c
===================================================================
--- branches/r5rs/sigscheme/operations.c	2005-12-17 01:30:58 UTC (rev 2625)
+++ branches/r5rs/sigscheme/operations.c	2005-12-17 01:32:46 UTC (rev 2626)
@@ -1224,7 +1224,7 @@
     /* fill string (multibyte-ready) */
     sport = scm_p_srfi6_open_output_string();
     for (i = 0; i < len; i++) {
-        SCM_PORT_PUT_CHAR(sport, filler_val);
+        scm_port_put_char(sport, filler_val);
     }
 
     return scm_p_srfi6_get_output_string(sport);
@@ -1481,7 +1481,7 @@
     for (rest = lst; CONSP(rest); rest = CDR(rest)) {
         ch = CAR(rest);
         ASSERT_CHARP(ch);
-        SCM_PORT_PUT_CHAR(sport, SCM_CHAR_VALUE(ch));
+        scm_port_put_char(sport, SCM_CHAR_VALUE(ch));
     }
     if (!NULLP(rest))
         ERR_OBJ("invalid char list", lst);

Modified: branches/r5rs/sigscheme/print.c
===================================================================
--- branches/r5rs/sigscheme/print.c	2005-12-17 01:30:58 UTC (rev 2625)
+++ branches/r5rs/sigscheme/print.c	2005-12-17 01:32:46 UTC (rev 2626)
@@ -145,7 +145,7 @@
     print_obj(port, obj, AS_WRITE);
 
 #if SCM_VOLATILE_OUTPUT
-    SCM_PORT_FLUSH(port);
+    scm_port_flush(port);
 #endif /* SCM_VOLATILE_OUTPUT */
 }
 
@@ -162,7 +162,7 @@
     print_obj(port, obj, AS_DISPLAY);
 
 #if SCM_VOLATILE_OUTPUT
-    SCM_PORT_FLUSH(port);
+    scm_port_flush(port);
 #endif /* SCM_VOLATILE_OUTPUT */
 }
 
@@ -197,7 +197,7 @@
             print_list(port, obj, otype);
         break;
     case ScmSymbol:
-        SCM_PORT_PUTS(port, SCM_SYMBOL_NAME(obj));
+        scm_port_puts(port, SCM_SYMBOL_NAME(obj));
         break;
     case ScmChar:
         print_char(port, obj, otype);
@@ -206,18 +206,18 @@
         print_string(port, obj, otype);
         break;
     case ScmFunc:
-        SCM_PORT_PUTS(port, (SCM_SYNTAXP(obj)) ? "#<syntax " : "#<subr ");
+        scm_port_puts(port, (SCM_SYNTAXP(obj)) ? "#<syntax " : "#<subr ");
         sym = scm_symbol_bound_to(obj);
         if (NFALSEP(sym))
             scm_display_to_port(port, sym);
         else
             scm_port_printf(port, "%p", (void *)obj);
-        SCM_PORT_PUT_CHAR(port, '>');
+        scm_port_put_char(port, '>');
         break;
     case ScmClosure:
-        SCM_PORT_PUTS(port, "#<closure ");
+        scm_port_puts(port, "#<closure ");
         print_obj(port, SCM_CLOSURE_EXP(obj), otype);
-        SCM_PORT_PUT_CHAR(port, '>');
+        scm_port_put_char(port, '>');
         break;
     case ScmVector:
         print_vector(port, obj, otype);
@@ -226,19 +226,19 @@
         print_port(port, obj, otype);
         break;
     case ScmContinuation:
-        SCM_PORT_PUTS(port, "#<subr continuation>");
+        scm_port_puts(port, "#<subr continuation>");
         break;
     case ScmValuePacket:
-        SCM_PORT_PUTS(port, "#<values ");
+        scm_port_puts(port, "#<values ");
         if (NULLP(SCM_VALUEPACKET_VALUES(obj)))
-            SCM_PORT_PUTS(port, "()");
+            scm_port_puts(port, "()");
         else
             print_list(port, SCM_VALUEPACKET_VALUES(obj), otype);
 #if SCM_USE_VALUECONS
         /* SCM_VALUEPACKET_VALUES() changes the type destructively */
         SCM_ENTYPE_VALUEPACKET(obj);
 #endif
-        SCM_PORT_PUT_CHAR(port, '>');
+        scm_port_put_char(port, '>');
         break;
     case ScmConstant:
         print_constant(port, obj, otype);
@@ -265,11 +265,11 @@
     c = SCM_CHAR_VALUE(obj);
     switch (otype) {
     case AS_WRITE:
-        SCM_PORT_PUTS(port, "#\\");
+        scm_port_puts(port, "#\\");
         /* special chars */
         for (info = scm_special_char_table; info->esc_seq; info++) {
             if (c == info->code) {
-                SCM_PORT_PUTS(port, info->lex_rep);
+                scm_port_puts(port, info->lex_rep);
                 return;
             }
         }
@@ -281,7 +281,7 @@
         }
         /* FALLTHROUGH */
     case AS_DISPLAY:
-        SCM_PORT_PUT_CHAR(port, c);
+        scm_port_put_char(port, c);
         break;
 
     default:
@@ -303,23 +303,23 @@
 
     switch (otype) {
     case AS_WRITE:
-        SCM_PORT_PUT_CHAR(port, '\"'); /* first doublequote */
+        scm_port_put_char(port, '\"'); /* first doublequote */
         for (i = 0; i < len; i++) {
             c = str[i];
             for (info = scm_special_char_table; info->esc_seq; info++) {
                 if (c == info->code) {
-                    SCM_PORT_PUTS(port, info->esc_seq);
+                    scm_port_puts(port, info->esc_seq);
                     break;
                 }
             }
             if (!info->esc_seq)
-                SCM_PORT_PUT_CHAR(port, str[i]);
+                scm_port_put_char(port, str[i]);
         }
-        SCM_PORT_PUT_CHAR(port, '\"'); /* last doublequote */
+        scm_port_put_char(port, '\"'); /* last doublequote */
         break;
 
     case AS_DISPLAY:
-        SCM_PORT_PUTS(port, str);
+        scm_port_puts(port, str);
         break;
 
     default:
@@ -340,11 +340,11 @@
 #endif
 
     if (NULLP(lst)) {
-        SCM_PORT_PUTS(port, "()");
+        scm_port_puts(port, "()");
         return;
     }
 
-    SCM_PORT_PUT_CHAR(port, '(');
+    scm_port_put_char(port, '(');
 
     for (;;) {
         car = CAR(lst);
@@ -352,7 +352,7 @@
         lst = CDR(lst);
         if (!CONSP(lst))
             break;
-        SCM_PORT_PUT_CHAR(port, ' ');
+        scm_port_put_char(port, ' ');
 
 #if SCM_USE_SRFI38
         /* See if the next pair is shared.  Note that the case
@@ -375,7 +375,7 @@
 
     /* last item */
     if (!NULLP(lst)) {
-        SCM_PORT_PUTS(port, " . ");
+        scm_port_puts(port, " . ");
         /* Callee takes care of shared data. */
         print_obj(port, lst, otype);
     }
@@ -384,7 +384,7 @@
   close_parens_and_return:
     while (necessary_close_parens--)
 #endif
-        SCM_PORT_PUT_CHAR(port, ')');
+        scm_port_put_char(port, ')');
 }
 
 static void
@@ -393,17 +393,17 @@
     ScmObj *v;
     int len, i;
 
-    SCM_PORT_PUTS(port, "#(");
+    scm_port_puts(port, "#(");
 
     v = SCM_VECTOR_VEC(vec);
     len = SCM_VECTOR_LEN(vec);
     for (i = 0; i < len; i++) {
         if (i)
-            SCM_PORT_PUT_CHAR(port, ' ');
+            scm_port_put_char(port, ' ');
         print_obj(port, v[i], otype);
     }
 
-    SCM_PORT_PUT_CHAR(port, ')');
+    scm_port_put_char(port, ')');
 }
 
 static void
@@ -411,26 +411,26 @@
 {
     char *info;
 
-    SCM_PORT_PUTS(port, "#<");
+    scm_port_puts(port, "#<");
 
     /* input or output */
     /* print "i", "o" or "io" if bidirectional port */
     if (SCM_PORT_FLAG(obj) & SCM_PORTFLAG_INPUT)
-        SCM_PORT_PUT_CHAR(port, 'i');
+        scm_port_put_char(port, 'i');
     if (SCM_PORT_FLAG(obj) & SCM_PORTFLAG_OUTPUT)
-        SCM_PORT_PUT_CHAR(port, 'o');
+        scm_port_put_char(port, 'o');
 
-    SCM_PORT_PUTS(port, "port");
+    scm_port_puts(port, "port");
 
     /* file or string */
-    info = SCM_PORT_INSPECT(obj);
+    info = scm_port_inspect(obj);
     if (*info) {
-        SCM_PORT_PUT_CHAR(port, ' ');
-        SCM_PORT_PUTS(port, info);
+        scm_port_put_char(port, ' ');
+        scm_port_puts(port, info);
     }
     free(info);
 
-    SCM_PORT_PUT_CHAR(port, '>');
+    scm_port_put_char(port, '>');
 }
 
 static void
@@ -455,7 +455,7 @@
     else if (EQ(obj, SCM_UNDEF))
         str = "#<undef>";
 
-    SCM_PORT_PUTS(port, str);
+    scm_port_puts(port, str);
 }
 
 static void
@@ -472,14 +472,14 @@
 
     switch (otype) {
     case AS_WRITE:
-        SCM_PORT_PUTS(port, "#<error ");
+        scm_port_puts(port, "#<error ");
         scm_write_to_port(port, reason);
         break;
 
     case AS_DISPLAY:
         scm_display_to_port(port, reason);
         if (CONSP(objs))
-            SCM_PORT_PUT_CHAR(port, ':');
+            scm_port_put_char(port, ':');
         break;
 
     default:
@@ -488,12 +488,12 @@
     }
 
     for (; CONSP(objs); objs = CDR(objs)) {
-        SCM_PORT_PUT_CHAR(port, ' ');
+        scm_port_put_char(port, ' ');
         scm_write_to_port(port, CAR(objs));
     }
 
     if (otype == AS_WRITE)
-        SCM_PORT_PUT_CHAR(port, '>');
+        scm_port_put_char(port, '>');
 }
 
 #if SCM_USE_SRFI38

Modified: branches/r5rs/sigscheme/read.c
===================================================================
--- branches/r5rs/sigscheme/read.c	2005-12-17 01:30:58 UTC (rev 2625)
+++ branches/r5rs/sigscheme/read.c	2005-12-17 01:32:46 UTC (rev 2626)
@@ -72,7 +72,7 @@
 #define WHITESPACE_CHARS " \t\n\r\v\f"
 #define DELIMITER_CHARS  "()\";" WHITESPACE_CHARS
 
-#define DISCARD_LOOKAHEAD(port) (SCM_PORT_GET_CHAR(port))
+#define DISCARD_LOOKAHEAD(port) (scm_port_get_char(port))
 
 /*=======================================
   Variable Declarations
@@ -172,7 +172,7 @@
     int c, state;
 
     for (state = LEX_ST_NORMAL;;) {
-        c = SCM_PORT_PEEK_CHAR(port);
+        c = scm_port_peek_char(port);
         switch (state) {
         case LEX_ST_NORMAL:
             if (c == ';')
@@ -188,7 +188,7 @@
                 return c;  /* peeked */
             break;
         }
-        SCM_PORT_GET_CHAR(port);  /* skip the char */
+        scm_port_get_char(port);  /* skip the char */
     }
 }
 
@@ -199,7 +199,7 @@
     char *p;
 
     for (p = buf; p < &buf[len]; p++) {
-        c = SCM_PORT_GET_CHAR(port);
+        c = scm_port_get_char(port);
         if (c == EOF)
             ERR("unexpected EOF");
         if (!isascii(c))
@@ -218,7 +218,7 @@
     char *p;
 
     for (p = buf;;) {
-        c = SCM_PORT_PEEK_CHAR(port);
+        c = scm_port_peek_char(port);
         CDBG((SCM_DBG_PARSER, "c = %c", c));
 
         if (p == buf) {
@@ -286,7 +286,7 @@
 
         case '#':
             DISCARD_LOOKAHEAD(port);
-            c = SCM_PORT_GET_CHAR(port);
+            c = scm_port_get_char(port);
             switch (c) {
             case 't':
                 return SCM_TRUE;
@@ -311,7 +311,7 @@
 
         case ',':
             DISCARD_LOOKAHEAD(port);
-            c = SCM_PORT_PEEK_CHAR(port);
+            c = scm_port_peek_char(port);
             switch (c) {
             case EOF:
                 ERR("EOF in unquote");
@@ -392,7 +392,7 @@
                  * incompatibility problem into codes of SigScheme users,
                  * require explicit whitespace around the dot.
                  */
-                c = SCM_PORT_PEEK_CHAR(port);
+                c = scm_port_peek_char(port);
                 if (!strchr(WHITESPACE_CHARS, c))
                     ERR("implicit dot delimitation is disabled to avoid compatibility problem");
 #endif
@@ -487,8 +487,8 @@
     char buf[CHAR_LITERAL_LEN_MAX + sizeof((char)'\0')];
 
     /* plain char (multibyte-ready) */
-    c = SCM_PORT_GET_CHAR(port);
-    next = SCM_PORT_PEEK_CHAR(port);
+    c = scm_port_get_char(port);
+    next = scm_port_peek_char(port);
     if (strchr(DELIMITER_CHARS, next) || next == EOF)
         return scm_make_char(c);
 #if SCM_USE_SRFI75
@@ -532,7 +532,7 @@
     LBUF_INIT(lbuf, init_buf, sizeof(init_buf));
 
     for (offset = 0, p = LBUF_BUF(lbuf);; offset = p - LBUF_BUF(lbuf)) {
-        c = SCM_PORT_GET_CHAR(port);
+        c = scm_port_get_char(port);
 
         CDBG((SCM_DBG_PARSER, "read_string c = %c", c));
 
@@ -551,7 +551,7 @@
             return obj;
 
         case '\\':
-            c = SCM_PORT_GET_CHAR(port);
+            c = scm_port_get_char(port);
 #if SCM_USE_SRFI75
             if (strchr("xuU", c)) {
                 c = read_unicode_sequence(port, c);
@@ -635,7 +635,7 @@
 
     CDBG((SCM_DBG_PARSER, "read_number_or_symbol"));
 
-    c = SCM_PORT_PEEK_CHAR(port);
+    c = scm_port_peek_char(port);
 
     if (isascii(c)) {
         if (isdigit(c))

Modified: branches/r5rs/sigscheme/sigscheme.h
===================================================================
--- branches/r5rs/sigscheme/sigscheme.h	2005-12-17 01:30:58 UTC (rev 2625)
+++ branches/r5rs/sigscheme/sigscheme.h	2005-12-17 01:32:46 UTC (rev 2626)
@@ -168,40 +168,13 @@
 #define SCM_PORT_MALLOC(size)          (scm_malloc(size))
 #define SCM_PORT_CALLOC(number, size)  (scm_calloc(number, size))
 #define SCM_PORT_REALLOC(ptr, size)    (scm_realloc(ptr, size))
+/* Above five macros must be defined before this inclusion. */
+#include "baseport.h"
 
 #define SCM_ASSERT_LIVE_PORT(port)                                           \
     (SCM_PORT_IMPL(port)                                                     \
      || (scm_error_obj("(unknown)", "operated on closed port", port), 1))
 
-#define SCM_PORT_CLOSE_IMPL(port)                                            \
-    (SCM_CHARPORT_CLOSE(SCM_PORT_IMPL(port)), SCM_PORT_SET_IMPL(port, NULL))
-#define SCM_PORT_ENCODING(port)                                              \
-    (SCM_ASSERT_LIVE_PORT(port), SCM_CHARPORT_ENCODING(SCM_PORT_IMPL(port)))
-#define SCM_PORT_INSPECT(port)                                              \
-    (SCM_ASSERT_LIVE_PORT(port), SCM_CHARPORT_INSPECT(SCM_PORT_IMPL(port)))
-#define SCM_PORT_GET_CHAR(port)                                              \
-    (SCM_ASSERT_LIVE_PORT(port), SCM_CHARPORT_GET_CHAR(SCM_PORT_IMPL(port)))
-#define SCM_PORT_PEEK_CHAR(port)                                             \
-    (SCM_ASSERT_LIVE_PORT(port), SCM_CHARPORT_PEEK_CHAR(SCM_PORT_IMPL(port)))
-#define SCM_PORT_CHAR_READYP(port)                                           \
-    (SCM_ASSERT_LIVE_PORT(port), SCM_CHARPORT_CHAR_READYP(SCM_PORT_IMPL(port)))
-#define SCM_PORT_VPRINTF(port, str, args)                                    \
-    (SCM_ASSERT_LIVE_PORT(port),                                             \
-     SCM_CHARPORT_VPRINTF(SCM_PORT_IMPL(port), (str), (args)))
-#define SCM_PORT_PUTS(port, str)                                             \
-    (SCM_ASSERT_LIVE_PORT(port), SCM_CHARPORT_PUTS(SCM_PORT_IMPL(port), (str)))
-#define SCM_PORT_PUT_CHAR(port, ch)                                          \
-    (SCM_ASSERT_LIVE_PORT(port),                                             \
-     SCM_CHARPORT_PUT_CHAR(SCM_PORT_IMPL(port), (ch)))
-#define SCM_PORT_FLUSH(port)                                                 \
-    (SCM_ASSERT_LIVE_PORT(port), SCM_CHARPORT_FLUSH(SCM_PORT_IMPL(port)))
-
-/*
- * SCM_CHARPORT_ERROR and SCM_BYTEPORT_ERROR must be defined before this
- * inclusion
- */
-#include "baseport.h"
-
 #define SCM_WRITESS_TO_PORT(port, obj) ((*scm_writess_func)(port, obj))
 
 /*============================================================================
@@ -922,9 +895,18 @@
 void   scm_set_lib_path(const char *path);
 ScmObj scm_make_shared_file_port(FILE *file, const char *aux_info,
                               enum ScmPortFlag flag);
+int scm_port_close(ScmObj port);
+const char *scm_port_encoding(ScmObj port);
+char *scm_port_inspect(ScmObj port);
+int scm_port_get_char(ScmObj port);
+int scm_port_peek_char(ScmObj port);
+int scm_port_char_readyp(ScmObj port);
+int scm_port_puts(ScmObj port, const char *str);
+int scm_port_put_char(ScmObj port, int ch);
 void scm_port_printf(ScmObj port, const char *fmt, ...);
 void scm_port_vprintf(ScmObj port, const char *fmt, va_list args);
 void scm_port_newline(ScmObj port);
+int scm_port_flush(ScmObj port);
 void scm_error_printf(const char *fmt, ...);
 void scm_error_vprintf(const char *fmt, va_list args);
 void scm_error_newline(void);

Modified: branches/r5rs/sigscheme/storage-gc.c
===================================================================
--- branches/r5rs/sigscheme/storage-gc.c	2005-12-17 01:30:58 UTC (rev 2625)
+++ branches/r5rs/sigscheme/storage-gc.c	2005-12-17 01:32:46 UTC (rev 2626)
@@ -541,7 +541,7 @@
                 free(SCM_VECTOR_VEC(cell));
         } else if (SCM_SWEEP_PHASE_PORTP(cell)) {
             if (SCM_PORT_IMPL(cell))
-                SCM_PORT_CLOSE_IMPL(cell);
+                scm_port_close(cell);
         } else if (SCM_SWEEP_PHASE_CONTINUATIONP(cell)) {
             /*
              * Since continuation object is not so many, destructing the object by
@@ -578,7 +578,7 @@
 
     case ScmPort:
         if (SCM_PORT_IMPL(cell))
-            SCM_PORT_CLOSE_IMPL(cell);
+            scm_port_close(cell);
         break;
 
     /* rarely swept objects */



More information about the uim-commit mailing list