guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch for port-line and port-column support for output ports


From: Matthias Koeppe
Subject: Patch for port-line and port-column support for output ports
Date: 05 Jun 2001 13:43:34 +0200

Here is a little patch that enables port-line and port-column updates
on writes. 

This is essential for a proper ~& format directive implementation (see
separate message). 

Index: libguile/ports.c
===================================================================
RCS file: /cvs/guile/guile-core/libguile/ports.c,v
retrieving revision 1.146
diff -u -r1.146 ports.c
--- libguile/ports.c    2001/05/26 20:51:21     1.146
+++ libguile/ports.c    2001/06/05 08:33:56
@@ -975,11 +975,8 @@
 
 /* scm_lfwrite
  *
- * Currently, this function has an identical implementation to
- * scm_c_write.  We could have turned it into a macro expanding into a
- * call to scm_c_write.  However, the implementation is small and
- * might differ in the future.
- */
+ * This function differs from scm_c_write; it updates port line and
+ * column. */
 
 void 
 scm_lfwrite (const char *ptr, size_t size, SCM port)
@@ -991,6 +988,18 @@
     scm_end_input (port);
 
   ptob->write (port, ptr, size);
+
+  for (; size; ptr++, size--) {
+    if (*ptr == '\n') {
+      SCM_INCLINE(port);
+    }
+    else if (*ptr == '\t') {
+      SCM_TABCOL(port);
+    }
+    else {
+      SCM_INCCOL(port);
+    }
+  }
 
   if (pt->rw_random)
     pt->rw_active = SCM_PORT_WRITE;

-- 
Matthias Köppe -- http://www.math.uni-magdeburg.de/~mkoeppe



reply via email to

[Prev in Thread] Current Thread [Next in Thread]