Andy Wingo [Mon, 11 Apr 2011 11:38:27 +0000 (13:38 +0200)]
symbols with odd characters print better in #{}#
* libguile/print.c (symbol_has_extended_read_syntax): Use a more
general, unicode-appropriate algorithm. Hopefully doesn't cause
any current #{}# cases to be unescaped.
(print_extended_symbol): Use more appropriate unicode algorithm, and
emit unicode hex escapes instead of our own lame escapes.
* test-suite/tests/symbols.test: Add tests.
Andy Wingo [Mon, 11 Apr 2011 10:48:06 +0000 (12:48 +0200)]
read-extended-symbol handles backslash better, including r6rs hex escapes
* libguile/read.c (scm_read_extended_symbol): Interpret '\' as an escape
character. Due to some historical oddities we have to support '\'
before any character, but since we never emitted '\' in front of
"normal" characters like 'x' we can interpret "\x..;" to be an R6RS
hex escape.
* test-suite/tests/reader.test ("#{}#"): Add tests.
Andy Wingo [Mon, 11 Apr 2011 09:52:35 +0000 (11:52 +0200)]
refactor scm_i_print_symbol_name
* libguile/print.c (symbol_has_extended_read_syntax)
(print_normal_symbol, print_extended_symbol, scm_i_print_symbol_name):
Factor scm_i_print_symbol_name into separate routines. Add comments.
There are a number of bugs here.
Andy Wingo [Mon, 11 Apr 2011 08:13:48 +0000 (10:13 +0200)]
ignore SIGPIPE in (system repl server)
* module/system/repl/server.scm (run-server): Ignore SIGPIPE when we run
a server, as otherwise a rudely disconnected client could cause the
server to quit. Thanks to John Proctor for the report, and Detlev
Zundel for the debugging.
Mark H Weaver [Wed, 6 Apr 2011 19:09:42 +0000 (15:09 -0400)]
Fix the R6RS exact-integer-sqrt and import into core guile
* libguile/numbers.c (scm_exact_integer_sqrt): New C procedure to
compute exact integer square root and remainder.
(scm_i_exact_integer_sqrt): New Scheme procedure `exact-integer-sqrt'
from the R6RS, imported into core guile.
* libguile/numbers.h: Add prototypes.
* module/rnrs/base.scm: Remove broken stub implementation, which would
fail badly when applied to large integers.
* doc/ref/api-data.texi: Add documentation.
* doc/ref/r6rs.texi: Change documentation for `exact-integer-sqrt' to a
stub that xrefs the core docs, as is done for other operations
available in core.
* test-suite/tests/numbers.test: Add tests.
* NEWS: Add news entries.
Andreas Rottmann [Fri, 8 Apr 2011 21:56:30 +0000 (23:56 +0200)]
Implement R6RS' `fixnum?' in a smarter way
* module/rnrs/arithmetic/fixnums.scm (fixnum?): Implemented using
bit-twiddling, and using `define-inlinable'.
Mark H Weaver [Thu, 7 Apr 2011 06:28:01 +0000 (02:28 -0400)]
Fix typo in arithmetic benchmark
* benchmark-suite/benchmarks/arithmetic.bm (fixnum): Fix `-' benchmark
to actually use `-' operator instead of `+' operator.
Andreas Rottmann [Wed, 6 Apr 2011 23:12:26 +0000 (01:12 +0200)]
Move `define-inlinable' into the default namespace
* module/ice-9/boot-9.scm (define-inlineable): Moved here from SRFI-9.
* module/srfi/srfi-9 (define-inlinable): Removed here.
* doc/ref/api-procedures.texi (Inlinable Procedures): Add subsection
about `define-inlinable'.
Mark H Weaver [Wed, 6 Apr 2011 22:24:40 +0000 (18:24 -0400)]
Fix parsing of exact numbers with negative exponents
* libguile/numbers.c (mem2decimal_from_point): Use scm_divide instead of
scm_divide2real when applying a negative exponent, to preserve
exactness in case the "#e" forced exactness specifier is present.
This fixes a bug where numeric literals such as "#e1e-5" yielded
incorrect fractions.
Mark H Weaver [Wed, 6 Apr 2011 17:00:34 +0000 (13:00 -0400)]
Doc fix: quotient/remainder/modulo do not require exact arguments
* doc/ref/api-data.texi (Arithmetic): `floor-remainder' is equivalent to
the R5RS `modulo' when the arguments are integers. Previously,
equivalence was claimed only for exact integers. Similarly for
`truncate-quotient' and `truncate-remainder' compared with the R5RS
`quotient' and `remainder'.
Mark H Weaver [Tue, 5 Apr 2011 23:42:06 +0000 (19:42 -0400)]
Undeprecate read syntax for uniform complex vectors
* libguile/read.c (scm_read_sharp): Move the "#c..." case outside of
#if SCM_ENABLE_DEPRECATED, and to the same section which handles
"#s...", "#u..." and "#f...".
Thanks to Andreas Rottmann <a.rottmann@gmx.at> for the bug report.
Andreas Rottmann [Sat, 2 Apr 2011 17:42:27 +0000 (19:42 +0200)]
Several optimizations for R6RS fixnum arithmetic
* module/rnrs/arithmetic/fixnums.scm (assert-fixnum): Is now a
macro.
(assert-fixnums): New procedure checking a the elements of a list
for fixnum-ness. All callers applying `assert-fixnum' to a list
now changed to use this procedure.
* module/rnrs/arithmetic/fixnums.scm (define-fxop*): New for defining
n-ary inlinable special-casing the binary case using `case-lambda'.
All applicable procedures redefined using this macro.
* module/rnrs/arithmetic/fixnums.scm: Alias all predicates to
their non-fixnum counterparts.
Andreas Rottmann [Sat, 2 Apr 2011 17:42:26 +0000 (19:42 +0200)]
Add a few benchmarks for R6RS fixnum arithmetic
* benchmark-suite/benchmarks/r6rs-arithmetic.bm: New file containing
some benchmarks for R6RS fixnum operations.
* benchmark-suite/Makefile.am (SCM_BENCHMARKS): Add
benchmarks/r6rs-arithmetic.
Andy Wingo [Sun, 3 Apr 2011 20:03:56 +0000 (22:03 +0200)]
pthread-threads.h: only redirect to GC_pthread_sigmask if it is present
* configure.ac: Check for pthread_sigmask.
* libguile/gen-scmconfig.c: Create SCM_HAVE_GC_PTHREAD_SIGMASK.
* libguile/pthread-threads.h (scm_i_pthread_sigmask): Only redirect to
GC_pthread_sigmask if GC_pthread_sigmask is present.
Andy Wingo [Fri, 1 Apr 2011 14:45:58 +0000 (16:45 +0200)]
fix c32vector-set!, c64vector-set!
* module/srfi/srfi-4/gnu.scm (bytevector-c32-native-set!):
(bytevector-c64-native-set!): Fix to actually allow complex numbers.
* test-suite/tests/srfi-4.test: Add tests.
Andy Wingo [Fri, 1 Apr 2011 11:31:26 +0000 (13:31 +0200)]
string->pointer and pointer->string have optional encoding arg
* test-suite/tests/foreign.test ("pointer<->string"): Add test cases.
* libguile/foreign.c (scm_string_to_pointer, scm_pointer_to_string): Add
optional encoding, and in the pointer->string case, length arguments.
* libguile/foreign.h: Update prototypes of internal functions.
Shouldn't affect ABI as they are internal.
* doc/ref/api-foreign.texi (Void Pointers and Byte Access): Update
docs.
Andy Wingo [Fri, 1 Apr 2011 10:10:42 +0000 (12:10 +0200)]
support loading objcode even if mmap(2) is unavailable
* configure.ac: Check for sys/mman.h.
* libguile/objcodes.c (verify_cookie): Factor cookie verification out to
a helper function.
(make_objcode_from_file): Rename from make_objcode_by_mmap. If mmap
is unavailable, just read(2) to a bytevector.
Andy Wingo [Fri, 1 Apr 2011 09:23:12 +0000 (11:23 +0200)]
make_objcode_by_mmap uses MAP_PRIVATE, not MAP_SHARED
* libguile/objcodes.c (make_objcode_by_mmap): MAP_PRIVATE, not
MAP_SHARED -- we don't need to update the underlying file, nor do we
need to see updates.
Andy Wingo [Fri, 1 Apr 2011 09:05:37 +0000 (11:05 +0200)]
latin1 subr and message in internal scm_{encoding,decoding}_error
* libguile/strings.c (scm_encoding_error, scm_decoding_error): Use
scm_from_latin1_string for the subr and message args, as these are
internal functions, and we know their callers.
Andy Wingo [Thu, 31 Mar 2011 21:33:00 +0000 (23:33 +0200)]
fix duplicate path in uninstalled-env
* meta/uninstalled-env.in: Our code that checked for paths already being
in the load path was not working for the last entry in the load path.
This caused the last entry to be re-added to the beginning, which also
caused relative filename canonicalization to prepend "module/" to
everything.
Terrible.
Kevin Fletcher [Thu, 31 Mar 2011 20:16:54 +0000 (22:16 +0200)]
fix gc_register_my_thread et al fallback impls
* libguile/threads.c (GC_register_my_thread, GC_get_stack_base): Fix
fallback impls.
Andy Wingo [Thu, 31 Mar 2011 14:36:01 +0000 (16:36 +0200)]
web.texi: handler return types documentation
* doc/ref/web.texi (Web Server): More docs on handler return types.
Andy Wingo [Thu, 31 Mar 2011 14:17:35 +0000 (16:17 +0200)]
web.texi: fix uri->string invocation
* doc/ref/web.texi (Web Examples): Fix uri->string invocation. Thanks
to Romel Sandoval for the report.
Andy Wingo [Thu, 31 Mar 2011 12:46:21 +0000 (14:46 +0200)]
fix problems detecting coding: in block comments
* libguile/read.c (scm_i_scan_for_encoding): Fix for coding on first
line #! and for !# immediately following the coding.
* test-suite/Makefile.am:
* test-suite/tests/coding.test: Add tests.
Andy Wingo [Thu, 31 Mar 2011 11:29:41 +0000 (13:29 +0200)]
inline fxops in psyntax
* module/ice-9/psyntax.scm (fx+, fx-, fx=, fx<): Given our lame lack of
an inliner, inline these manually with identifier syntax.
* module/ice-9/psyntax-pp.scm: Regenerate.
Andy Wingo [Thu, 31 Mar 2011 11:23:27 +0000 (13:23 +0200)]
allow definitions in with-syntax body
* module/ice-9/psyntax.scm (with-syntax): Allow definitions in the body,
as seems to be suggested by the R6RS.
* test-suite/tests/syncase.test ("with-syntax"): Add test.
* module/ice-9/psyntax-pp.scm: Regenerate.
Michael Gran [Thu, 31 Mar 2011 03:42:37 +0000 (20:42 -0700)]
More descriptive error for dynamic-pointer
* libguile/dynl.c (sysdep_dynl_value): Failure to find a symbol is not
an error, so raise our own, more appropriate error.
* test-suite/tests/foreign.test ("dynamic-pointer"): Add a test.
Andy Wingo [Thu, 24 Mar 2011 19:20:14 +0000 (20:20 +0100)]
with-continuation-barrier calls exit(3) _after_ unwinding
* libguile/continuations.c (scm_handler, c_handler)
(scm_c_with_continuation_barrier, scm_with_continuation_barrier):
Instead of calling scm_handle_by_message_noexit in the pre-unwind
handler, roll our own exception printing in the pre-unwind, and do to
exit()-on-quit in the post-unwind handler. This lets the stack unwind
at exit-time so that pending dynwinds run.
* test-suite/tests/continuations.test ("continuations"): Add a test.
Michael Gran [Wed, 30 Mar 2011 04:27:54 +0000 (21:27 -0700)]
don't GC unregister null thread
GC_unregister_my_thread is only supposed to be called from
a thread other than the main thread, so, it should never be
called when the system is compiled with null threads.
* libguile/threads.c (on_thread_exit)[SCM_USE_NULL_THREADS]: don't
call GC_unregister_my_thread
Michael Gran [Wed, 30 Mar 2011 04:25:04 +0000 (21:25 -0700)]
check for GC_allow_register_threads
This is not present in earlier versions of BDW-GC
* configure.ac: check for GC_allow_register_threads
* libguile/threads.c (scm_i_init_thread_for_guile): Only call
GC_allow_register_threads if it is present.
Ludovic Courtès [Tue, 29 Mar 2011 21:35:24 +0000 (23:35 +0200)]
Fix `procedure->pointer' for functions returning `void'.
* libguile/foreign.c (unpack): Handle `FFI_TYPE_VOID'.
* test-suite/tests/foreign.test ("procedure->pointer")["procedures
returning void"]: New test. Reported by
Tristan Colgate <tcolgate@gmail.com>.
Andy Wingo [Tue, 29 Mar 2011 15:41:31 +0000 (17:41 +0200)]
fix prompt and abort with the boot evaluator
* libguile/control.h:
* libguile/control.c (scm_i_prompt_pop_abort_args_x): Take a VM instead
of a prompt, given that it's the VM's registers that record the abort
arguments, not the prompt registers (which actually point right below
the abort values).
* libguile/eval.c (eval):
* libguile/throw.c (pre_init_catch): Pass the vm instead of a prompt.
Andy Wingo [Tue, 29 Mar 2011 11:21:44 +0000 (13:21 +0200)]
fix compilation with libgc 7.0, 7.1
* configure.ac: Check for GC_pthread_exit and GC_pthread_cancel.
* libguile/gen-scmconfig.c: Write HAVE_GC_PTHREAD_CANCEL and
HAVE_GC_PTHREAD_EXIT into scmconfig.h.
* libguile/pthread-threads.h (scm_i_pthread_exit, scm_i_pthread_cancel):
Only redefine to their GC_pthread_* variants if we have those
functions, which is not the case in libgc < 7.2.
Andy Wingo [Tue, 29 Mar 2011 10:38:18 +0000 (12:38 +0200)]
fix error message on ,disassemble "non-procedure"
* module/language/objcode/spec.scm (decompile-value): Don't assume that
`error' will handle format strings appropriately.
* module/system/repl/command.scm (disassemble): A more human error when
you disassemble a non-procedure.
Bug reported by Andrew Horton.
Andy Wingo [Tue, 29 Mar 2011 10:18:20 +0000 (12:18 +0200)]
document -q, repl options
* doc/ref/scheme-scripts.texi (Invoking Guile): Document -q.
* doc/ref/scheme-using.texi (Init File): New section, on .guile.
(Readline): Link to Init File.
(System Commands): Document the various REPL options, and
repl-default-option-set!.
Andy Wingo [Tue, 29 Mar 2011 09:40:05 +0000 (11:40 +0200)]
rewrite ensure-writable-dir to not be racy
* module/system/base/compile.scm (ensure-writable-dir): Rewrite to not
be racy.
Andy Wingo [Sun, 27 Mar 2011 13:00:18 +0000 (15:00 +0200)]
fix prompt in fix in single-value context compilation
* module/language/tree-il/compile-glil.scm (flatten): When compiling a
<prompt> in push context with an RA, after the body returns normally,
jump to that RA instead of to our POST label (which in that case does
not need to be emitted). Fixes a tail <prompt> in a push <fix>.
* test-suite/tests/control.test ("prompt in different contexts"): Add
more test cases.
Andy Wingo [Sun, 27 Mar 2011 12:44:20 +0000 (14:44 +0200)]
tree-il->scheme fix
* module/language/tree-il.scm (tree-il->scheme): Fix <prompt> to Scheme
serialization.
Noah Lavine [Fri, 11 Mar 2011 16:45:33 +0000 (11:45 -0500)]
Document SRFI-23
* doc/ref/srfi-modules.texi: mention that we support SRFI 23
* module/ice-9/boot-9.scm (%cond-expand-features): add srfi-23
Bruno Haible [Sat, 26 Mar 2011 22:33:00 +0000 (23:33 +0100)]
Update comment about uc_locale_language.
* libguile/i18n.c (locale_language): Update comment.
Andy Wingo [Sat, 26 Mar 2011 12:33:21 +0000 (13:33 +0100)]
fix stexi->html double translation
* module/texinfo/html.scm (entry): Fix to avoid double translation:
arg-req already pulls an stexi->shtml on its arg.
Andy Wingo [Sat, 26 Mar 2011 11:53:10 +0000 (12:53 +0100)]
fix (texinfo reflection) to handle nested structures like syntax patterns
* module/texinfo/reflection.scm (process-args): Convert any arg to a
string. "Fixes" documentation of syntax-rules patterns.
Neil Jerram [Mon, 21 Mar 2011 09:05:59 +0000 (09:05 +0000)]
Remove statements about scripts/* that are no longer true
* doc/ref/tools.texi (Executable Modules): Say "guile-tools modules"
instead of "executable modules". Remove obsolete statements about
not ending in .scm, being executable, and beginning with shell
script invocation sequence.
* module/scripts/README: Ditto.
Neil Jerram [Sun, 20 Mar 2011 23:50:22 +0000 (23:50 +0000)]
Inline the effect of am/pre-inst-guile
It's just one variable definition, and in my opinion it confuses,
rather than helps, the overall build picture to have two names
(preinstguile and meta/guile) for the same thing.
* am/Makefile.am (am_frags): Remove pre-inst-guile.
* am/pre-inst-guile: Deleted.
* doc/ref/Makefile.am: Don't include am/pre-inst-guile.
($(snarf_doc).am, $(snarf_doc).texi): Expand $(preinstguile).
* module/Makefile.am (ice-9/psyntax-pp.scm.gen): Don't include
am/pre-inst-guile.
(ice-9/psyntax-pp.scm.gen): Expand $(preinstguile).
Neil Jerram [Sun, 20 Mar 2011 23:02:33 +0000 (23:02 +0000)]
Make explicit that GUILE_FOR_BUILD is only used when cross-compiling
* configure.ac (GUILE_FOR_BUILD): Change normal build value to
'this-value-will-never-be-used'.
Neil Jerram [Sun, 20 Mar 2011 22:48:33 +0000 (22:48 +0000)]
GUILE_FOR_BUILD is only needed by meta/guile.in, not by Makefiles
* configure.ac: Use AM_SUBST_NOTMAKE for GUILE_FOR_BUILD instead of
AC_SUBST.
Neil Jerram [Sun, 20 Mar 2011 22:27:38 +0000 (22:27 +0000)]
Remove unused definition of preinstguiletool
* am/pre-inst-guile (preinstguiletool): Removed.
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.
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.
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.
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.
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.
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.
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'.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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>
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>
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>
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!'.
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.
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.
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.
Ludovic Courtès [Thu, 10 Mar 2011 21:24:40 +0000 (22:24 +0100)]
Thanks, Aidan.
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.
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.
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.
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>
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'.
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.
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 ...))'.
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.
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.
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.
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?'.
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.
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.
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.
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}.
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.
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.
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).
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.