bug-guile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: guile 1.9.0 scm_read_hash_extend gc trouble


From: Thien-Thi Nguyen
Subject: Re: guile 1.9.0 scm_read_hash_extend gc trouble
Date: Mon, 22 Jun 2009 10:50:07 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

() "Bill Schottstaedt" <address@hidden>
() 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
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]