guile-user
[Top][All Lists]
Advanced

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

port patch


From: Dr. Peter Ivanyi
Subject: port patch
Date: Wed, 28 May 2003 13:57:56 +0100

Hi,

I would like to propose this tiny patch. It modifies the peek-char function.
The problem is that if the peeked character is a new line, then the
column number is reset to zero (in scm_ungetc function). This does
not solve the problem of what to do with new line characters when ungetting
a character or a string but provides a consistent interface where peeking
and reading keeps a proper track of line and column numbers.

Probably it would also be good to mention in the documentation that when
ungetting a character or string the column number may not be consistent
with the actual value.

Thanx,

                                Peter Ivanyi

-------------------------------------------------------------------------

--- guile-1.6.4/libguile/ports.c        Sat Dec  7 22:41:32 2002
+++ guile-1.6.4-new/libguile/ports.c    Wed May 28 13:51:10 2003
@@ -1225,15 +1225,17 @@
            "to @code{read-char} would have hung.}")
 #define FUNC_NAME s_scm_peek_char
 {
-  int c;
+  int c, column;
   if (SCM_UNBNDP (port))
     port = scm_cur_inp;
   else
     SCM_VALIDATE_OPINPORT (1,port);
+  column = SCM_COL(port);
   c = scm_getc (port);
   if (EOF == c)
     return SCM_EOF_VAL;
   scm_ungetc (c, port);
+  SCM_COL(port) = column;
   return SCM_MAKE_CHAR (c);
 }
 #undef FUNC_NAME




reply via email to

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