From f9c68a472c89d967eb2df0974672edb06c3ee675 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Fri, 25 Oct 1996 08:30:26 +0000 Subject: [PATCH] * read.c (scm_lreadr): Recognize SCSH-style block comments; text between `#!' and `!#' is ignored. (skip_scsh_block_comment): New function. --- libguile/read.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) 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));