summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Blandy <jimb@red-bean.com>1997-04-19 13:25:28 +0000
committerJim Blandy <jimb@red-bean.com>1997-04-19 13:25:28 +0000
commitf9731264984e02133cf1ac26af7be9526ae94895 (patch)
tree707512fc3abf1979316ab6a7a11b6eb02adc83c5
parent0487b82f9fcee628c2482e14df38e5a7ff71149c (diff)
downloadguile-f9731264984e02133cf1ac26af7be9526ae94895.tar.gz
* read.c (skip_scsh_block_comment): SCSH says the !# that ends a
#! block comment must occur on a line all by itself.
-rw-r--r--libguile/read.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/libguile/read.c b/libguile/read.c
index 99c291c03..54ce6cfcc 100644
--- a/libguile/read.c
+++ b/libguile/read.c
@@ -239,13 +239,16 @@ recsexpr (obj, line, column, filename)
/* Consume an SCSH-style block comment. Assume that we've already
- read the initial `#!', and eat characters until the matching `!#'. */
+ read the initial `#!', and eat characters until we get a
+ newline/exclamation-point/sharp-sign/newline sequence. */
static void
skip_scsh_block_comment (port)
SCM port;
{
- char last_c = '\0';
+ /* Is this portable? Dear God, spare me from the non-eight-bit
+ characters. But is it tasteful? */
+ long history = 0;
for (;;)
{
@@ -254,10 +257,11 @@ skip_scsh_block_comment (port)
if (c == EOF)
scm_wta (SCM_UNDEFINED,
"unterminated `#! ... !#' comment", "read");
- else if (c == '#' && last_c == '!')
- return;
+ history = ((history << 8) | (c & 0xff)) & 0xffffffff;
- last_c = c;
+ /* Were the last four characters read "\n!#\n"? */
+ if (history == (('\n' << 24) | ('!' << 16) | ('#' << 8) | '\n'))
+ return;
}
}