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: Neil Jerram
Subject: Re: guile 1.9.0 scm_read_hash_extend gc trouble
Date: Sun, 21 Jun 2009 16:56:48 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

Neil Jerram <address@hidden> writes:

> "Bill Schottstaedt" <address@hidden> writes:
>
>> static SCM g_skip_block_comment(SCM ch, SCM port)
> [...]
>> Then call scm_read_hash_extend with "|" to activate it.
>
> How do you wrap g_skip_block_comment to get a suitable argument for
> scm_read_hash_extend () ?

I had a go using scm_c_make_subr ().  But with the attached program
and test input (and current Git HEAD) I can't reproduce the seg fault
that you described.  Can you spot some way in which what you are doing
is different to this?

Regards,
        Neil

#include <libguile.h>

static SCM g_skip_block_comment(SCM ch, SCM port)
{
  int bang_seen = 0;
  while (1)
    {
      int c;
      c = scm_getc(port);
      if (c == EOF)
        {
          fprintf(stderr, "unterminated `#| ... |#' comment");
          return(SCM_BOOL_F);
        }
      if (c == '|')
        bang_seen = 1;
      else 
        {
          if ((c == '#') && (bang_seen))
            return(SCM_BOOL_F);
          else bang_seen = 0;
        }
    }
  return(SCM_BOOL_F);
}

void inner_main (void *closure, int argc, char **argv)
{
  scm_read_hash_extend (scm_integer_to_char (scm_from_char ('|')),
                        scm_c_make_subr ("skip-comment",
                                         scm_tc7_subr_2,
                                         g_skip_block_comment));
  scm_shell (argc, argv);
}

int main (int argc, char **argv)
{
  scm_boot_guile (argc, argv, inner_main, NULL);
}

/*
  Local variables:
  compile-command: "gcc bill.c -o bill"
  End:
*/

Attachment: bill.scm
Description: Binary data


reply via email to

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