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

yamaken at freedesktop.org yamaken at freedesktop.org
Mon Oct 31 22:37:58 PST 2005


Author: yamaken
Date: 2005-10-31 22:37:32 -0800 (Mon, 31 Oct 2005)
New Revision: 1918

Modified:
   branches/r5rs/sigscheme/baseport.h
   branches/r5rs/sigscheme/config.h
   branches/r5rs/sigscheme/mbcport.c
   branches/r5rs/sigscheme/read.c
   branches/r5rs/sigscheme/sbcport.c
   branches/r5rs/sigscheme/sbcport.h
   branches/r5rs/sigscheme/sigschemetype-compact.h
   branches/r5rs/sigscheme/sigschemetype.h
Log:
* sigscheme/config.h
  - (SCM_DEBUG_PORT): New macro
* sigscheme/baseport.h
  - (SCM_DEBUG_PORT): New macro
* sigscheme/sigschemetype.h
  - (SCM_PORT_LINE): Remove for SCM_USE_NEWPORT
* sigscheme/sigschemetype-compact.h
  - (SCM_PORT_LINE): Ditto
* sigscheme/sbcport.h
  - (struct ScmBaseCharPort_): Add member 'linenum'
  - (ScmBaseCharPort_line_number): New function decl
* sigscheme/sbcport.c
  - (ScmBaseCharPort_line_number): New function
  - (ScmBaseCharPort_construct, basecport_get_char): Add line number support
* sigscheme/mbcport.c
  - (mbcport_get_char): Ditto
* sigscheme/read.c
  - (read_list): Ditto


Modified: branches/r5rs/sigscheme/baseport.h
===================================================================
--- branches/r5rs/sigscheme/baseport.h	2005-11-01 06:02:15 UTC (rev 1917)
+++ branches/r5rs/sigscheme/baseport.h	2005-11-01 06:37:32 UTC (rev 1918)
@@ -53,6 +53,10 @@
 /*=======================================
   Macro Definitions
 =======================================*/
+#ifndef SCM_DEBUG_PORT
+#define SCM_DEBUG_PORT 0
+#endif
+
 /*
  * Define appropriate error handling such as exception to override these. The
  * macro MUST NOT return. The replacement expression should indicate that it

Modified: branches/r5rs/sigscheme/config.h
===================================================================
--- branches/r5rs/sigscheme/config.h	2005-11-01 06:02:15 UTC (rev 1917)
+++ branches/r5rs/sigscheme/config.h	2005-11-01 06:37:32 UTC (rev 1918)
@@ -91,6 +91,7 @@
 ===========================================================================*/
 #define SCM_DEBUG               1  /* 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 */
 #define SCM_DEBUG_ENCODING      0  /* debug encoding-related functions */
 #define SCM_DEBUG_BACKTRACE_SEP 1  /* enable frame-separator on backtrace */

Modified: branches/r5rs/sigscheme/mbcport.c
===================================================================
--- branches/r5rs/sigscheme/mbcport.c	2005-11-01 06:02:15 UTC (rev 1917)
+++ branches/r5rs/sigscheme/mbcport.c	2005-11-01 06:37:32 UTC (rev 1918)
@@ -167,6 +167,10 @@
     ch = mbcport_peek_char(port);
     port->rbuf[0] = '\0';
     SCM_MBCPORT_CLEAR_STATE(cport)
+#if SCM_DEBUG
+    if (ch == '\n')
+        port->linenum++;
+#endif
 
     return ch;
 }

Modified: branches/r5rs/sigscheme/read.c
===================================================================
--- branches/r5rs/sigscheme/read.c	2005-11-01 06:02:15 UTC (rev 1917)
+++ branches/r5rs/sigscheme/read.c	2005-11-01 06:37:32 UTC (rev 1918)
@@ -65,6 +65,9 @@
 =======================================*/
 #include "sigscheme.h"
 #include "sigschemeinternal.h"
+#if SCM_USE_NEWPORT
+#include "sbcport.h"
+#endif
 
 /*=======================================
   File Local Struct Declarations
@@ -288,12 +291,22 @@
     ScmObj list_tail = SCM_NULL;
     ScmObj item   = SCM_NULL;
     ScmObj cdr    = SCM_NULL;
+#if SCM_USE_NEWPORT
+    ScmBaseCharPort *basecport;
+    int    start_line, cur_line;
+#else
     int    line   = SCM_PORT_LINE(port);
+#endif
     int    c      = 0;
     int    c2     = 0;
     char  *token  = NULL;
 
     CDBG((SCM_DBG_PARSER, "read_list"));
+#if SCM_USE_NEWPORT
+    basecport = SCM_PORT_DYNAMIC_CAST(ScmBaseCharPort, SCM_PORT_IMPL(port));
+    if (basecport)
+        start_line = ScmBaseCharPort_line_number(basecport);
+#endif
 
     while (1) {
         c = skip_comment_and_space(port);
@@ -302,11 +315,15 @@
 
         if (c == EOF) {
 #if SCM_USE_NEWPORT
-            if (FALSE)
+            if (basecport) {
+                cur_line = ScmBaseCharPort_line_number(basecport);
+                ERR("EOF inside list at line %d. (starting from line %d)",
+                    cur_line, start_line);
+            }
 #else
             if (SCM_PORT_PORTTYPE(port) == PORT_FILE)
+                SigScm_Error("EOF inside list. (starting from line %d)", line + 1);
 #endif
-                SigScm_Error("EOF inside list. (starting from line %d)", line + 1);
             else
                 SigScm_Error("EOF inside list.");
         } else if (c == closeParen) {

Modified: branches/r5rs/sigscheme/sbcport.c
===================================================================
--- branches/r5rs/sigscheme/sbcport.c	2005-11-01 06:02:15 UTC (rev 1917)
+++ branches/r5rs/sigscheme/sbcport.c	2005-11-01 06:37:32 UTC (rev 1918)
@@ -113,8 +113,19 @@
 {
     port->vptr = ScmSingleByteCharPort_vptr;
     port->bport = bport;
+#if SCM_DEBUG
+    port->linenum = 1;
+#else
+    port->linenum = -1;
+#endif
 }
 
+int
+ScmBaseCharPort_line_number(ScmBaseCharPort *port)
+{
+    return port->linenum;
+}
+
 static ScmCharPort *
 basecport_dyn_cast(ScmCharPort *cport, const ScmCharPortVTbl *dst_vptr)
 {
@@ -140,7 +151,15 @@
 static int
 basecport_get_char(ScmBaseCharPort *port)
 {
-    return SCM_BYTEPORT_GET_BYTE(port->bport);
+    int ch;
+
+    ch = SCM_BYTEPORT_GET_BYTE(port->bport);
+#if SCM_DEBUG
+    if (ch == '\n')
+        port->linenum++;
+#endif
+
+    return ch;
 }
 
 static int

Modified: branches/r5rs/sigscheme/sbcport.h
===================================================================
--- branches/r5rs/sigscheme/sbcport.h	2005-11-01 06:02:15 UTC (rev 1917)
+++ branches/r5rs/sigscheme/sbcport.h	2005-11-01 06:37:32 UTC (rev 1918)
@@ -63,6 +63,7 @@
     const ScmCharPortVTbl *vptr;
 
     ScmBytePort *bport;  /* protected */
+    int linenum;         /* protected */
 };
 
 /*=======================================
@@ -79,6 +80,7 @@
 void ScmBaseCharPort_construct(ScmBaseCharPort *port,
                                const ScmCharPortVTbl *vptr,
                                ScmBytePort *bport);
+int ScmBaseCharPort_line_number(ScmBaseCharPort *port);
 
 void ScmSingleByteCharPort_construct(ScmSingleByteCharPort *port,
                                      const ScmCharPortVTbl *vptr,

Modified: branches/r5rs/sigscheme/sigschemetype-compact.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype-compact.h	2005-11-01 06:02:15 UTC (rev 1917)
+++ branches/r5rs/sigscheme/sigschemetype-compact.h	2005-11-01 06:37:32 UTC (rev 1918)
@@ -499,7 +499,6 @@
 #define SCM_PORT_FLAG(a)                    (SCM_GET_VALUE_AS_INT(SCM_AS_PORT(a)->cdr, SCM_TAG_OTHERS_VALUE_OFFSET_PORT))
 #define SCM_PORT_SET_IMPL(a, impl)          (SCM_SET_VALUE_AS_PTR(SCM_AS_PORT(a)->car, impl, SCM_TAG_OTHERS_PORT))
 #define SCM_PORT_SET_FLAG(a, flag)          (SCM_SET_VALUE_AS_INT(SCM_AS_PORT(a)->cdr, flag, SCM_TAG_OTHERS_VALUE_OFFSET_PORT, SCM_TAG_OTHERS_PORT))
-#define SCM_PORT_LINE(a)           (0)
 #else /* SCM_USE_NEWPORT */
 #define SCM_PORT_PORTINFO(a)                (SCM_GET_VALUE_AS_PTR(SCM_AS_PORT(a)->car, ~SCM_TAG_OTHERS_MASK_PORT))
 #define SCM_PORT_PORTDIRECTION(a)           (SCM_GET_VALUE_AS_INT(SCM_AS_PORT(a)->cdr, SCM_TAG_OTHERS_VALUE_OFFSET_PORT))

Modified: branches/r5rs/sigscheme/sigschemetype.h
===================================================================
--- branches/r5rs/sigscheme/sigschemetype.h	2005-11-01 06:02:15 UTC (rev 1917)
+++ branches/r5rs/sigscheme/sigschemetype.h	2005-11-01 06:37:32 UTC (rev 1918)
@@ -373,7 +373,6 @@
 #define SCM_PORT_SET_FLAG(a, flag) (SCM_PORT_FLAG(a) = (flag))
 #define SCM_PORT_IMPL(a)           (SCM_AS_PORT(a)->obj.port.impl)
 #define SCM_PORT_SET_IMPL(a, impl) (SCM_PORT_IMPL(a) = (impl))
-#define SCM_PORT_LINE(a)           (0)
 #else /* SCM_USE_NEWPORT */
 #define SCM_PORT_PORTDIRECTION(a) (SCM_AS_PORT(a)->obj.port.port_direction)
 #define SCM_PORT_SET_PORTDIRECTION(a, pdirection) (SCM_PORT_PORTDIRECTION(a) = pdirection)



More information about the uim-commit mailing list