mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-13 15:10:34 +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:
parent
f29de79022
commit
f9c68a472c
1 changed files with 31 additions and 0 deletions
|
@ -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";
|
static char s_list[]="list";
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
|
@ -334,6 +359,12 @@ tryagain:
|
||||||
c = '#';
|
c = '#';
|
||||||
goto num;
|
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 '*':
|
case '*':
|
||||||
j = scm_read_token (c, tok_buf, port, case_i, 0);
|
j = scm_read_token (c, tok_buf, port, case_i, 0);
|
||||||
p = scm_istr2bve (SCM_CHARS (*tok_buf) + 1, (long) (j - 1));
|
p = scm_istr2bve (SCM_CHARS (*tok_buf) + 1, (long) (j - 1));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue