Ludovic Courtès [Sun, 26 Feb 2012 23:51:09 +0000 (00:51 +0100)]
Avoid failure when `format-analysis' stumbles upon unbound variables.
* module/language/tree-il/analyze.scm (proc-ref?): Wrap `variable-ref'
in `false-if-exception'.
* test-suite/tests/tree-il.test ("warnings")["format"]("non-literal
format string with forward declaration"): New test.
Andy Wingo [Fri, 24 Feb 2012 22:05:02 +0000 (23:05 +0100)]
port i/o optimizations for iso-8859-1
* libguile/ports.h (scm_t_port_encoding_mode):
* libguile/ports.c (scm_c_make_port_with_encoding):
(scm_i_set_port_encoding_x): Add special treatment for latin1
encoding.
(get_latin1_codepoint, get_codepoint): Add latin1 fast-path.
* libguile/print.c (display_string_as_latin1): Add latin1 fastpath.
Andy Wingo [Fri, 24 Feb 2012 22:03:31 +0000 (23:03 +0100)]
fixes to threaded finalizers
* libguile/finalizers.c (finalization_thread_proc):
(run_finalization_thread):
(start_finalization_thread):
(stop_finalization_thread): Use pthreads + scm_with_guile instead of
scm_spawn_thread, to avoid deadlocks.
Andy Wingo [Fri, 24 Feb 2012 19:01:47 +0000 (20:01 +0100)]
srfi-18 test fix
* test-suite/tests/srfi-18.test: Enclose the tests in a begin instead of
an and. Before, they were not being run, for some reason I don't
fully understand.
Andy Wingo [Fri, 24 Feb 2012 18:58:45 +0000 (19:58 +0100)]
slight cleanup to run-test
* test-suite/lib.scm (run-test): Slight cleanup.
Andy Wingo [Fri, 24 Feb 2012 18:42:00 +0000 (19:42 +0100)]
srfi-18 cleanup
* module/srfi/srfi-18.scm (with-exception-handler):
(thread-join!, mutex-lock!, mutex-unlock!): Avoid useless invocations
of `apply'.
Andy Wingo [Fri, 24 Feb 2012 17:57:37 +0000 (18:57 +0100)]
statically initialize the pthread mutex in fat mutexen
* libguile/threads.c (make_fat_mutex): Remove smob free function.
Because we use normal mutexen, we can just blit the mutex to
initialize it.
Andy Wingo [Fri, 24 Feb 2012 12:18:48 +0000 (13:18 +0100)]
run finalizers asynchronously (in asyncs and/or pthreads)
* libguile/finalizers.c: New excitement! We'll be running finalizers in
threads, if that's available. If it's not available, during early
boot, we can run finalizers in asyncs. This will make it safer to
allocate while holding a mutex.
* libguile/posix.c (scm_fork): Shut down the finalizer thread before
forking.
* libguile/init.c (scm_i_init_guile): Init the async finalizer mechanism
during boot and, if available, initialialize the finalizer thread at
the very end.
* libguile/gc.c (scm_storage_prehistory): Tell libgc we'll be finalizing
on demand.
(scm_gc): Explicitly run finalizers here. If you're calling this
function, you probably want synchronous GC.
Andy Wingo [Fri, 24 Feb 2012 10:20:21 +0000 (11:20 +0100)]
signal an error on multithreaded fork
* libguile/posix.c (scm_fork): Signal an error if a `fork' is attempted
after threads have been spawned.
* test-suite/tests/00-socket.test: Moved here, from socket.test, so as
to run before any threads are created.
* test-suite/Makefile.am: Adapt.
Andy Wingo [Thu, 23 Feb 2012 13:20:48 +0000 (14:20 +0100)]
remove atfork on revealed mutex in fports.c
* libguile/fports.c: Remove atfork call.
Andy Wingo [Thu, 23 Feb 2012 13:18:57 +0000 (14:18 +0100)]
Revert "add pthread_atfork helpers to our threading shims"
This reverts commit
2f745b64a1eb06e9e175a1b497d5270bebff9097.
Andy Wingo [Thu, 23 Feb 2012 13:18:56 +0000 (14:18 +0100)]
Revert "with a threaded guile, lock weak sets and tables during a fork"
This reverts commit
f609480611cfd1585409fd6b1b90beb730b026cf.
Andy Wingo [Thu, 23 Feb 2012 13:18:56 +0000 (14:18 +0100)]
Revert "install pthread_atfork handlers for guile's static mutexen"
This reverts commit
6a97b1f93aace5c7c976aef51d36b3ae9cfd5630.
Andy Wingo [Thu, 23 Feb 2012 13:18:52 +0000 (14:18 +0100)]
Revert "wrap iconv_open / iconv_close with a lock to help in thread/fork issues"
This reverts commit
8dfb7bbfd908ca883d0fdd0d868e13e6b20803ae.
Andy Wingo [Thu, 23 Feb 2012 13:10:22 +0000 (14:10 +0100)]
Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts:
module/language/tree-il/analyze.scm
Andy Wingo [Thu, 23 Feb 2012 12:56:06 +0000 (13:56 +0100)]
rewrite open-process in C, for robustness
* libguile/posix.c (scm_open_process): Rewrite in C, so as to avoid
allocations and other calls that are not async-signal-safe.
(scm_init_popen, scm_init_posix): Register popen extension.
* module/ice-9/popen.scm: Load the popen extension, to get open-process.
Andy Wingo [Wed, 22 Feb 2012 19:40:55 +0000 (20:40 +0100)]
microoptimizations in (web uri)
* module/web/uri.scm (valid-host?): Micro-optimizations.
Andy Wingo [Wed, 22 Feb 2012 19:08:44 +0000 (20:08 +0100)]
add test for recent quick fix
* test-suite/tests/web-uri.test ("string->uri"): Add test for
string->uri with hosts beginning in digits.
Andy Wingo [Tue, 21 Feb 2012 16:50:55 +0000 (16:50 +0000)]
quick fix the quick fix
Andy Wingo [Tue, 21 Feb 2012 16:42:53 +0000 (16:42 +0000)]
quick fix to uri parser
* module/web/uri.scm: Quick fix to not throw an error on e.g.
http://2012.jsconf.us.
Noah Lavine [Sat, 18 Feb 2012 15:55:49 +0000 (10:55 -0500)]
Optimize Equality Primitives
* module/language/tree-il/primitives.scm: add equality-primitive?,
which is true for eq?, eqv?, and equal?
* module/language/tree-il/peval.scm: if an equality primitive is
applied to the same variable twice, fold it to #t
* test-suite/tests/tree-il.test: add tests for pevaling equality
primitives
Ludovic Courtès [Sun, 19 Feb 2012 22:54:18 +0000 (23:54 +0100)]
Have `-Wformat' recognize `ngettext' calls.
* module/language/tree-il/analyze.scm (gettext?): Rename to...
(proc-ref?): ... this. Add `proc' and `special-name' parameters.
(gettext?): Define in terms of `proc-ref?'.
(ngettext?): New procedure.
(const-fmt): Recognize `ngettext' calls.
(format-analysis)[<down>](check-format-args]: Check
constant-but-non-string 2nd argument in the (not (const-fmt ...))
case.
[check-simple-format-args]: Use `const-fmt'.
* test-suite/tests/tree-il.test ("warnings")["format"]("non-literal
format string using ngettext", "non-literal format string using
ngettext as N_"): New tests.
("simple-format")["unsupported, ngettext"]: New test.
Ludovic Courtès [Sun, 19 Feb 2012 22:08:49 +0000 (23:08 +0100)]
Have `-Wformat' better recognize the `gettext' procedure.
Fixes <http://bugs.gnu.org/10846>.
Reported by Bruno Haible <bruno@clisp.org>.
* module/language/tree-il/analyze.scm (gettext?): New procedure.
(const-fmt): Add `env' parameter; update callers. Use `gettext?'.
(format-analysis)[check-simple-format-args]: Actually support
gettextized format strings.
* test-suite/tests/tree-il.test ("warnings")["format"]("non-literal
format string using gettext"): Use `gettext' as the procedure name.
("non-literal format string using gettext as _"): New test.
["simple-format"]("unsupported, gettext"): New test.
Andy Wingo [Sun, 19 Feb 2012 11:23:29 +0000 (12:23 +0100)]
use the new finalizer helpers
* libguile/foreign.c (scm_set_pointer_finalizer_x)
* libguile/ports.c (finalize_port, scm_c_make_port_with_encoding)
(open_iconv_descriptors)
* libguile/smob.c (scm_i_new_smob, scm_i_new_double_smob)
* libguile/struct.c (scm_i_alloc_struct)
* libguile/weak-set.c (weak_gc_finalizer)
(scm_c_register_weak_gc_callback)
* libguile/weak-table.c (scm_c_register_weak_gc_callback)
(weak_gc_finalizer)
* libguile/numbers.c (make_bignum): Use the new API.
Andy Wingo [Sun, 19 Feb 2012 11:22:12 +0000 (12:22 +0100)]
add scm_i_set_finalizer, scm_i_add_finalizer, scm_i_add_resuscitator
* libguile/finalizers.h:
* libguile/finalizers.c: New files.
* libguile.h:
* libguile/Makefile.am: Add to build.
Andy Wingo [Sun, 19 Feb 2012 19:34:26 +0000 (20:34 +0100)]
better hysteresis in weak-set, weak-table
* libguile/weak-set.c:
* libguile/weak-table.c: Attempt to avoid bouncing between sizes when
growing the vector causes elements to be removed from the set/table.
Andy Wingo [Sun, 19 Feb 2012 14:19:14 +0000 (15:19 +0100)]
tune default hash table sizes
* libguile/modules.c: In my current image, there are 1790 bindings in
the root module, which tips over to the next hash vector size, so
declare that to prevent rehashing.
* libguile/srcprop.c (scm_init_srcprop): Don't preallocate a big
source_whash table, as we might not need it (if everything is
compiled, for example).
* module/ice-9/boot-9.scm (make-module): Don't preall-cate big hash
tables for imported bindings. Instead trust that resizing works
correctly.
Andy Wingo [Sun, 19 Feb 2012 11:34:20 +0000 (12:34 +0100)]
move revealed-count mechanism to fports.c
* libguile/fports.c (scm_revealed_count, scm_port_revealed)
(scm_set_port_revealed_x, scm_adjust_port_revealed_x): Move these APIs
here, and only operate on fports. To keep revealed ports alive, now
we will just keep them in a data structure that the GC knows about --
a static list.
* libguile/fports.h: Add revealed count to scm_t_fport, and move decls
of revealed-count functions here.
* libguile/ports.h:
* libguile/ports.c: Adapt to change. Remove SCM_REVEALED and
SCM_SETREVEALED; since they only apply to fports now, keeping them
around would be inviting type errors.
(finalize_port): We don't need to worry about resuscitating ports
here.
* libguile/init.c: Use the scm_set_port_revealed_x function to set the
revealed counts on stream ports.
Andy Wingo [Sun, 19 Feb 2012 12:29:59 +0000 (13:29 +0100)]
ice-9/poll optimization
* module/ice-9/poll.scm (poll-set-add!): Use fileno instead of
port->fdes, to avoid manipulating revealed counts.
Ludovic Courtès [Fri, 17 Feb 2012 23:04:17 +0000 (00:04 +0100)]
Don't fail when locale env. vars specify a dot-less locale name.
Fixes <http://bugs.gnu.org/10742>.
Reported by Alírio Eyng <alirioeyng@ig.com.br>.
* gnulib-local/lib/localcharset.c.diff (environ_locale_charset): Change
to set CODESET to "" when LOCALE lacks a dot. Return "ISO-8859-1"
when CODESET is the empty string.
* lib/localcharset.c: Update.
* test-suite/standalone/Makefile.am (check_SCRIPTS): Add
`test-command-line-encoding2'.
(TESTS): Likewise.
* test-suite/standalone/test-command-line-encoding2: New file.
Andy Wingo [Tue, 14 Feb 2012 13:30:48 +0000 (14:30 +0100)]
wrap iconv_open / iconv_close with a lock to help in thread/fork issues
* libguile/bytevectors.c (STRING_TO_UTF, scm_string_to_utf8)
(UTF_TO_STRING):
* libguile/ports.c (open_iconv_descriptors, close_iconv_descriptors):
* libguile/strings.c (scm_from_stringn, scm_to_stringn): Wrap operations
that acquire and destroy iconv contexts with a mutex. While iconv is
threadsafe, internally it uses a lock, and we need to make sure when
we fork() that no one has that lock -- so we surround it with another
one. Gross.
Andy Wingo [Wed, 8 Feb 2012 18:57:41 +0000 (19:57 +0100)]
install pthread_atfork handlers for guile's static mutexen
* libguile/async.c:
* libguile/deprecation.c:
* libguile/fluids.c:
* libguile/gc.c:
* libguile/instructions.c:
* libguile/ports.c:
* libguile/posix.c:
* libguile/strings.c:
* libguile/threads.c: Use the SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX
mechanism to lock a number of static mutexen.
Andy Wingo [Fri, 17 Feb 2012 10:35:02 +0000 (11:35 +0100)]
add pthread_atfork helpers to our threading shims
* libguile/null-threads.h:
* libguile/pthread-threads.h (SCM_DEFINE_ATFORK_HANDLERS_FOR_MUTEX)
(scm_i_pthread_atfork): Define a pthread_atfork shim, and a helper to
declare procedures to lock and unlock a mutex.
* libguile/threads.h (SCM_PTHREAD_ATFORK_LOCK_STATIC_MUTEX): New macro,
causes the snarfer to emit a pthread_atfork call to lock a mutex, if
threads are enabled.
Andy Wingo [Fri, 17 Feb 2012 10:47:52 +0000 (11:47 +0100)]
with a threaded guile, lock weak sets and tables during a fork
* libguile/weak-set.c (make_weak_set):
* libguile/weak-table.c (make_weak_table): If we have a threaded Guile,
* keep a weak set (table) of weak sets (tables). Use this and the
pthread_atfork mechanism to lock and unlock weak sets and weak tables
during a fork().
* libguile/weak-set.h (scm_weak_set_prehistory): New internal API.
* libguile/init.c: Add call to scm_weak_set_prehistory().
Andy Wingo [Fri, 17 Feb 2012 09:21:50 +0000 (10:21 +0100)]
Merge remote-tracking branch 'local-2.0/stable-2.0'
Conflicts:
libguile/read.c
libguile/srcprop.c
module/ice-9/psyntax-pp.scm
Andy Wingo [Wed, 15 Feb 2012 22:40:42 +0000 (23:40 +0100)]
remove deprecated features test
* test-suite/tests/procprop.test ("procedure-arity"): Remove a test of
deprecated features.
Andy Wingo [Wed, 15 Feb 2012 22:04:53 +0000 (23:04 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
module/ice-9/psyntax-pp.scm
Mark H Weaver [Wed, 15 Feb 2012 17:23:12 +0000 (12:23 -0500)]
Add tests to verify that 'read' sets source properties when appropriate
* test-suite/tests/srcprop.test (source properties): Add tests.
Mark H Weaver [Wed, 15 Feb 2012 16:47:31 +0000 (11:47 -0500)]
Add support for source properties on non-immediate numbers
* libguile/read.c (scm_read_number): Set source properties on
non-immediate numbers if the 'positions' reader option is set.
* doc/ref/api-debug.texi (Source Properties): Update manual.
Mark H Weaver [Wed, 15 Feb 2012 04:22:51 +0000 (23:22 -0500)]
psyntax: access source properties for all supported objects
* module/ice-9/psyntax.scm (decorate-source): Set source properties on
any object that satisfies 'supports-source-properties?'. Previously
we used 'pair?' as the predicate.
(source-annotation): Apply 'source-properties' to _any_ kind of source
expression, where previously only pairs were queried. If the argument
is a syntax-object, apply the source-properties to the syntax-object's
expression.
In the peculiar case of a syntax-object whose expression is also a
syntax-object: previously we would iterate, but with this commit we
now call 'syntax-object-expression' only once.
* module/ice-9/psyntax-pp.scm: Regenerate.
Mark H Weaver [Tue, 14 Feb 2012 07:14:10 +0000 (02:14 -0500)]
Add 'supports-source-properties?' predicate
* libguile/srcprop.c (scm_supports_source_properties_p): New procedure.
(supports_source_props): New static C function.
* libguile/srcprop.h (scm_supports_source_properties_p): Add prototype.
* doc/ref/api-debug.texi (Source Properties): Add documentation.
Andy Wingo [Wed, 15 Feb 2012 10:43:32 +0000 (11:43 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Mark H Weaver [Tue, 14 Feb 2012 06:54:15 +0000 (01:54 -0500)]
Relax validation of source property accessors
* libguile/srcprop.c (scm_source_properties, scm_source_property,
scm_i_has_source_properties): Relax validation to allow _any_ object
to be queried for source properties.
Mark H Weaver [Wed, 15 Feb 2012 05:41:24 +0000 (00:41 -0500)]
syntax-violation: prefer 'subform' for source info, with 'form' as fallback
* module/ice-9/psyntax.scm (syntax-violation): Look for source
properties of 'subform' first. If 'subform' has none, 'form' is used.
Previously, the source information of 'form' was used unless 'form'
_itself_ was '#f', in which case 'subform' was used.
* module/ice-9/psyntax-pp.scm: Regenerate.
Mark H Weaver [Wed, 15 Feb 2012 05:17:18 +0000 (00:17 -0500)]
Fix psyntax bugs that would cause bad source annotations
* module/ice-9/psyntax.scm (rebuild-macro-output): Fix two bugs that
would cause bogus source properties to be added to vectors and
macro-introduced syntax objects. These bugs were masked by the
limitation that only pairs can be decorated with source properties.
Due to a typo, each vector in the macro output was decorated using the
vector itself as its source. Due to accidental variable capture, each
syntax-object introduced by the macro had its expression decorated
with its own wrap-subst.
* module/ice-9/psyntax-pp.scm: Regenerate.
Mark H Weaver [Mon, 13 Feb 2012 05:06:43 +0000 (00:06 -0500)]
Fix typo in comment in message.scm: 'know' to 'known' warning types
* module/system/base/message.scm (%warning-types): Fix typo.
Andy Wingo [Tue, 14 Feb 2012 13:33:19 +0000 (14:33 +0100)]
better handling for exceptions in close-port and port finalizers
* libguile/fports.c (close_the_fd, fport_close): Arrange to always close
the fd, even if the flush procedure throws an exception. Perhaps the
port machinery should do this for us, though. Don't wrap the close
call in SCM_SYSCALL, EINTR leaves the fd in an unspecified state.
Don't bother freeing buffers, the collector will handle that; simply
drop references via scm_port_non_buffer.
* libguile/ports.c (do_free, finalize_port): Catch exceptions caused by
the free procedure. Don't bother setting the stream to 0 at all.
(scm_close_port): Ensure that exceptions thrown by the "close"
procedure don't prevent the port from being marked as closed.
Andy Wingo [Tue, 14 Feb 2012 16:32:16 +0000 (17:32 +0100)]
web server: fix spurious warning
* module/web/server.scm (sanitize-response): Quick fix to the
304-has-no-body sanitizer.
Andy Wingo [Tue, 14 Feb 2012 08:35:22 +0000 (09:35 +0100)]
scm_from_stringn utf8 optimization
* libguile/strings.c (scm_from_stringn): Optimize scm_from_stringn for
utf-8.
Andy Wingo [Tue, 14 Feb 2012 13:24:04 +0000 (14:24 +0100)]
fix buggy scm_from_utf8_stringn (!)
* libguile/strings.c (scm_from_utf8_stringn): Embarassingly, my
scm_from_utf8_stringn implementation was buggy for non-ascii
characters, since October (
41d1d984). Fixed. Will be tested with the
next patch.
Andy Wingo [Tue, 14 Feb 2012 13:01:52 +0000 (14:01 +0100)]
ports: avoid adding port table entries and finalizers if possible
* libguile/ports.h (scm_t_port_type_flags, scm_t_ptob_descriptor): Add
flags to ptob descriptors.
* libguile/ports.c (scm_set_port_flush): Set the SCM_PORT_TYPE_HAS_FLUSH
flag here.
(scm_c_make_port_with_encoding): Only add ports to the table if
SCM_PORT_TYPE_HAS_FLUSH is set. Only add finalizers to ports if there
is a free function.
(scm_close_port): Inline scm_i_remove_port here. Only remove from the
weak set if SCM_PORT_TYPE_HAS_FLUSH is set.
(scm_set_port_revealed_x): Add a comment.
Andy Wingo [Tue, 14 Feb 2012 12:09:34 +0000 (13:09 +0100)]
refactor port encoding modes: utf-8 and iconv
* libguile/ports.h (struct scm_t_port): Add a flag for the port encoding
mode: UTF8 or iconv. The iconv descriptors are now in a separate
structure so that we can avoid attaching finalizers to the ports
themselves, in some cases.
* libguile/ports.c (scm_c_make_port_with_encoding): Init the encoding
mode.
(scm_i_remove_port): Adapt to call close_iconv_descriptors.
(finalize_iconv_descriptors, open_iconv_descriptors):
(close_iconv_descriptors): New infrastructure to manage iconv
descriptors.
(scm_i_port_iconv_descriptors): New internal helper.
(scm_i_set_port_encoding_x): Use open_iconv_descriptors, if needed.
(get_iconv_codepoint): Use pt->iconv_descriptors.
(get_codepoint): Check the port encoding mode flags.
* libguile/print.c (display_string_using_iconv): Use
scm_i_port_iconv_descriptors.
(display_string): Use pt->encoding_mode flag.
Andy Wingo [Mon, 13 Feb 2012 23:11:39 +0000 (00:11 +0100)]
string ports simplification
* libguile/strports.c (st_fill_input): Rename from stfill_buffer, and
remove an unneeded scm_return_first_int.
(st_resize_port): Minor variable renaming.
(st_write): Keep read_pos updated to be the same as write_pos. If we
need to resize, do so only once.
(st_seek): No more need to flush.
(st_truncate): Update read_pos here too.
(scm_mkstrport): No need to flush here.
(scm_strport_to_string): Just call scm_from_stringn; rely on it to
detect the latin1 case.
(scm_make_stptob): No more flush function.
Andy Wingo [Mon, 13 Feb 2012 14:29:21 +0000 (15:29 +0100)]
weaks: move an allocation outside a critical section
* libguile/weak-set.c (resize_set):
* libguile/weak-table.c (resize_table): Drop the set/table lock while
allocating the new vector. Fixes a bug in which a finalizer could
recursively try to grab the port table lock.
Mark H Weaver [Sun, 12 Feb 2012 22:05:28 +0000 (17:05 -0500)]
Fix manual: scm_foreign_to_bytevector to scm_pointer_to_bytevector
* doc/ref/api-foreign.texi (Void Pointers and Byte Access): Fix outdated
function name: scm_foreign_to_bytevector to scm_pointer_to_bytevector.
Andy Wingo [Sun, 12 Feb 2012 12:32:56 +0000 (13:32 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Sun, 12 Feb 2012 12:17:11 +0000 (13:17 +0100)]
web server: do not provide a response body where it is not permitted
* module/web/response.scm (response-must-not-include-body?): New
function.
* doc/ref/web.texi: Doc the function.
* module/web/server.scm (sanitize-response): Error if we have a body,
but the response type does not permit a body. If we are responding to
a HEAD request, silently drop the body.
Andy Wingo [Sat, 11 Feb 2012 17:28:37 +0000 (18:28 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Sat, 11 Feb 2012 17:27:56 +0000 (18:27 +0100)]
web server: print backtrace on errors when run in batch mode
* module/web/server.scm (read-client, handle-request, write-client):
When run in batch mode, give a full backtrace for errors.
Andy Wingo [Sat, 11 Feb 2012 17:14:48 +0000 (18:14 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
libguile/read.c
test-suite/tests/tree-il.test
Andy Wingo [Thu, 9 Feb 2012 22:15:25 +0000 (23:15 +0100)]
more efficient scm_string_to_utf8, scm_string_to_utf32
* libguile/bytevectors.c (scm_string_to_utf8): More efficient
implementation.
(scm_string_to_utf32): Likewise.
Andy Wingo [Thu, 9 Feb 2012 22:14:11 +0000 (23:14 +0100)]
more efficient scm_to_utf8_stringn, scm_to_utf32_stringn
* libguile/strings.c (scm_to_utf8_stringn): More efficient
implementation than calling scm_to_stringn.
(scm_to_utf32_stringn): Likewise.
Mark H Weaver [Wed, 8 Feb 2012 00:40:29 +0000 (19:40 -0500)]
Support => within case, and improve error messages for cond and case
* module/ice-9/boot-9.scm (cond, case): Reimplement using syntax-case,
with improved error messages and support for '=>' within 'case' as
mandated by the R7RS. Add warnings for duplicate case datums and
case datums that cannot be meaningfully compared using 'eqv?'.
* module/system/base/message.scm (%warning-types): Add 'bad-case-datum'
and 'duplicate-case-datum' warning types.
* test-suite/tests/syntax.test (cond, case): Update tests to reflect
improved error reporting. Add tests for '=>' within 'case'.
* test-suite/tests/tree-il.test (partial evaluation): Update tests to
reflect changes in how 'case' is expanded.
* doc/ref/api-control.texi (Conditionals): Document '=>' within 'case'.
Mark H Weaver [Wed, 8 Feb 2012 20:51:38 +0000 (15:51 -0500)]
Add source properties to many more types of data
* libguile/read.c (scm_read_array): New internal helper that
calls scm_i_read_array and sets its source property if the
'positions' reader option is set.
(scm_read_string): Set source properties on strings if the 'positions'
reader option is set.
(scm_read_vector, scm_read_srfi4_vector, scm_read_bytevector,
scm_read_guile_bitvector, scm_read_sharp): Add new arguments for the
'line' and 'column' of the first character of the datum being read.
Set source properties if the 'positions' reader option is set.
(scm_read_expression): Pass 'line' and 'column' to scm_read_sharp.
* doc/ref/api-debug.texi (Source Properties): Update manual.
Mark H Weaver [Wed, 8 Feb 2012 20:32:55 +0000 (15:32 -0500)]
Unoptimize 'read' to return freshly allocated empty strings
* libguile/read.c (scm_read_string): Return a freshly allocated string
every time, even for empty strings. The motivation is to allow source
properties to be added to all strings. Previously, the shared global
'scm_nullstr' was returned for empty strings. Note that empty strings
still share a common global 'null_stringbuf'.
* test-suite/tests/srfi-13.test (substring/shared): Fix tests to reflect
the fact that empty string literals are no longer guaranteed to be
'eq?' to each other.
Mark H Weaver [Wed, 8 Feb 2012 20:29:10 +0000 (15:29 -0500)]
Optimize empty substring case of scm_i_substring_copy
* libguile/strings.c (scm_i_substring_copy): When asked to create an
empty substring, use 'scm_i_make_string' to make use of its
optimization for empty strings that reuses the global null_stringbuf.
Mark H Weaver [Wed, 8 Feb 2012 08:10:11 +0000 (03:10 -0500)]
Add and use maybe_annotate_source helper in read.c
* libguile/read.c (maybe_annotate_source): New static helper function.
(scm_read_sexp, scm_read_quote, scm_read_syntax): Use
'maybe_annotate_source'.
Mark H Weaver [Wed, 8 Feb 2012 08:00:15 +0000 (03:00 -0500)]
Remove inline and register attributes from read.c
* libguile/read.c: Remove all 'inline' and 'register' attributes.
Mark H Weaver [Wed, 8 Feb 2012 08:14:17 +0000 (03:14 -0500)]
Remove incorrect comment in read.c
* libguile/read.c (scm_read_sharp): Remove incorrect comment that
claims that scm_read_boolean might return a SRFI-4 vector.
Andy Wingo [Wed, 8 Feb 2012 11:25:10 +0000 (12:25 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Andy Wingo [Wed, 8 Feb 2012 11:20:09 +0000 (12:20 +0100)]
i18: avoid freelocale (NULL)
* libguile/i18n.c (smob_locale_free): Don't freelocale (NULL).
Andy Wingo [Wed, 8 Feb 2012 10:48:08 +0000 (11:48 +0100)]
Merge remote-tracking branch 'origin/stable-2.0'
Conflicts:
GUILE-VERSION
libguile/gc-malloc.c
libguile/ports.c
Andy Wingo [Sun, 5 Feb 2012 14:55:09 +0000 (15:55 +0100)]
Fix --enable-debug-malloc
* libguile/gc-malloc.c (do_realloc, do_calloc, do_gc_malloc)
(do_gc_malloc_atomic, do_gc_realloc, do_gc_free): Wrap the allocators
in helper methods. The non-GC allocators call
scm_gc_register_allocation, and the GC allocators ensure that
gc_malloc returns a nonzero value.
(scm_realloc, scm_calloc): Allow NULL return for malloc(0). It is
permitted by POSIX. Don't wrap in a SCM_SYSCALL; the only possible
errno is ENOMEM.
(scm_gc_malloc_pointerless, scm_gc_malloc, scm_gc_calloc):
(scm_gc_realloc, scm_gc_free, scm_gc_strndump): Use the wrappers.
Don't call the debug-malloc registrations and deregistrations, as it
is neither mandatory nor advised to call scm_gc_free. Fixes
compilation with debug-malloc.
(scm_must_free): Don't scm_malloc_unregister.
Ludovic Courtès [Sat, 4 Feb 2012 22:38:47 +0000 (23:38 +0100)]
i18n: Skips ~h `format' tests when digit grouping info is missing.
* test-suite/tests/i18n.test ("format ~h"): Skip tests when
`locale-digit-grouping' returns '().
BT Templeton [Wed, 17 Aug 2011 03:49:56 +0000 (23:49 -0400)]
function binding fixes
* module/language/elisp/bindings.scm (bindings): Add `function-bindings'
field.
(make-bindings): Initialize the `function-bindings' field.
(get-function-binding, with-function-bindings): New functions.
(access-variable, reference-variable, set-variable!): Remove the
`module' argument and only handle references to the value cell. All
callers changed. Callers passing `function-slot' as the module changed
to use the corresponding functions for the function cell instead.
(access-function, reference-function, set-function!): New procedures.
(compile-flet, compile-labels): Use `with-function-bindings' instead
of `with-lexical-bindings'.
BT Templeton [Wed, 17 Aug 2011 03:16:46 +0000 (23:16 -0400)]
sharpsign-colon for uninterned symbols
* module/language/elisp/lexer.sm (lex): Add support for `#:' syntax for
uninterned symbols.
BT Templeton [Sun, 14 Aug 2011 21:36:38 +0000 (17:36 -0400)]
elisp I/O
* module/language/elisp/boot.el (princ, print, terpri, format*): New
functions.
BT Templeton [Sun, 14 Aug 2011 20:54:14 +0000 (16:54 -0400)]
improve management of global special variables
* module/language/elisp/bindings.scm (bindings): Remove `globals'
field. (global?, mark-global!, map-globals): Remove. All callers
changed.
* module/language/elisp/compile-tree-il.scm (generate-ensure-global,
ensuring-globals): Remove. All callers changed.
(global?, ensure-globals!): New procedures.
(bind-lexically?): Use new `global?'.
(compile-lambda, compile-let, compile-let*): Use `ensure-globals!'.
BT Templeton [Sun, 14 Aug 2011 20:42:37 +0000 (16:42 -0400)]
more lexical declarations
* module/language/elisp/boot.el (condition-case, catch): Add `lexical'
declarations in macro expansions.
BT Templeton [Fri, 12 Aug 2011 20:34:16 +0000 (16:34 -0400)]
signal an error for uncaught throws
* module/language/elisp/boot.el (%catch): New variable.
(catch): Bind `%catch' to `t' during the evaluation of `body'. Call
`throw' instead of signalling an exception directly.
(throw): Signal a `no-catch' error if there is no `catch' to throw to.
BT Templeton [Fri, 12 Aug 2011 19:57:17 +0000 (15:57 -0400)]
`catch' in terms of `condition-case'
* module/language/elisp/boot.el (throw): Define an `error-conditions'
property for this symbol.
(catch): Define in terms of `condition-case' instead of using Guile
exceptions directly.
(throw): Signal a `throw' condition instead of throwing a Guile
exception directly.
BT Templeton [Fri, 12 Aug 2011 03:56:55 +0000 (23:56 -0400)]
standard error symbols
* module/language/elisp/boot.el (error, wrong-type-argument, no-catch,
invalid-function): Define `error-conditions' properties for these
standard error symbols.
BT Templeton [Fri, 12 Aug 2011 03:47:36 +0000 (23:47 -0400)]
`%plist-member' fix
* module/language/elisp/boot.el (%plist-member): Use recursion to avoid
using `catch' and `throw'.
BT Templeton [Fri, 12 Aug 2011 03:41:30 +0000 (23:41 -0400)]
condition-case
* module/language/elisp/boot.el (signal): Accept only two arguments, and
throw an `elisp-condition' exception instead of an `elisp-error'
exception.
(condition-case): New macro.
BT Templeton [Fri, 12 Aug 2011 03:20:37 +0000 (23:20 -0400)]
elisp `member' subrs
* module/language/elisp/boot.el (%member, member, memql, memq): New
functions.
BT Templeton [Tue, 9 Aug 2011 03:40:07 +0000 (23:40 -0400)]
use `dynlet' for dynamic binding
* module/language/elisp/compile-tree-il.scm (let-dynamic): Remove. All
callers changed to use `dynlet' instead.
BT Templeton [Tue, 9 Aug 2011 00:47:03 +0000 (20:47 -0400)]
inline `generate-let' and `generate-let*'
* module/language/elisp/compile-tree-il.scm (generate-let, compile-let):
Inline the former into the latter.
(generate-let*, compile-let*): Likewise.
BT Templeton [Tue, 9 Aug 2011 00:40:13 +0000 (20:40 -0400)]
define `flet' directly
* module/language/elisp/compile-tree-il.scm (compile-flet): Compile
`flet' directly instead of using `generate-let'.
BT Templeton [Tue, 9 Aug 2011 00:20:16 +0000 (20:20 -0400)]
lexical binding macros
* module/language/elisp/boot.el (lexical-let, lexical-let*): New macros.
* module/language/elisp/compile-tree-il.scm (bind-lexically?): Remove
the check for a `lexical' flag, since `lexical-let' and `lexical-let*'
are no longer special operators.
(compile-lexical-let, compile-lexical-let*): Remove.
* module/language/elisp/runtime/function-slot.scm: Update module
definition.
BT Templeton [Tue, 9 Aug 2011 00:15:06 +0000 (20:15 -0400)]
use `lexical' declarations in "boot.el"
* module/language/elisp/boot.el (prog1, cond, or, catch): Use `let' with
`lexical' declarations instead of `lexical-let'.
(%plist-put): Use `let' instead of `lexical-let', since "boot.el" now
uses lexical binding by default.
BT Templeton [Mon, 8 Aug 2011 22:53:01 +0000 (18:53 -0400)]
elisp `while' macro
* module/language/elisp/compile-tree-il.scm (compile-while): Remove.
* module/language/elisp/boot.el (while): New macro.
* module/language/elisp/runtime/function-slot.scm: Update module
definition.
BT Templeton [Mon, 8 Aug 2011 22:50:04 +0000 (18:50 -0400)]
elisp `labels'
* module/language/elisp/compile-tree-il.scm (compile-labels): New
special operator.
* module/language/elisp/runtime/function-slot.scm: Update module
definition.
BT Templeton [Mon, 8 Aug 2011 22:18:41 +0000 (18:18 -0400)]
fix `flet' syntax
* module/language/elisp/compile-tree-il.scm (process-let-bindings):
Remove.
(parse-let-binding, parse-flet-binding): New procedures.
(generate-let, generate-let*): Now takes an association list mapping
symbols to values for the `bindings' argument.
(compile-let, compile-let*, compile-lexical-let)
(compile-lexical-let*): Parse the bindings list with
`parse-let-binding'.
(compile-flet): Parse the bindings list with `parse-flet-binding'.
BT Templeton [Mon, 8 Aug 2011 21:45:42 +0000 (17:45 -0400)]
elisp binding declarations
* module/language/elisp/compile-tree-il.scm (bind-lexically?): Accept a
new `decls' argument and check it for `lexical' declarations.
Establish the same kind of binding whether or not a lexical binding
for `sym' exists, whereas previously the presence of a lexical binding
would cause newly-established bindings to be lexical bindings as well.
(split-let-bindings): Remove. All callers changed.
(generate-let, generate-let*, compile-lambda): Pass the declarations
list to `bind-lexically?'.
* test-suite/tests/elisp-compiler.test: Explicitly disable the
lexical-binding mode. Add `lexical' declarations where necessary.
BT Templeton [Fri, 5 Aug 2011 20:14:42 +0000 (16:14 -0400)]
declaration parsing
* module/language/elisp/compile-tree-il.scm (parse-body-1, parse-body)
(parse-lambda-body, parse-declaration): New procedures.
(generate-let, generate-let*): Use `parse-body'.
(compile-lambda): Use `parse-lambda-body'.
BT Templeton [Sat, 6 Aug 2011 23:13:10 +0000 (19:13 -0400)]
elisp lambda list parsing
* module/language/elisp/compile-tree-il.scm (split-lambda-arguments):
Remove.
(parse-lambda-list, make-simple-lambda): New procedures.
(compile-lambda): Use `parse-lambda-list' and `make-simple-lambda'.
Set empty rest arguments to the empty list instead of `#nil'.
* test-suite/tests/elisp-compiler.test ("Lambda Expressions")["rest
argument"]: Use Elisp `null' instead of a Scheme equality check.
BT Templeton [Mon, 25 Jul 2011 17:21:55 +0000 (13:21 -0400)]
elisp function subrs
* module/language/elisp/boot.el (null, consp, listp, car, cdr)
(make-symbol, signal): Use `%funcall' instead of `funcall' or `fset'.
(symbolp, symbol-function, eval): Use `%funcall', since `funcall' now
calls these functions.
(functionp, %indirect-function): New functions.
(funcall): Define in terms of `%funcall' and `%indirect-function'.
(apply): New function. Previously defined in
"module/language/elisp/runtime/subrs.scm".
(fset): If `definition' is not a function, set the function cell of
`symbol' to an falias for `definition'.
* module/language/elisp/falias.scm: New file.
* module/language/elisp/subrs.scm: Remove file.
(apply): Remove. Now defined in "boot.el".
* module/language/elisp/runtime/function-slot.scm: Update module
definition.
* module/Makefile.am: Update.
BT Templeton [Sat, 30 Jul 2011 21:12:13 +0000 (17:12 -0400)]
remove dynamic function binding
* module/language/elisp/compile-tree-il.scm (find-operator): Assume that
`name' is lexically bound.
* module/language/elisp/runtime.scm (symbol-fbound?, fmakunbound!):
Assume that `symbol' is lexically bound.
(defspecial): Bind special operators lexically.
BT Templeton [Sat, 30 Jul 2011 04:22:15 +0000 (00:22 -0400)]
elisp nil equality
* module/language/elisp/boot.el (eq, equal): Return `#t' if both
arguments are nil.
(eql): New function.
BT Templeton [Sat, 30 Jul 2011 04:16:50 +0000 (00:16 -0400)]
use lexical binding in boot.el
* module/language/elisp/boot.el: Use lexical binding.