() "Bill Schottstaedt" <b...@ccrma.stanford.edu> () Sun, 21 Jun 2009 05:10:09 -0700
code to implement #|..|# block comment processing triggers either a glibc memory complaint or a segfault. FWIW, below is the implementation from Guile 1.4.1.118 (not yet released). It handles nesting (per R6RS, i believe) and a weird lookahead case. thi _____________________________________________________________ /* Skip #|...|# block comments. */ static void skip_hashpipe_block_comment (SCM port) { #define FUNC_NAME s_scm_read int c; bool pipep = false; int oline = SCM_LINUM (port); int ocol = SCM_COL (port); for (;;) { if (EOF == (c = GETC ())) toosoon: { char buf[149]; snprintf (buf, 149, "%s\n%s:%d:%d: (starting here)", "unterminated `#| ... |#' comment", c_port_filename (port), 1 + oline, ocol - 1); BADNESS (0, buf); } if (pipep && '#' == c) return; /* Handle nested comments. */ retry: if ('#' == c) { if (EOF == (c = GETC ())) goto toosoon; if ('|' == c) { skip_hashpipe_block_comment (port); pipep = false; } else /* Don't get fooled by ##|...|# (ugh). */ goto retry; } pipep = ('|' == c); } #undef FUNC_NAME }