bpt/guile.git
13 years agoavoid running GC when SCM_I_CURRENT_THREAD is unset
Andy Wingo [Fri, 25 Mar 2011 14:35:20 +0000 (15:35 +0100)]
avoid running GC when SCM_I_CURRENT_THREAD is unset

* libguile/threads.c (guilify_self_1): Prevent finalizers from running
  before SCM_I_CURRENT_THREAD is set.
  (do_thread_exit_trampoline): Leave the thread in the registered state.
  (on_thread_exit): Always unregister the thread here.

13 years agothreading / with_guile refactor to use more GC_stack_base
Andy Wingo [Fri, 25 Mar 2011 12:01:51 +0000 (13:01 +0100)]
threading / with_guile refactor to use more GC_stack_base

* libguile/init.h:
* libguile/init.c (scm_i_init_guile): Change arg to this internal
  function from SCM_STACKITEM* to void*.  Actually it's a
  struct GC_stack_base*.

* libguile/bdw-gc.h: Don't do pthread redirects, because we don't want
  to affect applications' pthread_* bindings.

* libguile/pthread-threads.h (scm_i_pthread_create)
  (scm_i_pthread_detach, scm_i_pthread_exit, scm_i_pthread_cancel)
  (scm_i_pthread_sigmask): Do pthread redirects here, in this internal
  header.

* libguile/threads.h: Remove declaration of internal
  scm_i_with_guile_and_parent.  Remove declaration of undefined
  scm_threads_init_first_thread.  Make declaration of internal
  scm_threads_prehistory actually internal, and take a void* (actually a
  struct GC_stack_base*).

* libguile/threads.c (GC_get_stack_base): Implement a shim if this
  function is unavailable, and fold in the implementations of
  get_thread_stack_base.
  (GC_call_with_stack_base): Actually implement.
  (guilify_self_1): Take a GC_stack_base* as an arg.
  (scm_i_init_thread_for_guile): Likewise, and set up libgc for
  registration of other threads.
  (scm_init_guile): Use GC_get_stack_base instead of our own guesswork.
  (with_guile_and_parent, scm_i_with_guile_and_parent): Rework to
  trampoline through a GC_call_with_stack_base.
  (scm_threads_prehistory): Pass the "base" arg on to guilify_self_1.

13 years agoRevert "with-continuation-barrier carps, calls exit(3) _after_ unwinding"
Andy Wingo [Fri, 25 Mar 2011 09:47:10 +0000 (10:47 +0100)]
Revert "with-continuation-barrier carps, calls exit(3) _after_ unwinding"

This reverts commit ecba00af6501e082b86c8f2f7730081c733509d7.

13 years agobdw-gc 6.8 compatibility (hopefully)
Andy Wingo [Thu, 24 Mar 2011 19:34:31 +0000 (20:34 +0100)]
bdw-gc 6.8 compatibility (hopefully)

* configure.ac (HAVE_GC_STACK_BASE): New check.

* libguile/threads.c (GC_UNIMPLEMENTED, GC_SUCCESS): Define if needed.
  (GC_register_my_thread, GC_unregister_my_thread)
  (GC_call_with_stack_base): Define shims if needed.

13 years agowith-continuation-barrier carps, calls exit(3) _after_ unwinding
Andy Wingo [Thu, 24 Mar 2011 19:20:14 +0000 (20:20 +0100)]
with-continuation-barrier carps, calls exit(3) _after_ unwinding

* libguile/continuations.c (scm_handler, c_handler)
  (scm_c_with_continuation_barrier, scm_with_continuation_barrier): Call
  scm_handle_by_message_noexit in the post-unwind handler, so that
  dynwinds

* test-suite/tests/continuations.test ("continuations"): Add a test.

13 years agofix a failure to sync regs in vm bytevector ops
Andy Wingo [Wed, 23 Mar 2011 16:05:28 +0000 (17:05 +0100)]
fix a failure to sync regs in vm bytevector ops

* libguile/vm-i-scheme.c (BV_SET_WITH_ENDIANNESS, BV_FIXABLE_INT_SET)
  (BV_INT_SET, BV_FLOAT_SET): Sync registers before dispatching to the C
  function.

13 years agoDo not enter the debugger if the thrown key is in `pass-keys'
Mark H Weaver [Tue, 22 Mar 2011 15:11:53 +0000 (11:11 -0400)]
Do not enter the debugger if the thrown key is in `pass-keys'

* module/system/repl/error-handling.scm (call-with-error-handling):
  Do _not_ enter the debugger if the thrown key is in `pass-keys'.
  Previously, for example, (throw 'quit) entered the debugger when run
  from the REPL, despite the fact that 'quit is in `pass-keys'.

13 years agoMake VM string literals immutable.
Ludovic Courtès [Sun, 20 Mar 2011 22:34:42 +0000 (23:34 +0100)]
Make VM string literals immutable.

* libguile/strings.c (scm_i_make_string, scm_i_make_wide_string): Add
  `read_only_p' parameter.  All callers updated.

* libguile/vm-i-loader.c (load_string, load_wide_string): Push read-only
  strings.

* test-suite/tests/strings.test ("literals"): New test prefix.

13 years agofix guile-snarf
BT Templeton [Sun, 20 Mar 2011 03:21:06 +0000 (23:21 -0400)]
fix guile-snarf

* libguile/snarf.h: New macro `SCM_SNARF_INIT_PREFIX'. (SCM_SNARF_INIT)
  Use `SCM_SNARF_INIT_PREFIX' instead of including a literal marker. If
  the preprocessor echoes #define directives to its output, this will
  prevent `guile-snarf' from snarfing the `SCM_SNARF_INIT' definition
  itself. Reported by Mike Gran <spk121@yahoo.com>.
* libguile/guile-snarf.in (modern_snarf): Don't output anything for
  lines in which only one of the magic snarfing markers is present.
  Modify the `sed' program for compatibility with POSIX `sed'. The new
  `sed' program is based on a version by Wolfgang Jenkner
  <wjenkner@inode.at>.
* test-suite/standalone/test-guile-snarf: New tests.

13 years agoAdd VM test for call/cc in non-tail position
Andreas Rottmann [Sun, 20 Mar 2011 00:00:09 +0000 (01:00 +0100)]
Add VM test for call/cc in non-tail position

* test-suite/vm/t-call-cc.scm: Add test case using call/cc in a non-tail
  position.

13 years agoFix syntax error in benchmark-suite/Makefile.am
Andreas Rottmann [Sat, 19 Mar 2011 23:49:07 +0000 (00:49 +0100)]
Fix syntax error in benchmark-suite/Makefile.am

* benchmark-suite/Makefile.am (SCM_BENCHMARKS): Correct position of
  a trailing backslash.

13 years agoBenchmarks for string comparisons
Michael Gran [Sat, 19 Mar 2011 22:25:28 +0000 (15:25 -0700)]
Benchmarks for string comparisons

* benchmark-suite/benchmarks/strings.bm: new file
* benchmark-suite/Makefile.am: add strings.bm

13 years agofix new-frame push in call/cc
Andy Wingo [Sat, 19 Mar 2011 22:12:40 +0000 (23:12 +0100)]
fix new-frame push in call/cc

* libguile/vm-i-system.c (call/cc): Whoops, fix the new-frame push
  here.  A little birdie tells me a test case is coming soon.

13 years agofix thread cleanup
Andy Wingo [Fri, 18 Mar 2011 12:18:47 +0000 (13:18 +0100)]
fix thread cleanup

* libguile/threads.h: Always declare a scm_i_thread_key, for cleanup
  purposes, in the BUILDING_LIBGUILE case.

* libguile/threads.c (scm_i_thread_key): Init with a cleanup handler, so
  any guile-specific info for a thread can be cleaned up reliably.
  (guilify_self_1): Always set the thread key.
  (do_thread_exit_trampoline, on_thread_exit): Enter guile-mode for the
  guile-mode cleanup handler, and trampoline through a
  gc_call_with_stack_base for reasons explained in the code.
  (init_thread_key, scm_i_init_thread_for_guile): Always init the key.
  (scm_i_with_guile_and_parent): No need for pthread_cancel cleanup
  handlers, as the pthread key destructor will take care of that for
  us.
  (really_launch): Remove needless pthread_exit call with incorrect
  comment.

13 years agoFix `i18n.test' when the German or Greek locales aren't available.
Ludovic Courtès [Fri, 18 Mar 2011 10:24:51 +0000 (11:24 +0100)]
Fix `i18n.test' when the German or Greek locales aren't available.

* test-suite/tests/i18n.test (%german-utf8-locale, %greek-utf8-locale):
  New variables.
  (under-german-utf8-locale-or-unresolved,
  under-greek-utf8-locale-or-unresolved): Use them.

13 years agoi18n: Add case mapping and case-insensitive string comparison tests.
Ludovic Courtès [Thu, 17 Mar 2011 21:44:25 +0000 (22:44 +0100)]
i18n: Add case mapping and case-insensitive string comparison tests.

Thanks to Mark H Weaver <mhw@netris.org> for coming up with most of the
examples.

* test-suite/tests/i18n.test (%german-utf8-locale-name,
  %greek-utf8-locale-name): New variables.
  (under-german-utf8-locale-or-unresolved,
  under-greek-utf8-locale-or-unresolved): New procedures.
  ("text collation (German)", "text collation (Greek)"): New tests
  prefixes.
  ("string mapping")["string-locale-upcase German",
  "string-locale-upcase Greek", "string-locale-upcase Greek (two
  sigmas)", "string-locale-downcase Greek", "string-locale-downcase
  Greek (two sigmas)"]: New tests.

13 years agoi18n: Re-enable tests with the Turkish locale.
Ludovic Courtès [Thu, 17 Mar 2011 21:31:48 +0000 (22:31 +0100)]
i18n: Re-enable tests with the Turkish locale.

* test-suite/tests/i18n.test ("character mapping")["char-locale-upcase
  Turkish", "char-locale-downcase Turkish"]: Re-enable.  Passes with
  GNU libc 2.12.1.
  ("string mapping")["string-locale-upcase Turkish",
  "string-locale-downcase Turkish"]: Likewise.

13 years agoadd multibyte regexp test
Andy Wingo [Thu, 17 Mar 2011 17:53:11 +0000 (18:53 +0100)]
add multibyte regexp test

* test-suite/standalone/Makefile.am:
* test-suite/standalone/test-mb-regexp: New test, that the previous
  patch fixed the abort() on fixup_multibyte_match.

13 years agoscm_{to,from}_locale_string use current locale, not current ports
Andy Wingo [Thu, 17 Mar 2011 17:29:08 +0000 (18:29 +0100)]
scm_{to,from}_locale_string use current locale, not current ports

* libguile/strings.c (scm_to_locale_stringn, scm_from_locale_stringn):
  Use the encoding of the current locale, not of the current i/o ports.
  Also use the current conversion strategy.

* doc/ref/api-data.texi (Conversion to/from C): Update docs.

13 years agoallow ,option on-error report instead of debug
Andy Wingo [Thu, 17 Mar 2011 11:33:58 +0000 (12:33 +0100)]
allow ,option on-error report instead of debug

* module/system/repl/command.scm:
* module/system/repl/debug.scm (terminal-width): Move terminal-width
  here, make it thread-local, and export it.
  (print-locals, print-frame, print-frames): Default width to
  terminal-width.

* module/system/repl/error-handling.scm (call-with-error-handling): Add
  `report' and `backtrace' on-error handlers.

* module/system/repl/common.scm (repl-default-options): Add on-error
  REPL option, defaulting to `debug', but which may be changed.

* module/system/repl/repl.scm (run-repl): Pass the #:on-error REPL
  option to call-with-error-handling.

13 years agoadd heap-allocated-since-gc to gc-stats
Andy Wingo [Thu, 17 Mar 2011 10:43:06 +0000 (11:43 +0100)]
add heap-allocated-since-gc to gc-stats

* libguile/gc.c (scm_gc_stats): Use add bytes_since_gc to the alist,
  under "heap-allocated-since-gc", and remove dead code.

13 years agofix code that causes warnings on gcc 4.6
Andy Wingo [Thu, 17 Mar 2011 10:42:50 +0000 (11:42 +0100)]
fix code that causes warnings on gcc 4.6

* libguile/arrays.c (scm_i_read_array):
* libguile/backtrace.c (display_backtrace_body):
* libguile/filesys.c (scm_readdir)
* libguile/i18n.c (chr_to_case):
* libguile/ports.c (register_finalizer_for_port):
* libguile/posix.c (scm_nice):
* libguile/stacks.c (scm_make_stack): Clean up a number of
  set-but-unused vars.  Thanks to Douglas Mencken for the report.

* libguile/numbers.c (scm_log, scm_exp): Fix a few #if cases that should
  be #ifdef.

13 years agoadd pointer->scm, scm->pointer
Andy Wingo [Thu, 17 Mar 2011 09:39:02 +0000 (10:39 +0100)]
add pointer->scm, scm->pointer

* libguile/foreign.c (scm_pointer_to_scm, scm_scm_to_pointer): New
  functions, useful to pass and receive SCM values to and from foreign
  functions.

* module/system/foreign.scm: Export the new functions.

* doc/ref/api-foreign.texi (Foreign Variables): Add docs.

* test-suite/tests/foreign.test ("pointer<->scm"): Tests.

13 years agoadd more prompt/abort tests
Andy Wingo [Tue, 15 Mar 2011 22:54:06 +0000 (23:54 +0100)]
add more prompt/abort tests

* test-suite/tests/control.test: Use c&e tests for most test blocks.
  Note that this did not catch the recent bug.
  ("reified continuations"): Add a new test for capturing partial
  continuations containing pending call frames.  Before these would
  contain dynamic links pointing out of the continuation segment, which
  would not be relocated; now, the dynamic links are only made when the
  frames are activated.

  Thanks to Wolfgang J Moeller for the bug report and test case.

13 years agofix frame dynamic linkage in the face of partial continuation application
Andy Wingo [Tue, 15 Mar 2011 22:33:32 +0000 (23:33 +0100)]
fix frame dynamic linkage in the face of partial continuation application

* libguile/vm-i-system.c (new-frame): Though it was appealing to set the
  dynamic link here on the incomplete frame, we no longer do that, for
  the reasons mentioned in the code.
  (call, mv-call): Adapt to set the frame's dynamic link.

* libguile/vm-engine.c (vm_engine): Don't set dynamic link here, even
  for boot program.

* libguile/frames.c (scm_frame_num_locals, scm_frame_local_ref)
  (scm_frame_local_set_x): Fix up not-yet-active frame detection.

13 years agodoc: Remove "lack of support for Unicode I/O and strings".
Ludovic Courtès [Sun, 13 Mar 2011 22:21:07 +0000 (23:21 +0100)]
doc: Remove "lack of support for Unicode I/O and strings".

* doc/ref/api-io.texi (R6RS I/O Ports): Remove 1.8ish comment.

13 years agoEnhance transcoder-related functionality of `(rnrs io ports)'
Andreas Rottmann [Sun, 13 Mar 2011 22:14:10 +0000 (23:14 +0100)]
Enhance transcoder-related functionality of `(rnrs io ports)'

* module/rnrs/io/ports.scm (transcoder-eol-style)
  (transcoder-error-handling-mode): Export these.
  (textual-port?): Implement this procedure and export it.
* module/rnrs.scm: Export these here as well.

* module/rnrs/io/ports.scm (port-transcoder): Implement this procedure.
  (binary-port?): Treat only ports without an encoding as binary ports,
  add docstring.
  (standard-input-port, standard-output-port, standard-error-port):
  Ensure these are created without an encoding.
  (eol-style): Add `none' as enumeration member.
  (native-eol-style): Switch to `none' from `lf'.

* test-suite/tests/r6rs-ports.test (7.2.7 Input ports)
  (8.2.10 Output ports): Test binary-ness of `standard-input-port',
  `standard-output-port' and `standard-error-port'.
  (8.2.6 Input and output ports): Add test for `port-transcoder'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoExport `current-*-port' from `(rnrs io ports)'
Andreas Rottmann [Sun, 13 Mar 2011 21:39:26 +0000 (22:39 +0100)]
Export `current-*-port' from `(rnrs io ports)'

* module/rnrs/io/ports.scm: Export `current-input-port',
  `current-output-port' and `current-error-port' (see R6RS 8.2.7 "Input
  ports" and 8.2.10 "Output ports").

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoAdd `get-string-n' and `get-string-n!' for R6RS ports
Andreas Rottmann [Sun, 13 Mar 2011 21:39:14 +0000 (22:39 +0100)]
Add `get-string-n' and `get-string-n!' for R6RS ports

* libguile/r6rs-ports.c (scm_get_string_n_x): Implement `get-string-n!'
  in C for efficiency.
* libguile/r6rs-ports.h: Add prototype for this function.
* module/ice-9/binary-ports.scm: Export `get-string-n!'.

* module/rnrs/io/ports.scm (get-string-n): Implement based on
  `get-string-n!'.
  Export both `get-string-n!' and `get-string-n'.
* module/rnrs.scm: Also export these.

* test-suite/tests/r6rs-ports.test (8.2.9 Textual input): Add a few
  tests for `get-string-n' and `get-string-n!'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoWork around weak-value hash table bug in `define-wrapped-pointer-type'.
Ludovic Courtès [Sun, 13 Mar 2011 15:09:55 +0000 (16:09 +0100)]
Work around weak-value hash table bug in `define-wrapped-pointer-type'.

* module/system/foreign.scm (define-wrapped-pointer-type)[wrap]: Use
  `hash-ref' and `hash-set!' instead of `hash-create-handle!' and
  `set-cdr!'.

13 years agoFix `define-inlinable' in SRFI-9 so that arguments are evaluated only once.
Ludovic Courtès [Fri, 11 Mar 2011 20:01:35 +0000 (21:01 +0100)]
Fix `define-inlinable' in SRFI-9 so that arguments are evaluated only once.

* module/srfi/srfi-9.scm (define-inlinable): When inlining, evaluate the
  arguments only once.  Reported by Andreas Rottmann; thanks to Andy
  Wingo for the elegant solution.

* test-suite/tests/srfi-9.test ("side-effecting arguments"): New test
  prefix.

13 years agofix port-filename without readline to match the docs
Andy Wingo [Fri, 11 Mar 2011 19:53:13 +0000 (20:53 +0100)]
fix port-filename without readline to match the docs

* libguile/init.c (stream_body, scm_standard_stream_to_port): Don't name
  stdin, stdout, and stderr -- at least not as strings.  That confuses
  any code which tries to treat port-filename as a real filename, like
  the syntax expander, or the `load' procedure/macro.  Also this
  behavior matches the docs now.

13 years agoFix bug to make `string=' much faster
Mark H Weaver [Thu, 10 Mar 2011 22:35:19 +0000 (17:35 -0500)]
Fix bug to make `string=' much faster

* libguile/srfi-13.c (scm_string_eq): Fix a bug which caused the slow
  general string_compare function to be used for strings of unequal
  lengths.

13 years agoThanks, Aidan.
Ludovic Courtès [Thu, 10 Mar 2011 21:24:40 +0000 (22:24 +0100)]
Thanks, Aidan.

13 years agoFFI: Return the right alignment for structures.
Ludovic Courtès [Thu, 10 Mar 2011 21:24:23 +0000 (22:24 +0100)]
FFI: Return the right alignment for structures.

* libguile/foreign.c (scm_alignof): Fix handling of structure alignment.
  Reported by Aidan Gauland <aidalgol@no8wireless.co.nz>.

* test-suite/tests/foreign.test ("structs")["alignof { int8, double,
  int8 }", "int8, { int8, double, int8 }, int16"]: New tests.

13 years agoUpdate Gnulib; add new modules; remove `round' module.
Mark H Weaver [Mon, 7 Mar 2011 11:27:42 +0000 (06:27 -0500)]
Update Gnulib; add new modules; remove `round' module.

This updates Gnulib to v0.0-4951-g6ff7b70.

* m4/gnulib-cache.m4: Add floor, ceil, frexp, and ldexp.  Add wchar as
  an explicit dependency; it had been present as an indirect dependency
  before, but no longer.  Remove round, which I had requested earlier,
  but turned out to be unnecessary.

13 years agofix-letrec tweaks
Andy Wingo [Wed, 9 Mar 2011 21:37:53 +0000 (22:37 +0100)]
fix-letrec tweaks

* module/language/tree-il/fix-letrec.scm (partition-vars): Previously,
  for letrec* we treated all unreferenced vars as complex, because of
  orderings of effects that could arise in their definitions.  But we
  can actually keep simple and lambda vars as unreferenced, as their
  initializers cannot cause side effects.
  (fix-letrec!): Remove letrec* -> letrec code, as it's unneeded.

13 years agoDon't mix definitions and expressions in SRFI-9
Andreas Rottmann [Wed, 9 Mar 2011 20:36:54 +0000 (21:36 +0100)]
Don't mix definitions and expressions in SRFI-9

The expansion of `define-inlinable' contained an expression, which made
SRFI-9's `define-record-type' fail in non-toplevel contexts ("definition
used in expression context").

* module/srfi/srfi-9.scm (define-inlinable): Get rid of apparently
  useless expression in the expansion, so the expansion yields only
  definitions.  At the same time, use a space in the generated names to
  lessen the chances of name conflicts, also avoiding -Wunused-toplevel
  warnings.
* test-suite/tests/srfi-9.test (non-toplevel): New test verifying that
  `define-record-type' works in non-toplevel context as well.
* doc/ref/srfi-modules.texi (SRFI-9 - define-record-type): Add
  subsubsection noting that Guile does not enforce top-levelness.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoAdd scm_from_latin1_keyword and scm_from_utf8_keyword
Mark H Weaver [Wed, 9 Mar 2011 06:14:43 +0000 (01:14 -0500)]
Add scm_from_latin1_keyword and scm_from_utf8_keyword

* libguile/keywords.c (scm_from_latin1_keyword, scm_from_utf8_keyword):
  New functions appropriate for use when keyword name is a constant.

  (scm_from_locale_keyword, scm_from_locale_keywordn): Change formal
  parameter from `str' to `name'.

* libguile/keywords.h: Add prototypes for new functions.  Change formal
  parameter of scm_from_locale_keyword* from `str' to `name'.

* doc/ref/api-data.texi: Document new functions.  Remind users that
  scm_from_locale_keyword should not be used when the name is a C string
  constant.  Change formal parameter from `str' to `name'.

13 years agoImprove docs of string and symbol conversions from C strings
Mark H Weaver [Tue, 8 Mar 2011 18:13:54 +0000 (13:13 -0500)]
Improve docs of string and symbol conversions from C strings

* doc/ref/api-data.texi (Conversion to/from C): Document
  scm_from_latin1_string, scm_from_utf8_string, and
  scm_from_utf32_string.  Remind readers that these functions should be
  used to convert C string constants, and that scm_from_locale_string is
  _not_ appropriate for that purpose.

  (Symbol Primitives): Document scm_from_latin1_symbol and
  scm_from_utf8_symbol.  Remind readers that these functions should be
  used when the specified names are C string constants, and that
  scm_from_locale_symbol is _not_ appropriate for that purpose.

13 years agoWithin `while', `continue' takes zero arguments
Mark H Weaver [Fri, 4 Mar 2011 18:44:02 +0000 (13:44 -0500)]
Within `while', `continue' takes zero arguments

* module/ice-9/boot-9.scm (while): Report an error if `continue' is
  passed one or more arguments.  Previously, it would report an error if
  `(continue arg rest ...)' was found within the `while', but not if
  `continue' was found bare and later applied to one or more arguments,
  e.g. `(apply continue (list arg rest ...))'.

13 years agoQuotient, remainder and modulo accept inexact integers
Mark H Weaver [Mon, 7 Mar 2011 01:27:40 +0000 (20:27 -0500)]
Quotient, remainder and modulo accept inexact integers

* libguile/numbers.c (scm_quotient, scm_remainder, scm_modulo): Accept
  inexact integers as well as exact ones, as required by the R5RS.

* test-suite/tests/numbers.test (quotient, remainder, modulo): Add tests.

13 years agoRemove incorrect footnote from GOOPS manual
Mark H Weaver [Tue, 1 Mar 2011 18:46:08 +0000 (13:46 -0500)]
Remove incorrect footnote from GOOPS manual

* doc/ref/goops.texi (Inheritance): Remove footnote which incorrectly
  stated that <complex> was not shown in the class hierarchy figure.

13 years agoUpdate comments regarding GMP earlier than 4.2.
Mark H Weaver [Wed, 23 Feb 2011 02:39:37 +0000 (21:39 -0500)]
Update comments regarding GMP earlier than 4.2.

* libguile/numbers.c: Update comments regarding GMP earlier than 4.2.
  Remove speculations about versions of GMP that had not yet been
  released when the comments were written.  Replace them with facts that
  are now known about the changes made in GMP 4.2.

13 years agoFix description of the R6RS `finite?' in manual
Mark H Weaver [Tue, 1 Mar 2011 17:37:01 +0000 (12:37 -0500)]
Fix description of the R6RS `finite?' in manual

* doc/ref/r6rs.texi (rnrs base): `(finite? x)' returns true iff x is
  neither infinite nor a NaN.  Previously, it stated that `finite?' was
  the negation of `infinite?', which was incorrect because NaNs are
  neither finite nor infinite.  Combine description of 'nan?' with those
  of `finite?' and `infinite?'.

13 years agoFix bytevectors VALIDATE_REAL to test for reals, not rationals
Mark H Weaver [Tue, 1 Mar 2011 17:46:38 +0000 (12:46 -0500)]
Fix bytevectors VALIDATE_REAL to test for reals, not rationals

Reported and fixed by Daniel Llorens <dll@bluewin.ch>.

* libguile/bytevectors.c (VALIDATE_REAL): Test for reals, not rationals.

* test-suite/tests/srfi-4.test (f32 vectors, f64 vectors): Add tests.

13 years agoscm_public_ref et al docs
Andy Wingo [Tue, 8 Mar 2011 21:34:53 +0000 (22:34 +0100)]
scm_public_ref et al docs

* doc/ref/api-modules.texi (Accessing Modules from C): Add docs for the
  new C procedures.

13 years agoeval-string docs
Andy Wingo [Tue, 8 Mar 2011 20:53:02 +0000 (21:53 +0100)]
eval-string docs

* doc/ref/api-evaluation.texi (Fly Evaluation): Update eval-string
  documentation.

13 years agodocument scm_call_{5,6,n}
Andy Wingo [Tue, 8 Mar 2011 20:06:12 +0000 (21:06 +0100)]
document scm_call_{5,6,n}

* doc/ref/api-evaluation.texi (Fly Evaluation): Document
  scm_call_{5,6,n}.

13 years agoadd scm_call_{5,6}
Andy Wingo [Tue, 8 Mar 2011 19:57:41 +0000 (20:57 +0100)]
add scm_call_{5,6}

* libguile/eval.h:
* libguile/eval.c (scm_call_5, scm_call_6): New scm_call functions; why
  not.

13 years agofix scm_setter
Andy Wingo [Tue, 8 Mar 2011 08:30:33 +0000 (09:30 +0100)]
fix scm_setter

* libguile/procs.c (scm_setter): Only get at the setter slot if the pure
  generic actually has a setter.  Needs test.

* test-suite/tests/goops.test ("defining generics"):
  ("defining accessors"): Add `setter' tests.

13 years agocore eval-string uses (ice-9 eval-string)
Andy Wingo [Tue, 8 Mar 2011 08:29:24 +0000 (09:29 +0100)]
core eval-string uses (ice-9 eval-string)

* libguile/strports.c (scm_eval_string_in_module): Use eval-string from
  (ice-9 eval-string).

13 years agoadd scm_c_public_ref et al
Andy Wingo [Tue, 8 Mar 2011 08:27:23 +0000 (09:27 +0100)]
add scm_c_public_ref et al

* libguile/modules.h:
* libguile/modules.c (scm_public_lookup, scm_private_lookup)
  (scm_c_public_lookup, scm_c_private_lookup, scm_public_ref)
  (scm_private_ref, scm_c_public_ref, scm_c_private_ref)
  (scm_public_variable, scm_private_variable, scm_c_public_variable)
  (scm_c_private_variable): New helpers to get at variables and values
  in modules.

13 years agoHandle `letrec*' like `letrec' in simple cases.
Ludovic Courtès [Sun, 6 Mar 2011 22:02:57 +0000 (23:02 +0100)]
Handle `letrec*' like `letrec' in simple cases.

* module/language/tree-il/fix-letrec.scm (fix-letrec!): When X is a
  `letrec*' with only lambdas and simple expressions, analyze it as if
  it were a `letrec'.
* test-suite/tests/tree-il.test ("letrec"): Add test for
  `(letrec* (x y) (xx yy) ((const 1) (const 2)) (lexical y yy))'.

13 years agoHave `gc-profile.scm' make sure it's on a Linux-based system.
Ludovic Courtès [Sun, 6 Mar 2011 21:27:53 +0000 (22:27 +0100)]
Have `gc-profile.scm' make sure it's on a Linux-based system.

* gc-benchmarks/gc-profile.scm (memory-mappings): Check %HOST-TYPE for
  "-linux-".

13 years agoAdd `gc-benchmarks/' to the distribution.
Ludovic Courtès [Sun, 6 Mar 2011 21:26:49 +0000 (22:26 +0100)]
Add `gc-benchmarks/' to the distribution.

* gc-benchmarks/Makefile.am: New file.

* configure.ac: Produce it.

* Makefile.am (SUBDIRS): Add `gc-benchmarks'.

13 years agoMake `object->string' explicitly close its string output port.
Ludovic Courtès [Sun, 6 Mar 2011 21:13:10 +0000 (22:13 +0100)]
Make `object->string' explicitly close its string output port.

* libguile/strports.c (scm_object_to_string): Close PORT before
  returning the resulting string.

13 years agoSlightly optimize `gensym'.
Ludovic Courtès [Sun, 6 Mar 2011 20:47:48 +0000 (21:47 +0100)]
Slightly optimize `gensym'.

* libguile/symbols.c (default_gensym_prefix): New variable.
  (scm_gensym): Use it.  Use `scm_from_latin1_stringn' instead of
  `scm_from_locale_stringn'.
  (scm_init_symbols): Initialize DEFAULT_GENSYM_PREFIX.

13 years agoSimply grow string port buffers geometrically.
Ludovic Courtès [Sun, 6 Mar 2011 13:31:28 +0000 (14:31 +0100)]
Simply grow string port buffers geometrically.

* libguile/strports.c (SCM_WRITE_BLOCK): Remove.
  (st_flush): Multiply `pt->write_buf_size' by 2.
  (st_seek): Likewise when TARGET == PT->write_buf_size.

13 years agoLet `scm_mkstrport' allocate buffers on the caller's behalf.
Ludovic Courtès [Sun, 6 Mar 2011 10:42:37 +0000 (11:42 +0100)]
Let `scm_mkstrport' allocate buffers on the caller's behalf.

* libguile/strports.c (INITIAL_BUFFER_SIZE): New macro.
  (scm_mkstrport): If STR is false, allocate a bytevector on the
  caller's behalf.
  (scm_object_to_string, scm_call_with_output_string,
  scm_open_output_string): Pass SCM_BOOL_F as the STR argument of
  `scm_mkstrport'.

* libguile/backtrace.c (scm_display_application,
  display_backtrace_body): Likewise.

* libguile/gdbint.c (scm_init_gdbint): Likewise.

* libguile/print.c (scm_simple_format): Likewise.

13 years agoUse a bytevector as the backing buffer of string ports.
Ludovic Courtès [Sat, 5 Mar 2011 19:15:09 +0000 (20:15 +0100)]
Use a bytevector as the backing buffer of string ports.

* libguile/strports.c (st_resize_port): Adjust to deal with OLD_STREAM
  and NEW_STREAM as bytevectors.
  (scm_mkstrport): Store a bytevector in the port's stream rather than a
  string.

13 years agoadd ice-9 eval-string
Andy Wingo [Sat, 5 Mar 2011 22:16:11 +0000 (23:16 +0100)]
add ice-9 eval-string

* module/Makefile.am:
* module/ice-9/eval-string.scm: New module, for use in implementing the
  scm_c_eval_string_from_file_line suggestion.

* test-suite/Makefile.am:
* test-suite/tests/eval-string.test: New tests.

13 years agoremove obsolete comments
Andy Wingo [Sat, 5 Mar 2011 20:48:47 +0000 (21:48 +0100)]
remove obsolete comments

* libguile/eval.c (scm_nconc2last):
* libguile/strports.c (scm_c_read_string): Remove some obsolete
  comments.

13 years agoUpdated Guile manual page.
Mark Harig [Sat, 5 Mar 2011 00:36:28 +0000 (19:36 -0500)]
Updated Guile manual page.

* doc/guile.1: Added the current month and year, Guile version
  descriptive text, and the text GNU to the title.

  Updated the nroff formatting commands for the SYNOPSIS and OPTIONS
  sections to what 'man' prescribes.  See 'man(1)', 'man(7)', and
  'man-pages(7)'.

  Corrected grammar, spelling, and capitalization (for example,
  'scheme' to 'Scheme').

  Vertical white-space was non-standard (two lines between some
  sections, one space between others).  Changed this to the standard
  one empty line before each section heading, and added dots (a single
  period on a line) before every section heading (.SH) so that
  maintainers will find the readability unchanged.

  Added white space to follow the 'groff' recommendation of starting
  every sentence on its own line, and breaking sentences at
  punctuation.

  Corrected an error in description of the info command.

  Added the missing option '--no-debug', and the short switches '-h'
  and '-v'.

  Changed the description of the environment variable
  GUILE_LOAD_COMPILED_PATH so that it references the Guile variable
  `%load-compiled-path' instead of the variable `%load-path'.

  Updated the copyright to include 2011.

13 years agoguile-snarf: allow multiple init actions on one line
BT Templeton [Tue, 22 Feb 2011 18:15:31 +0000 (13:15 -0500)]
guile-snarf: allow multiple init actions on one line

* libguile/guile-snarf.in (modern_snarf): Allow programs to specify
  multiple initialization actions on a single line. This makes it
  possible for C programs to define multiple subrs with a single macro
  invocation.

* test-suite/standalone/test-guile-snarf: Enable more tests.

13 years agoadd guile-snarf tests
BT Templeton [Tue, 22 Feb 2011 20:15:33 +0000 (15:15 -0500)]
add guile-snarf tests

* test-suite/standalone/test-guile-snarf: New file.
* test-suite/standalone/Makefile.am: Add `test-guile-snarf'.

13 years agorepl: terminal-width by default
Andy Wingo [Fri, 4 Mar 2011 10:16:15 +0000 (11:16 +0100)]
repl: terminal-width by default

* module/system/repl/command.scm (terminal-width): New parameter that
  will use the true terminal width if unset.
  (backtrace, locals): Default to (terminal-width).
  (width): Simplify.

13 years agoAdd ,width meta-command to set screen width in debug output
Michael Gran [Mon, 21 Feb 2011 05:53:46 +0000 (21:53 -0800)]
Add ,width meta-command to set screen width in debug output

This meta-command allows one to set the default number of columns
that output from ,backtrace and ,locals shall occupy.

* doc/ref/scheme-using.texi (Debug Commands): document ,width
* module/system/repl/command.scm (*width*): new var
  (backtrace, locals): use *width* in optarg
  (width): new meta-command

13 years agofix ,stat
Andy Wingo [Fri, 4 Mar 2011 09:33:51 +0000 (10:33 +0100)]
fix ,stat

* module/system/repl/command.scm (statistics): Fix for BDW-GC.
  Unfortunately we still don't have mallocation or time taken.

13 years agorepl.scm understands comments
Andy Wingo [Thu, 3 Mar 2011 22:51:20 +0000 (23:51 +0100)]
repl.scm understands comments

* module/system/repl/repl.scm (read-comment, read-scheme-line-comment)
  (read-scheme-datum-comment): New helpers.
  (meta-reader): Take a language instead of a reader.  If we have a
  nonwhitespace char, first check to see that it's a comment, and if so,
  read it off and loop.
  (prompting-meta-read): Call meta-reader with the lang.

13 years agorepl.scm refactor
Andy Wingo [Thu, 3 Mar 2011 22:19:35 +0000 (23:19 +0100)]
repl.scm refactor

* module/system/repl/repl.scm (flush-leading-whitespace): Rename from
  next-char.
  (meta-reader): Use flush-leading-whitespace.
  (run-repl): Use flush-to-newline after the evaluation, which seems to
  be the same as what we did before.

13 years agofix encoding scanning for non-seekable ports
Andy Wingo [Thu, 3 Mar 2011 11:46:49 +0000 (12:46 +0100)]
fix encoding scanning for non-seekable ports

* libguile/read.c (scm_i_scan_for_encoding): If possible, just use the
  read buffer for the encoding scan, and avoid seeking.  Fixes
  `(open-input-file "/dev/urandom")', because /dev/urandom can't be
  seeked backwards.

13 years agomore module-use-interfaces! tweaks
Andy Wingo [Thu, 3 Mar 2011 10:29:27 +0000 (11:29 +0100)]
more module-use-interfaces! tweaks

* module/ice-9/boot-9.scm (module-use-interfaces!): Fix up to prevent
  duplication in the use list of multiple incoming interfaces.

* test-suite/tests/modules.test ("module-use"): Add tests.

13 years agoUse module identity to filter for existing modules
Andreas Rottmann [Thu, 3 Mar 2011 10:09:54 +0000 (11:09 +0100)]
Use module identity to filter for existing modules

This fixes a problem with R6RS's `import' in particuliar: when importing
a subset of a library/module, the interface created for that purpose
inherits the name of the module it is derived from.  The low-level
primitives that are used for importing would then disregard earlier
imports from the same module.

An example for this bug can be seen with the following library
definition:

(library (test-guile2)
  (export foo)
  (import (only (rnrs base) define)
          (only (rnrs base) error))

  (define (foo . args)
    #t))

In the above, the import of `define' would be disregarded when `error'
is imported, thus leading to a syntax error, since `(foo . args)' is
treated as an application, since the binding of `define' would be not
present.

* module/ice-9/boot-9.scm (module-use!): Remove the filtering of the
  existing imports of the module by name; a check for identity is
  already done beforehand.
  (module-use-interfaces!): Filter the existing imports by identity
  instead of filtering them by their names.

13 years agoRemove extra comma after `SCM_ARRAY_ELEMENT_TYPE_LAST'.
Ludovic Courtès [Wed, 2 Mar 2011 23:13:30 +0000 (00:13 +0100)]
Remove extra comma after `SCM_ARRAY_ELEMENT_TYPE_LAST'.

* libguile/array-handle.h (scm_t_array_element_type): Remove extra comma
  after last element.  Reported by David Fang <fang@csl.cornell.edu>.
  Indent.

13 years agoImprove the documentation for `dynamic-link'.
Ludovic Courtès [Wed, 2 Mar 2011 21:12:56 +0000 (22:12 +0100)]
Improve the documentation for `dynamic-link'.

* doc/ref/api-foreign.texi (Foreign Libraries): Make it clear that the
  LIBRARY argument of `dynamic-link' should not contain an extension.
  (Foreign Functions): Add cross-reference from `load-extension' to
  `dynamic-link'.  Typeset file names and module names correctly.

13 years agoPortability fixes for popen.test (for when /bin/sh is not bash)
Mark H Weaver [Wed, 2 Mar 2011 11:02:58 +0000 (06:02 -0500)]
Portability fixes for popen.test (for when /bin/sh is not bash)

* test-suite/tests/popen.test (open-input-pipe no-duplicate): Pass
  "read REPLY" command instead of "read" to the subshell, for improved
  portability.  In particular, it is needed when /bin/sh is dash.

  (open-output-pipe no-duplicate): Pass "exec guile [...]" instead of
  "guile [...]" to the subshell, to ensure that the subshell will not
  run guile as a subprocess while holding a duplicate of STDIN, which
  would cause this test to fail.  This is needed when /bin/sh is dash.

13 years agoHave `read' update line/column numbers when reading SCSH block comments.
Ludovic Courtès [Mon, 28 Feb 2011 22:33:47 +0000 (23:33 +0100)]
Have `read' update line/column numbers when reading SCSH block comments.

* libguile/read.c (scm_read_scsh_block_comment): Use `scm_getc' instead
  of `scm_get_byte_or_eof'.

* test-suite/tests/reader.test ("read-options")["position of SCSH block
  comment"]: New test.

13 years agoupdate port-filename docs
Andy Wingo [Mon, 28 Feb 2011 19:53:40 +0000 (20:53 +0100)]
update port-filename docs

* doc/ref/api-io.texi (File Ports):
* libguile/ports.c (scm_port_filename): Fix docs to match
  implementation.

13 years agoLink stand-alone tests against libgc.
Ludovic Courtès [Sun, 27 Feb 2011 23:40:45 +0000 (00:40 +0100)]
Link stand-alone tests against libgc.

Reported by Andreas Rottmann <a.rottmann@gmx.at>.

* test-suite/standalone/Makefile.am (LIBGUILE_LDADD): New variable.
  (test_num2integral_LDADD, test_round_LDADD, libtest_asmobs_la_LIBADD,
  libtest_ffi_la_LIBADD, test_list_LDADD, test_unwind_LDADD,
  test_conversion_LDADD, test_loose_ends_LDADD, test_scm_c_read_LDADD,
  test_scm_take_locale_symbol_LDADD, test_scm_take_u8vector_LDADD,
  libtest_extensions_la_LIBADD, test_with_guile_module_LDADD,
  test_scm_with_guile_LDADD): Use it.

13 years agoStrip any CPPFLAGS other than `-I' from `guile-2.0.pc'.
Ludovic Courtès [Sun, 27 Feb 2011 23:21:48 +0000 (00:21 +0100)]
Strip any CPPFLAGS other than `-I' from `guile-2.0.pc'.

* configure.ac: Strip anything beyond `-I' from $GUILE_CFLAGS so that
  `guile-2.0.pc' does not export them to the user.  Reported and fixed
  by Bruno Haible <bruno@clisp.org>.

13 years agoflush all input on a read error
Andy Wingo [Sun, 27 Feb 2011 22:26:08 +0000 (23:26 +0100)]
flush all input on a read error

* module/system/repl/repl.scm (flush-all-input): New helper.
  (prompting-meta-read): Flush all input on a read error, as we could be
  within some expression or a string or something.

13 years agoscm-error-printer resilience
Andy Wingo [Sun, 27 Feb 2011 22:15:13 +0000 (23:15 +0100)]
scm-error-printer resilience

* module/ice-9/boot-9.scm (scm-error-printer): Allow #f for rest args,
  interpreting it as '().  Fixes regexp throws, which are of the form:

    (regular-expression-syntax "make-regexp" "Invalid preceding regular expression" #f ("?.*"))

13 years agoupdate R6RS incompatibilities
Andy Wingo [Sun, 27 Feb 2011 12:07:04 +0000 (13:07 +0100)]
update R6RS incompatibilities

* doc/ref/r6rs.texi (R6RS Incompatibilities): Update.

13 years agoregenerate psyntax-pp
Andy Wingo [Sun, 27 Feb 2011 11:59:44 +0000 (12:59 +0100)]
regenerate psyntax-pp

* module/ice-9/psyntax-pp.scm: Regenerate.

13 years agoadd syncase test
Andy Wingo [Sun, 27 Feb 2011 11:58:54 +0000 (12:58 +0100)]
add syncase test

* test-suite/tests/syncase.test ("top-level expansions"): New test.

13 years agochi-top-sequence defines macros before expanding other exps
Andy Wingo [Sun, 27 Feb 2011 11:48:23 +0000 (12:48 +0100)]
chi-top-sequence defines macros before expanding other exps

* module/ice-9/psyntax.scm (chi-top-sequence): Manually inline
  eval-if-c&e into its two call sites; I found it hard to understand
  otherwise.  If the mode is just 'e, defer expansion of definitions and
  expressions until the end, so that they can be expanded in a context
  of all syntax expanders defined in the sequence.

13 years agopsyntax: fold chi-top-sequence into chi-top
Andy Wingo [Sun, 27 Feb 2011 11:07:48 +0000 (12:07 +0100)]
psyntax: fold chi-top-sequence into chi-top

* module/ice-9/psyntax.scm (chi-top-sequence): Pull chi-top into the
  body of this toplevel begin expander.  This will let us do r6rs
  toplevel expansion correctly.
  (chi-top): Remove.
  (macroexpand): Dispatch to chi-top-sequence directly.

13 years agoFix `gc-profile.scm'.
Ludovic Courtès [Fri, 25 Feb 2011 13:54:36 +0000 (14:54 +0100)]
Fix `gc-profile.scm'.

* gc-benchmarks/gc-profile.scm (memory-mappings)[mapping-line-rx]: Fix
  and give an example.
  (total-heap-size): Fix docstring.

13 years agomake-weak-key-hash-table vacuuming
Andy Wingo [Fri, 25 Feb 2011 09:48:35 +0000 (10:48 +0100)]
make-weak-key-hash-table vacuuming

* libguile/hashtab.c (scm_make_weak_key_hash_table): Whoops, fix the
  case I actually cared about.

13 years agoRevert ""latin1" -> "Latin-1"."
Ludovic Courtès [Thu, 24 Feb 2011 22:17:23 +0000 (23:17 +0100)]
Revert ""latin1" -> "Latin-1"."

This reverts commit c2c550ca9d2442d070f79ed8bacb8db173c72df3.

The name "latin1" is standardized by IANA, unlike the other one.
Reported by Bruno Haible.

13 years agoMake `locale-digit-grouping' more robust.
Ludovic Courtès [Thu, 24 Feb 2011 22:17:06 +0000 (23:17 +0100)]
Make `locale-digit-grouping' more robust.

* libguile/i18n.c (scm_nl_langinfo)[GROUPING]: Consider negative numbers
  like `CHAR_MAX'.  Reported by David Fang <fang@csl.cornell.edu>.
  Fix suggested by Bruno Haible <bruno@clisp.org>.

13 years agoFix README.
Ludovic Courtès [Thu, 24 Feb 2011 22:13:54 +0000 (23:13 +0100)]
Fix README.

* README: Remove mention of an alpha release.  Reported by
  Mark H. Weaver.

13 years agoweak hash tables vacuum stale entries after a gc
Andy Wingo [Thu, 24 Feb 2011 16:00:30 +0000 (17:00 +0100)]
weak hash tables vacuum stale entries after a gc

* libguile/hashtab.c (scm_c_register_weak_gc_callback): New private
  helper, arranges for a C function to be called with a SCM as an
  argument, as long as the argument is reachable by GC.
  (scm_make_weak_key_hash_table)
  (scm_make_weak_value_hash_table)
  (scm_make_doubly_weak_hash_table): Register a weak GC callback to
  vacuum_weak_hash_table.

13 years agore-enable the after-gc-hook
Andy Wingo [Thu, 24 Feb 2011 15:30:08 +0000 (16:30 +0100)]
re-enable the after-gc-hook

* libguile/gc.c (scm_gc): No need to take a mutex here.  Don't run the
  hook, the hook will run itself.
  (scm_c_register_gc_callback): New private helper, registers a callback
  the next time GC happens.
  (system_gc_callback): Guile's internal callback that runs
  scm_after_gc_c_hook, which itself queues a call to the after-gc-hook.
  (scm_storage_prehistory): Queue up a call to system_gc_callback.

13 years agopointerless backing buffers for string ports
Andy Wingo [Thu, 24 Feb 2011 12:12:58 +0000 (13:12 +0100)]
pointerless backing buffers for string ports

* libguile/strports.c (scm_mkstrport): String port string buffer
  allocated atomically.

13 years agoerrno saving in display_string
Andy Wingo [Thu, 24 Feb 2011 12:10:16 +0000 (13:10 +0100)]
errno saving in display_string

* libguile/print.c (display_string): Fix a case in which perhaps `errno'
  could have been stompled.

13 years agoweb server more assiduous about closing ports
Andy Wingo [Thu, 24 Feb 2011 10:10:19 +0000 (11:10 +0100)]
web server more assiduous about closing ports

* module/web/uri.scm:
* module/web/server.scm (call-with-output-string*):
  (call-with-output-bytevector*): Local procs to output to strings or
  bytevectors, *and then close the port*.  We can't make this change in
  call-with-output-string because it would be incompatible.

* module/web/uri.scm (call-with-encoded-output-string, decode-string)
  (uri-decode)
* module/web/server.scm (call-with-encoded-output-string): Use the new
  helpers.

13 years agoopen-pipe* pumps pipes guardian
Andy Wingo [Wed, 23 Feb 2011 20:04:26 +0000 (21:04 +0100)]
open-pipe* pumps pipes guardian

* module/ice-9/popen.scm (open-pipe*): Hack around the lack of an
  after-gc hook, and pump the pipes guardian here in the procedure that
  adds to the guardian.

13 years agoGC dead links in weak hash tables before a possible rehash
Andy Wingo [Wed, 23 Feb 2011 10:59:38 +0000 (11:59 +0100)]
GC dead links in weak hash tables before a possible rehash

* libguile/hashtab.c (vacuum_weak_hash_table): New helper, goes through
  the entirety of a weak hash table, vacuuming dead entries.
  (scm_hash_fn_create_handle_x): If when adding to a weak hash table, we
  would trigger a rehash, vacuum the table first.  The weak_bucket_assoc
  would have only caught dead entries within one bucket.

  Without this patch, the following code leaks:

  (let lp ()
    (call-with-output-string
      (lambda (port)
        (display "foo" port)))
    (lp))