diff --git a/libguile/read.c b/libguile/read.c index 7ef8151a2..d20318fdf 100644 --- a/libguile/read.c +++ b/libguile/read.c @@ -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));