1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-11 14:21:10 +02:00

* read.c (scm_lreadr): Recognize SCSH-style block comments; text

between `#!' and `!#' is ignored.
(skip_scsh_block_comment): New function.
This commit is contained in:
Jim Blandy 1996-10-25 08:30:26 +00:00
parent f29de79022
commit f9c68a472c

View file

@ -242,6 +242,31 @@ 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 `!#'. */
static void
skip_scsh_block_comment (port)
SCM port;
{
char last_c = '\0';
for (;;)
{
int c = scm_gen_getc (port);
if (c == EOF)
scm_wta (SCM_UNDEFINED,
"unterminated `#! ... !#' comment", "read");
else if (c == '#' && last_c == '!')
return;
last_c = c;
}
}
static char s_list[]="list";
SCM
@ -334,6 +359,12 @@ tryagain:
c = '#';
goto num;
case '!':
/* start of a shell script. Parse as a block comment,
terminated by !#, just like SCSH. */
skip_scsh_block_comment (port);
goto tryagain;
case '*':
j = scm_read_token (c, tok_buf, port, case_i, 0);
p = scm_istr2bve (SCM_CHARS (*tok_buf) + 1, (long) (j - 1));