bpt/guile.git
13 years agoice-9 poll handles buffered io too
Andy Wingo [Mon, 6 Dec 2010 18:27:22 +0000 (19:27 +0100)]
ice-9 poll handles buffered io too

* libguile/poll.c (scm_primitive_poll): Account for buffered I/O.

* module/ice-9/poll.scm (poll): Adapt to call primitive-poll with the
  port vector too.

13 years agofix name...
Andy Wingo [Mon, 6 Dec 2010 14:32:13 +0000 (15:32 +0100)]
fix name...

* module/web/request.scm (read-request-body/latin-1): Fix name...

13 years agofix read-{request,response}-body/latin-1
Andy Wingo [Mon, 6 Dec 2010 14:30:45 +0000 (15:30 +0100)]
fix read-{request,response}-body/latin-1

* module/web/request.scm (read-response-body/latin-1):
* module/web/response.scm (read-response-body/latin-1): Avoid the
  craziness of the read-delimited! interface and hand-roll our
  own. Fixes errors if read-delimited returns #f or EOF.

13 years agoupdate read-delimited! docs
Andy Wingo [Mon, 6 Dec 2010 14:19:40 +0000 (15:19 +0100)]
update read-delimited! docs

* doc/ref/api-io.texi (Line/Delimited): Update the read-delimited!
  docs.

13 years agoleniency regarding quality values in http.scm
Andy Wingo [Mon, 6 Dec 2010 12:52:56 +0000 (13:52 +0100)]
leniency regarding quality values in http.scm

* module/web/http.scm: Add commentary.
  (parse-quality): Allow .NNN to be interpreted as 0.NNN.

* test-suite/tests/web-http.test ("request headers"): Add a test.

13 years agofix entity tag writing
Andy Wingo [Mon, 6 Dec 2010 11:58:16 +0000 (12:58 +0100)]
fix entity tag writing

* module/web/http.scm (write-entity-tag): Fix writing of entity tags
  (strong versus weak).

13 years agomore robustness in http-read
Andy Wingo [Mon, 6 Dec 2010 10:24:48 +0000 (11:24 +0100)]
more robustness in http-read

* module/web/server/http.scm (http-read): If there was an error reading
  the request, be sure to close the request port.

13 years agohttp doesn't keep-alive requests for which there was an error
Andy Wingo [Sun, 5 Dec 2010 19:24:14 +0000 (20:24 +0100)]
http doesn't keep-alive requests for which there was an error

* module/web/server/http.scm (keep-alive?): Don't keep the client around
  if there is an error.

13 years ago(web server http) comment
Andy Wingo [Sat, 4 Dec 2010 18:45:51 +0000 (19:45 +0100)]
(web server http) comment

* module/web/server/http.scm: Add comment about charsets.

13 years agofix error handling in read-{request,response}-body/latin-1
Andy Wingo [Sat, 4 Dec 2010 18:45:09 +0000 (19:45 +0100)]
fix error handling in read-{request,response}-body/latin-1

* module/web/request.scm (read-request-body/latin-1):
* module/web/response.scm (read-response-body/latin-1): Detect short
  reads instead of returning a full buffer with the last bits zeroed
  out. (Before the make-string commit, they contained uninitialized
  memory, which was a fairly serious error.)

13 years agomake-string et al nulls memory if not given an initializer
Andy Wingo [Sat, 4 Dec 2010 18:31:20 +0000 (19:31 +0100)]
make-string et al nulls memory if not given an initializer

* libguile/gc-malloc.c: Add a note that the gc-malloc does not clear the
  memory block, so users need to make sure it is initialized.

* libguile/bitvectors.c (scm_c_make_bitvector):
* libguile/bytevectors.c (scm_make_bytevector):
* libguile/strings.c (scm_c_make_string): If no initializer is given,
  initialize the bytes to 0. Prevents information leakage if an app uses
  make-string et al without initializers.

* libguile/foreign.c (make_cif): Initialize this too, to prevent leakage
  in the struct holes. Paranoia...

13 years agoread-delimited is clearer and conses less
Andy Wingo [Fri, 3 Dec 2010 17:03:51 +0000 (18:03 +0100)]
read-delimited is clearer and conses less

* module/ice-9/rdelim.scm (read-delimited): Clarify and somewhat
  optimize implementation.

13 years agohttp server impl reads body as a bytevector by default
Andy Wingo [Fri, 3 Dec 2010 16:37:22 +0000 (17:37 +0100)]
http server impl reads body as a bytevector by default

* module/web/server/http.scm (http-read): Read body as a bytevector by
  default. That way we punt encoding issues to the app.

13 years agoremove redundant error-handling block
Andy Wingo [Fri, 3 Dec 2010 15:41:46 +0000 (16:41 +0100)]
remove redundant error-handling block

* module/web/server/http.scm (http-read): No need for a
  call-with-error-handling block here, as the read impl is itself within
  an error-handling block.

13 years agoweb server micro-tuning
Andy Wingo [Fri, 3 Dec 2010 15:30:52 +0000 (16:30 +0100)]
web server micro-tuning

* module/web/server/http.scm (http-open): Allow up to 128 pending
  connections -- the default value for somaxconn on a number of
  machines. This is from the HOP paper.
  (http-read): Set the send buffer to 12 KB, also from the HOP paper.

13 years agoreverse order of poll-set traversal in http-read
Andy Wingo [Fri, 3 Dec 2010 15:11:37 +0000 (16:11 +0100)]
reverse order of poll-set traversal in http-read

* module/web/server/http.scm (http-read): Rewrite to iterate down the
  pollset, so the vector shuffles touch less memory and the end
  condition of the loop is clearer.

13 years ago(web server) punts keep-alive to impls; http server uses (ice-9 poll)
Andy Wingo [Fri, 3 Dec 2010 14:31:57 +0000 (15:31 +0100)]
(web server) punts keep-alive to impls; http server uses (ice-9 poll)

* module/web/server.scm: Rewrite to remove the extra "keep-alive"
  parameter. Instead, since the server is an essentially stateful
  object, have clients that want to do keep-alive manage that set as
  part of the server state. Also avoids imposing a particular data
  structure on the server implementation.

* module/web/server/http.scm: Adapt to the new server interface. Also,
  use a poll set instead of select and lists. Makes handling 1000
  clients at a time much more possible.

13 years agoASYNC_TICK after catching EINTR in SCM_SYSCALL
Andy Wingo [Fri, 3 Dec 2010 14:17:35 +0000 (15:17 +0100)]
ASYNC_TICK after catching EINTR in SCM_SYSCALL

* libguile/_scm.h (SCM_SYSCALL): As in scm_syserror, do a SCM_ASYNC_TICK
  before resuming the syscall after an EINTR.

13 years agoadd (ice-9 poll), a poll wrapper
Andy Wingo [Fri, 3 Dec 2010 12:09:43 +0000 (13:09 +0100)]
add (ice-9 poll), a poll wrapper

* libguile/poll.c:
* libguile/poll.h:
* module/ice-9/poll.scm: New module, (ice-9 poll).

* module/Makefile.am:
* libguile/init.c:
* libguile/Makefile.am: Adapt.

* configure.ac: Check for poll.h and poll.

13 years agoAdd `(ice-9 futures)'.
Ludovic Courtès [Thu, 2 Dec 2010 23:35:15 +0000 (00:35 +0100)]
Add `(ice-9 futures)'.

* doc/ref/api-scheduling.texi (Threads): Add short introduction.
  Mention the `threads' feature.  Add cross-reference to futures.
  (Futures): New node.

* module/Makefile.am (ICE_9_SOURCES): Add `ice-9/futures.scm'.

* module/ice-9/futures.scm: New file.

* test-suite/Makefile.am (SCM_TESTS): Add `tests/future.test'.

* test-suite/tests/future.test: New file.

13 years agoAdd bindings to GNU `sched_setaffinity' and `sched_getaffinity'.
Ludovic Courtès [Wed, 1 Dec 2010 22:58:39 +0000 (23:58 +0100)]
Add bindings to GNU `sched_setaffinity' and `sched_getaffinity'.

* configure.ac: Add checks for `sched_setaffinity' and
  `sched_getaffinity'.

* doc/ref/posix.texi (Processes): Document `getaffinity' and
  `setaffinity'.

* libguile/posix.c (cpu_set_to_bitvector,
  scm_getaffinity)[HAVE_SCHED_GETAFFINITY]: New functions.
  (scm_setaffinity)[HAVE_SCHED_SETAFFINITY]: New function.

* libguile/posix.h (scm_getaffinity, scm_setaffinity): New declarations.

* test-suite/tests/posix.test ("affinity"): New test prefix.

13 years agono need for fport_fill_input to select() before read()
Andy Wingo [Thu, 2 Dec 2010 22:41:00 +0000 (23:41 +0100)]
no need for fport_fill_input to select() before read()

* libguile/fports.c (fport_fill_input): Likewise to the previous commit,
  no need to select() before read().

13 years agoscm_accept no longer leaves guile mode
Andy Wingo [Thu, 2 Dec 2010 22:24:39 +0000 (23:24 +0100)]
scm_accept no longer leaves guile mode

* libguile/socket.c (scm_accept): Revert
  7d1fc8721724ab64ccdc44d6f4f84abad43751b4. Now that we don't need to
  leave guile mode in order for GC to happen, don't do so, as we assume
  that anyone who cares has already done a select() beforehand.

13 years agosxml->xml fix
Andy Wingo [Thu, 2 Dec 2010 21:24:26 +0000 (22:24 +0100)]
sxml->xml fix

* module/sxml/simple.scm (attribute-value->xml): Whoops, fix null case.

13 years agosxml->xml writes directly to a port
Andy Wingo [Thu, 2 Dec 2010 16:25:46 +0000 (17:25 +0100)]
sxml->xml writes directly to a port

* module/sxml/simple.scm: Remove "universal-sxslt-rules" -- it was a bad
  interface, and I couldn't find any users of it.
  (sxml->xml): Rewrite so that instead of generating another tree of
  data, we write the data directly to a port.

13 years agoadd some debugging to (web server)
Andy Wingo [Thu, 2 Dec 2010 12:36:04 +0000 (13:36 +0100)]
add some debugging to (web server)

* module/web/server.scm: Add some basic elapsed-time debugging, but only
  if you flip a switch to turn it on at expand-time.

13 years agobetter socket buffering on http web server backend
Andy Wingo [Thu, 2 Dec 2010 12:33:49 +0000 (13:33 +0100)]
better socket buffering on http web server backend

* module/web/server/http.scm (http-read, http-write): Line-buffer the
  port while we're reading the request, and block-buffer it otherwise
  Use the default block size.

13 years agoindentation fix in ports.c
Andy Wingo [Thu, 2 Dec 2010 11:46:15 +0000 (12:46 +0100)]
indentation fix in ports.c

* libguile/ports.c (scm_i_get_conversion_strategy): Indentation fix.

13 years ago(web server) supports non-utf-8 charsets
Andy Wingo [Thu, 2 Dec 2010 11:28:35 +0000 (12:28 +0100)]
(web server) supports non-utf-8 charsets

* module/web/server.scm (sanitize-response): Support charsets other than
  utf-8. Oddly collecting a string and converting it to utf-8 appears to
  be faster than collecting a utf-8 bytevector directly.

13 years agoadd simple web app examples
Andy Wingo [Thu, 2 Dec 2010 10:47:19 +0000 (11:47 +0100)]
add simple web app examples

* examples/web/hello.scm:
* examples/web/debug-sxml.scm: New examples, for simple web
  applications.

* examples/README:
* examples/Makefile.am: Add new files.

13 years agohttp web server impl ignores SIGPIPE
Andy Wingo [Mon, 29 Nov 2010 12:00:43 +0000 (13:00 +0100)]
http web server impl ignores SIGPIPE

* module/web/server/http.scm (http-open): Ignore SIGPIPE. Keeps the
  server from dying in some circumstances.

13 years agostub fixes to http 1.0 support in the web server
Andy Wingo [Mon, 29 Nov 2010 11:05:57 +0000 (12:05 +0100)]
stub fixes to http 1.0 support in the web server

* module/web/server.scm (read-client): Fix number of returned values in
  the case in which there is an error reading the client.
  (sanitize-response): Add a case to adapt the reponse to the request
  version.
  (handle-request): Sanitize the response within an error-handling
  block.
  (serve-one-client): Move sanitation out of here.

* module/web/server/http.scm (keep-alive?): A more proper detection on
  whether we should support persistent connections.

* module/web/response.scm (adapt-response-version): New routine, to
  adapt a response to a given version. Currently a stub.

13 years agoSome tweaks to the R6RS support
Andreas Rottmann [Thu, 25 Nov 2010 22:03:12 +0000 (23:03 +0100)]
Some tweaks to the R6RS support

* module/rnrs/base.scm (error, assert): Define -- they were missing.
  (assertion-violation): Properly treat a #f `who' argument.

* module/rnrs/conditions.scm (condition): Use `assertion-violation'
  instead of the undefined `raise'.
  (define-condition-type): Fix for multiple fields.
* test-suite/tests/r6rs-conditions.test: Test accessors of a
  multiple-field condition.  Also import `(rnrs base)' to allow
  stand-alone running of the tests; apparently the `@' references
  scattered throughout the R6RS modules make the libraries sensitive to
  their load order -- for instance, trying to load `(rnrs conditions)'
  before `(rnrs base)' is loaded fails.

* module/rnrs/records/inspection.scm: Use `assertion-violation' instead
  of an explicit `raise'.
* module/rnrs/records/syntactic.scm (process-fields): Use
  `syntax-violation' instead of bogus invocations of `error'.

13 years agoFix `regexp.test' when the "en_US.utf8" locale isn't available.
Ludovic Courtès [Wed, 24 Nov 2010 22:38:01 +0000 (23:38 +0100)]
Fix `regexp.test' when the "en_US.utf8" locale isn't available.

* test-suite/tests/regexp.test ("nonascii locales"): Move `with-locale'
  within the body of `pass-if' so that `unresolved' is caught.

13 years agoHonor R6RS transcoder error handling modes, when possible.
Ludovic Courtès [Wed, 24 Nov 2010 22:01:50 +0000 (23:01 +0100)]
Honor R6RS transcoder error handling modes, when possible.

* module/rnrs/io/ports.scm (transcoded-port): Change RESULT's conversion
  strategy based on TRANSCODER's error-handling mode.

* test-suite/tests/r6rs-ports.test ("8.2.6  Input and output
  ports")["transcoded-port [error handling mode = raise]",
  "transcoded-port [error handling mode = replace]"]: New tests.

13 years agoAdd implementation of "transcoded ports"
Andreas Rottmann [Sun, 21 Nov 2010 22:17:54 +0000 (23:17 +0100)]
Add implementation of "transcoded ports"

* libguile/r6rs-ports.c (make_tp, tp_write, tp_fill_input, tp_flush)
  (tp_close, initialize_transcoded_ports, scm_i_make_transcoded_port): New
  functions.
  (scm_init_r6rs_ports): Call `initialize_transcoded_ports'.
* module/rnrs/ports.scm (transcoded-port): Actually implement,
  using `%make-transcoded-port'.
* test-suite/tests/r6rs-ports.test ("8.2.6 Input and output ports"): Added a
  few tests for `transcoded-port'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoWork towards a more complete implementation of `(rnrs io ports)'
Andreas Rottmann [Sun, 21 Nov 2010 22:17:53 +0000 (23:17 +0100)]
Work towards a more complete implementation of `(rnrs io ports)'

* module/rnrs/io/ports.scm: (file-options, buffer-mode, eol-style)
  (error-handling-mode, make-transcoder, native-transcoder)
  (latin-1-codec, utf-8-codec, utf-16-codec)
  (call-with-bytevector-output-port, open-file-input-port)
  (open-file-output-port, make-custom-textual-output-port)
  (flush-output-port, put-char, put-datum, put-string, get-char)
  (get-datum, get-line, get-string-all, lookahead-char)
  (standard-input-port, standard-output-port, standard-error-port):
  Define all of these.

  (call-with-port): Don't use `dynamic-wind', as it is against its
  specification in R6RS 8.2.6.

* module/rnrs.scm: Export procedures added.

* module/rnrs/io/simple.scm (call-with-input-file)
  (call-with-output-file): Define these in terms of R6RS procedures to
  get correct exception behavior.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoReorganize the R6RS I/O condition types
Andreas Rottmann [Sun, 21 Nov 2010 22:17:52 +0000 (23:17 +0100)]
Reorganize the R6RS I/O condition types

Move the I/O condition types from `(rnrs conditions)', where they were
not exported, to `(rnrs files)', where they are.

* module/rnrs/conditions.scm: Remove definition of I/O condition types.
* module/rnrs/files.scm: Replace references to I/O condition types
  inside `(rnrs conditions)' with the actual definitions.
* module/rnrs/io/simple.scm: Don't `@@'-reference the I/O condition types, just
  imported them from `(rnrs files)'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoTurn `(rnrs io ports)' into an R6RS library
Andreas Rottmann [Sun, 21 Nov 2010 22:17:51 +0000 (23:17 +0100)]
Turn `(rnrs io ports)' into an R6RS library

* module/rnrs/io/ports.scm: Change into an R6RS library from a "regular"
  Guile module, so the bookkeeping for #:re-export and #:replace is done
  automatically and we gain control over the imports from `(guile)'.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agofix regexp matches to refer to chars, not bytes
Andy Wingo [Tue, 23 Nov 2010 21:39:06 +0000 (22:39 +0100)]
fix regexp matches to refer to chars, not bytes

* libguile/regex-posix.c (fixup_multibyte_match): Fixup the match
  structure to refer to character offsets, not byte offsets. Fixes bug
  31650.

* test-suite/tests/regexp.test: Add a test.

13 years agofix web server bugs
Andy Wingo [Tue, 23 Nov 2010 15:02:21 +0000 (16:02 +0100)]
fix web server bugs

* module/web/http.scm (valid-quality?):
* module/web/server.scm (sanitize-response): Fix a couple bugs.

13 years agofix up a couple content-length issues in web/server.scm:sanitize-response
Andy Wingo [Mon, 22 Nov 2010 22:58:24 +0000 (23:58 +0100)]
fix up a couple content-length issues in web/server.scm:sanitize-response

* module/web/server.scm (sanitize-response): Allow body to be #f. Don't
  require or insert a content-length if there is no body.

13 years agoEnumeration set universe comparisons should be done with `equal?'
Julian Graham [Sun, 21 Nov 2010 20:35:44 +0000 (15:35 -0500)]
Enumeration set universe comparisons should be done with `equal?'

* module/rnrs/enums.scm (enum-set-union, enum-set-intersection,
  enum-set-difference): Compare enum-set universes with `equal?' to support
  sets generated using constructor syntax bound by `define-enumeration'.
* test-suite/tests/r6rs-enums.test (enum-set-union, enum-set-intersection,
  enum-set-difference): New test cases for syntactically-generated sets.

13 years agoFix missing port-table locking and bytevector output port segfault
Andreas Rottmann [Sat, 20 Nov 2010 17:40:30 +0000 (18:40 +0100)]
Fix missing port-table locking and bytevector output port segfault

* libguile/r6rs-ports.c (make_bip, make_cbip, make_bop, make_cbop): Lock
  the port table.

* libguile/r6rs-ports.c (make_bop): Let the returned extraction
  procedure refer to the port's buffer instead of the port itself.  This
  fixes a segfault if the port is closed before the extraction procedure
  is called.
  (bop_proc_apply): Adapt accordingly.
* test-suite/tests/r6rs-ports.test (8.2.10 Output ports): Add testcase
  for extraction after close.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoAllow user-defined meta-commands
Andreas Rottmann [Sat, 20 Nov 2010 22:14:05 +0000 (23:14 +0100)]
Allow user-defined meta-commands

Besides allowing user-defined meta-commands, this change also refactors
the meta-command machinery to split reading a command's arguments from
the procedure actually implementing it, and hence allows nesting
meta-commands.  As an example of such a command, ",in" is added as a new
meta-command.

* module/system/repl/command.scm: Export `define-meta-command'.
  (*command-module*): Replaced by the hash table `*command-infos*'.
  (command-info, make-command-info, command-info-procedure)
  (command-info-arguments-reader): New procedures, encapsulating the
  information about a meta-command.
  (command-procedure): Adapted to use the `command-info' lookup
  procedure.
  (read-command-arguments): New auxiliary procedure invoking a command's
  argument reader procedure.
  (meta-command): Adapted to the split of reading arguments and
  executing a command.
  (add-meta-command!): New auxiliary procedure, registers a meta
  command's procedure and argument reader into `*command-infos* and
  `*command-table*.
  (define-meta-command): Extended to allow specification of the command's
  category; split the argument reader and actual command procedure.
  (guile:apropos, guile:load, guile:compile-file, guile:gc): Remove these
  aliases, they are unnecessary as we now use a hash table instead of the
  module to store the commands.
  (in): New meta-command, which evaluates an expression, or alternatively
  executes another meta-command, in the context of a specific module.
* doc/ref/scheme-using.texi (Module Commands): Document the `in'
  meta-command.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoannounce flex version in autogen.sh
Andy Wingo [Sat, 20 Nov 2010 22:18:43 +0000 (23:18 +0100)]
announce flex version in autogen.sh

* autogen.sh: Announce flex version. Has the side-effect of checking for
  flex when building from git.

13 years agoAllow specifying load extensions on the command line
Andreas Rottmann [Sat, 20 Nov 2010 00:05:10 +0000 (01:05 +0100)]
Allow specifying load extensions on the command line

Add a new command-line switch `-x', which manipulates the
%load-extensions list.

* libguile/script.c (scm_compile_shell_switches): Process the new "-x"
  switch.
  (scm_shell_usage): Mention the "-x" switch.
* doc/ref/scheme-scripts.texi (Invoking Guile): Add "-x" switch to the
  list of command-line switches.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoUse `define-module*' in (ice-9 history).
Ludovic Courtès [Fri, 19 Nov 2010 23:47:12 +0000 (00:47 +0100)]
Use `define-module*' in (ice-9 history).

* module/ice-9/history.scm: Use `define-module*' instead of
  `process-define-module'.

13 years agobump objcode version
Andy Wingo [Fri, 19 Nov 2010 16:51:16 +0000 (17:51 +0100)]
bump objcode version

* libguile/_scm.h (SCM_OBJCODE_MINOR_VERSION): Bump, as the
  process-define-module deprecation means that outside compiled code
  won't find process-define-module in the (guile) module, as they would
  before.

13 years agofix string-filter and string-delete argument order
Andy Wingo [Fri, 19 Nov 2010 16:08:36 +0000 (17:08 +0100)]
fix string-filter and string-delete argument order

* libguile/srfi-13.h:
* libguile/srfi-13.c (scm_string_filter, scm_string_delete): Swap
  char_pred and s argument order, to comply with SRFI-13. There is a
  back-compat shim that will detect programs that used the old,
  erroneous interface, while giving a warning.

* doc/ref/api-data.texi: Update docs.

13 years agodeprecate process-define-module
Andy Wingo [Fri, 19 Nov 2010 14:08:07 +0000 (15:08 +0100)]
deprecate process-define-module

* module/ice-9/boot-9.scm:
* module/ice-9/deprecated.scm (process-define-module): Deprecate.

13 years agodefine-module compiles to define-module*
Andy Wingo [Fri, 19 Nov 2010 13:43:31 +0000 (14:43 +0100)]
define-module compiles to define-module*

* module/ice-9/boot-9.scm (define-module): Compile down to a call to
  define-module*, not process-define-module.

13 years agoscm_c_define_module uses define-module*
Andy Wingo [Fri, 19 Nov 2010 12:11:47 +0000 (13:11 +0100)]
scm_c_define_module uses define-module*

* libguile/modules.c (scm_c_define_module):
* module/ice-9/boot-9.scm: Update to have the C function call
  define-module*.

13 years agomake module definition procedure more structured
Andy Wingo [Fri, 19 Nov 2010 12:06:03 +0000 (13:06 +0100)]
make module definition procedure more structured

* module/ice-9/boot-9.scm (define-module*): New procedure, like
  process-define-modules but more structured.
  (process-define-module): Reimplement in terms of define-module*.

13 years agorelax sizeof(long) restriction in configure.ac
Andy Wingo [Fri, 19 Nov 2010 10:39:06 +0000 (11:39 +0100)]
relax sizeof(long) restriction in configure.ac

* configure.ac: Relax the sizeof(long)==sizeof(void*) restriction,
  instead asserting that the sizeof(long)<=sizeof(void*). There will
  still be problems on nonstandard platforms related to the interface
  with gmp, but those are confined to numbers.c.

13 years agofix a number of assuptions that a long could hold an inum
Andy Wingo [Fri, 19 Nov 2010 10:29:26 +0000 (11:29 +0100)]
fix a number of assuptions that a long could hold an inum

* libguile/bytevectors.c:
* libguile/goops.c:
* libguile/instructions.c:
* libguile/numbers.c:
* libguile/random.c:
* libguile/read.c:
* libguile/vm-i-scheme.c: Fix a number of assumptions that a long could
  hold an inum. This is not the case on platforms whose void* is larger
  than their long.

* libguile/numbers.c (scm_i_inum2big): New helper, only implemented for
  sizeof(void*) == sizeof(long); produces a compile error on other
  platforms. Basically gmp doesn't have a nice interface for converting
  between mpz values and intmax_t.

13 years agosimpos tweak
Andy Wingo [Thu, 18 Nov 2010 21:31:34 +0000 (22:31 +0100)]
simpos tweak

* libguile/simpos.c (scm_system_star): Use scm_from_ulong, as we do cast
  to ulong.

13 years agofix a number of assumptions that a pointer could fit into a long
Andy Wingo [Thu, 18 Nov 2010 21:30:27 +0000 (22:30 +0100)]
fix a number of assumptions that a pointer could fit into a long

* libguile/debug.c:
* libguile/eval.c:
* libguile/frames.c:
* libguile/objcodes.c:
* libguile/print.c:
* libguile/programs.c:
* libguile/read.c:
* libguile/struct.c:
* libguile/vm.c: Fix a number of instances in which we assumed we could
  fit a pointer into a long.

13 years agoFix incorrect uses of en-dashes and em-dashes in the intro.
Ludovic Courtès [Fri, 19 Nov 2010 13:28:40 +0000 (14:28 +0100)]
Fix incorrect uses of en-dashes and em-dashes in the intro.

* doc/ref/intro.texi (Introduction): Use commas instead of en-dashes
  around "for example".  Use em-dashes instead of en-dashes around
  parenthetical phrases.  Remove spaces around em-dashes.

13 years agoInclude <alloca.h> wherever `alloca' is used.
Ludovic Courtès [Fri, 19 Nov 2010 13:14:53 +0000 (14:14 +0100)]
Include <alloca.h> wherever `alloca' is used.

Patch provided by <carlo.bramix@libero.it> (tiny change).

* libguile/control.c, libguile/fluids.c, libguile/foreign.c,
  libguile/hashtab.c, libguile/strings.c: Include <alloca.h>.

13 years agoOptimize fixnum comparison.
Ludovic Courtès [Fri, 19 Nov 2010 10:18:42 +0000 (11:18 +0100)]
Optimize fixnum comparison.

* libguile/vm-i-scheme.c (REL): Don't untag X and Y since tagging
  preserves ordering.

13 years agoAdd fixnum arithmetic benchmarks.
Ludovic Courtès [Fri, 19 Nov 2010 10:06:10 +0000 (11:06 +0100)]
Add fixnum arithmetic benchmarks.

* benchmark-suite/benchmarks/arithmetic.bm ("fixnum")["*", "/"]: New
  benchmarks.

13 years agoAdd optimized tagged integer addition/subtractions for x86_64.
Ludovic Courtès [Wed, 17 Nov 2010 22:06:26 +0000 (23:06 +0100)]
Add optimized tagged integer addition/subtractions for x86_64.

This results in a 17% improvement in the execution time of the "+" and
"-" benchmarks for fixnums.

* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB)[defined __x86_64__ &&
  SCM_GNUC_PREREQ (4, 5)]: New macros.
  (add)[defined ASM_ADD]: Use `ASM_ADD' for the fast path.
  (sub)[defined ASM_SUB]: Use `ASM_SUB' for the fast path.

* test-suite/tests/numbers.test ("+")["fixnum + fixnum = bignum
  (32-bit)", "fixnum + fixnum = bignum (64-bit)", "bignum + fixnum =
  fixnum", "wrong type"]: New tests.
  ("-")["fixnum - fixnum = bignum (32-bit)", "fixnum - fixnum = bignum
  (64-bit)", "bignum - fixnum = fixnum", "wrong type"]: New tests.

* test-suite/tests/00-initial-env.test ("goopsless")["+ wrong type
  argument"]: Use `with-test-prefix/c&e' instead of `with-test-prefix'.
  ["- wrong type argument"]: New test prefix.

13 years agoUse the `with-test-prefix/c&e' for the `1+' and `1-' tests.
Ludovic Courtès [Wed, 17 Nov 2010 22:05:50 +0000 (23:05 +0100)]
Use the `with-test-prefix/c&e' for the `1+' and `1-' tests.

* test-suite/tests/numbers.test ("1+"): Use `with-test-prefix/c&e'
  instead of `with-test-prefix'.  Provide a name to each `pass-if'
  invocation.
  ("1-"): Likewise.

13 years agoMove `with-test-prefix/c&e' to `(test-suite lib)'.
Ludovic Courtès [Wed, 17 Nov 2010 22:04:11 +0000 (23:04 +0100)]
Move `with-test-prefix/c&e' to `(test-suite lib)'.

* test-suite/tests/bytevectors.test (c&e, with-test-prefix/c&e): Move...
* test-suite/lib.scm: ... here.
  (with-test-prefix): Rewrite using `syntax-rules'.

13 years agoAdd `SCM_GNUC_PREREQ'.
Ludovic Courtès [Fri, 12 Nov 2010 08:54:49 +0000 (09:54 +0100)]
Add `SCM_GNUC_PREREQ'.

* libguile/__scm.h (SCM_GNUC_PREREQ): New macro.
  Use it in this file in lieu of hand-written GCC version tests.

13 years agoadd `reload-module' to boot-9
Andy Wingo [Thu, 18 Nov 2010 20:48:55 +0000 (21:48 +0100)]
add `reload-module' to boot-9

* module/ice-9/boot-9.scm (reload-module): New procedure,
  programmatically reloads the source file corresponding to the given
  module.

13 years agonumbers.test expects lower-case hexadecimals
Andy Wingo [Thu, 18 Nov 2010 15:06:46 +0000 (16:06 +0100)]
numbers.test expects lower-case hexadecimals

* test-suite/tests/numbers.test ("number->string"): Expect lower-case
  hexidecimals.

13 years agoread-set! takes effect at expand time
Andy Wingo [Thu, 18 Nov 2010 13:43:43 +0000 (14:43 +0100)]
read-set! takes effect at expand time

* module/ice-9/boot-9.scm (define-option-interface): The set! command
  goes in an eval-when to be run at expand-time, so that (read-set!
  keywords 'prefix) does what it used to in 1.8 (mostly).

13 years agorepl read/write using current ports, not captured ports
Andy Wingo [Thu, 18 Nov 2010 13:32:53 +0000 (14:32 +0100)]
repl read/write using current ports, not captured ports

Fixes bug in repl meta-commands after activating readline, which changes
the current input port.

* module/system/repl/common.scm (<repl>): Remove inport and outport
  fields.
  (make-repl): Adapt.
  (repl-read, repl-print): Just read and write to the current ports.

* module/system/repl/repl.scm (meta-reader): Meta-read from the current
  input port.

* module/system/repl/command.scm (read-command, define-meta-command):
  Read from the current input port.

13 years agolower-case hexadecimal digits again
Andy Wingo [Thu, 18 Nov 2010 12:10:45 +0000 (13:10 +0100)]
lower-case hexadecimal digits again

* libguile/numbers.c: Default to lower-case hexadecimal digits again.

13 years agobetter errors for ecmascript parser too
Andy Wingo [Thu, 18 Nov 2010 12:03:49 +0000 (13:03 +0100)]
better errors for ecmascript parser too

* module/language/ecmascript/parse.scm (syntax-error): Better errors
  here too.

13 years agoecmascript tokenization errors report source location
Andy Wingo [Thu, 18 Nov 2010 11:55:25 +0000 (12:55 +0100)]
ecmascript tokenization errors report source location

* module/language/ecmascript/tokenize.scm (syntax-error): Report source
  locations. Adapt all callers to pass source locations.

13 years agoadd source-location->source-properties to lalr
Andy Wingo [Thu, 18 Nov 2010 11:31:28 +0000 (12:31 +0100)]
add source-location->source-properties to lalr

* module/system/base/lalr.scm (source-location->source-properties): New
  public function, to produce source properties that can be given to the
  compiler.

13 years agomore ecmascript testing
Andy Wingo [Thu, 18 Nov 2010 11:26:20 +0000 (12:26 +0100)]
more ecmascript testing

* test-suite/tests/ecmascript.test (eread/1, parse): Also check
  read-ecmascript/1, which uses tokenize/1.

13 years agofix ecmascript at the repl
Andy Wingo [Thu, 18 Nov 2010 11:24:01 +0000 (12:24 +0100)]
fix ecmascript at the repl

* module/language/ecmascript/tokenize.scm (syntax-error): Reorder args
  to throw vals in the right order.
  (make-tokenizer/1): Fix. Broken since the lalr refactor...

13 years agorepl.scm displays syntax errors on read as well
Andy Wingo [Thu, 18 Nov 2010 11:21:36 +0000 (12:21 +0100)]
repl.scm displays syntax errors on read as well

* module/system/repl/repl.scm (prompting-meta-read): Use
  display-syntax-error as appropriate.

13 years agodeprecate cuserid
Andy Wingo [Thu, 18 Nov 2010 10:15:16 +0000 (11:15 +0100)]
deprecate cuserid

* libguile/posix.c:
* libguile/posix.h:
* libguile/deprecated.h:
* libguile/deprecated.c (scm_cuserid): Deprecate cuserid, as it only
  returns 8 bytes of a user's login.

* doc/ref/posix.texi: Remove cuserid from docs.

13 years agoadapt tests to new syntax-error form
Andy Wingo [Thu, 18 Nov 2010 10:04:15 +0000 (11:04 +0100)]
adapt tests to new syntax-error form

* test-suite/tests/syntax.test (pass-if-syntax-error): Fix up for new
  form of syntax errors. Adapt all tests.

* test-suite/tests/srfi-17.test: Likewise.

13 years agoAdd exports for missing functions from `(rnrs base)'.
Julian Graham [Wed, 17 Nov 2010 05:59:45 +0000 (00:59 -0500)]
Add exports for missing functions from `(rnrs base)'.

* module/rnrs.scm (boolean=?): New export.
  Fix typo in export of`integer-valued?'.
* module/rnrs/base.scm: Add exports for `exact' and `inexact'.
  (boolean=?, symbol=?, infinite?, finite?, exact-integer-sqrt,
  integer-valued?, rational-valued?, real-valued?): New functions.
* test-suite/tests/r6rs-base.test (boolean=?, symbol=?, infinite?,
  finite?, exact-integer-sqrt, integer-valued?, rational-valued?,
  real-valued?): New test prefixes and tests.

13 years agofix the C syntax-error pretty-printer
Andy Wingo [Tue, 16 Nov 2010 02:00:01 +0000 (03:00 +0100)]
fix the C syntax-error pretty-printer

* libguile/throw.c (handler_message): Fix up a bit.

13 years agoadd proper pretty-printing for syntax errors
Andy Wingo [Tue, 16 Nov 2010 01:56:43 +0000 (02:56 +0100)]
add proper pretty-printing for syntax errors

* module/system/repl/repl.scm (display-syntax-error): New helper,
  displays a syntax error.
  (abort-on-error, run-repl): Use it.

* libguile/throw.c (handler_message): Re-code the same thing in C.

13 years agoremove syntax-error and call-with-compile-error-catch from compile.scm
Andy Wingo [Tue, 16 Nov 2010 01:55:46 +0000 (02:55 +0100)]
remove syntax-error and call-with-compile-error-catch from compile.scm

* module/system/base/compile.scm: Remove unused syntax-error and
  call-with-compile-error-catch exports.

13 years agoecmascript syntax errors throw to 'syntax-error
Andy Wingo [Tue, 16 Nov 2010 01:09:39 +0000 (02:09 +0100)]
ecmascript syntax errors throw to 'syntax-error

* module/language/ecmascript/parse.scm (syntax-error):
* module/language/ecmascript/tokenize.scm (syntax-error): Throw to
  'syntax-error as psyntax does.

13 years agosyntax-violation uses lambda*, throws a structured message
Andy Wingo [Tue, 16 Nov 2010 01:09:03 +0000 (02:09 +0100)]
syntax-violation uses lambda*, throws a structured message

* module/ice-9/psyntax.scm (syntax-violation): Use lambda* for subform
  arg. Instead of using scm-error, just throw to 'syntax-error with all
  we got.

* module/ice-9/psyntax-pp.scm (#{and-map*\ 37}): Regenerated.

13 years agofix string->number for bases > 16
Andy Wingo [Mon, 15 Nov 2010 22:43:30 +0000 (23:43 +0100)]
fix string->number for bases > 16

* libguile/numbers.c (scm_iuint2str): Add an assertion on the domain of
  the radix. Use the number_chars table to write the string, instead of
  doing strange math. Same effect, though.
  (mem2uinteger, char_decimal_value): Change logic to allow all ascii
  alphabetic chars as decimals, not just a-f. Thanks to Nils Gey for the
  report.

* test-suite/tests/numbers.test ("number->string"): Add some tests.

13 years agoExpression-oriented readline history
Neil Jerram [Sat, 30 Oct 2010 15:28:54 +0000 (16:28 +0100)]
Expression-oriented readline history

* guile-readline/ice-9/readline.scm (make-readline-port): Instead of
  calling add-history after every %readline call, do it only when
  starting a new read.  Other times, append the line just read to an
  internal buffer.

13 years agoflesh out (web server)'s sanitize-response
Andy Wingo [Sat, 13 Nov 2010 17:31:34 +0000 (18:31 +0100)]
flesh out (web server)'s sanitize-response

* module/web/server.scm (sanitize-response): Flesh out. If we get a
  string, we encode it to a bytevector using the encoding snarfed from
  the response. We should check the request, though...

13 years agoadd extend-response.
Andy Wingo [Sat, 13 Nov 2010 17:30:27 +0000 (18:30 +0100)]
add extend-response.

* module/web/response.scm (extend-response): New utility.

13 years ago(web http) parses content-type as "foo/bar", not "foo" "bar"
Andy Wingo [Sat, 13 Nov 2010 17:17:28 +0000 (18:17 +0100)]
(web http) parses content-type as "foo/bar", not "foo" "bar"

* module/web/http.scm (parse-media-type, validate-media-type,
  (content-type): Change to represent media types as ("foo/bar" ("param"
  . "val") ...) instead of ("foo" "bar" ("param" . "val") ...). Seems to
  be more in line with what people expect.

* test-suite/tests/web-http.test ("entity headers"): Add content-type
  test.

* test-suite/tests/web-response.test ("example-1"): Adapt expected
  parse.

13 years agoNUL vs NULL fix
Andy Wingo [Fri, 12 Nov 2010 16:18:08 +0000 (17:18 +0100)]
NUL vs NULL fix

* libguile/read.c (scm_i_scan_for_encoding): Fix NUL rather than NULL.

13 years agoremove (web toy-server)
Andy Wingo [Fri, 12 Nov 2010 11:16:26 +0000 (12:16 +0100)]
remove (web toy-server)

* module/Makefile.am
* module/web/toy-server.scm: Remove. It's not so much that the new (web
  server) stuff is not a toy, it's that users are expected to use the
  new backends (mod-lisp, etc) in "production".

13 years agoadd generic web server with http-over-tcp backend
Andy Wingo [Fri, 12 Nov 2010 11:07:24 +0000 (12:07 +0100)]
add generic web server with http-over-tcp backend

* module/web/server.scm: New generic web server module, with support for
  different backends. An HTTP-over-TCP backend is the only one included
  with Guile, though one can imagine FastCGI, mod-lisp, mongrel2/0mq etc
  backends as well.

* module/web/server/http.scm: The aforementioned HTTP backend.

13 years agoadd request-meta
Andy Wingo [Fri, 12 Nov 2010 11:12:34 +0000 (12:12 +0100)]
add request-meta

* module/web/request.scm (<request>): Add `meta' field and accessor, for
  metadata like the server IP, the client IP, CGI environment variables,
  etc.
  (build-request): Add meta kwarg.
  (read-request): Add meta optional arg.
  (write-request): Adapt.

13 years agomore (web http) exports for parsing request components
Andy Wingo [Fri, 12 Nov 2010 11:10:44 +0000 (12:10 +0100)]
more (web http) exports for parsing request components

* module/web/http.scm (lookup-header-decl): New exported function.
  (parse-http-version, parse-http-method, parse-request-uri): Export
  these functions.

13 years agocall-with-error-handling pass-keys w/ procedural handlers fix
Andy Wingo [Fri, 12 Nov 2010 11:08:54 +0000 (12:08 +0100)]
call-with-error-handling pass-keys w/ procedural handlers fix

* module/system/repl/error-handling.scm (call-with-error-handling):
  Respect the pass-keys set for procedural on-error and post-error
  handlers.

13 years agounparse-uri avoids serializing e.g. :80 in http:// uris
Andy Wingo [Mon, 8 Nov 2010 15:06:50 +0000 (16:06 +0100)]
unparse-uri avoids serializing e.g. :80 in  uris

* module/web/uri.scm (declare-default-port!): New function, declares a
  default port for a scheme. Predeclare default ports for http and
  https.
  (unparse-uri): If the port is the default port for the given scheme,
  don't serialize the port part of the URI.

13 years agoFix buffer over-read in port encoding scan.
Julian Graham [Fri, 12 Nov 2010 13:45:09 +0000 (08:45 -0500)]
Fix buffer over-read in port encoding scan.

* libguile/read.c (scm_i_scan_for_encoding): Add a NULL terminator to the
  end of header to prevent over-read by subsequent call to strstr.

13 years agoAdd FFI tests for `sizeof' and structs.
Ludovic Courtès [Thu, 11 Nov 2010 15:36:29 +0000 (16:36 +0100)]
Add FFI tests for `sizeof' and structs.

* test-suite/tests/foreign.test ("structs")["sizeof { int8, double }",
  "sizeof { short, int, long, pointer }"]: New tests.

13 years agoAdd FFI support for `short' and `unsigned short'.
Ludovic Courtès [Thu, 11 Nov 2010 15:26:50 +0000 (16:26 +0100)]
Add FFI support for `short' and `unsigned short'.

* libguile/foreign.c (sym_short, sym_unsigned_short): New variables.
  (scm_init_foreign): Define Scheme variables SYM_SHORT and
  SYM_UNSIGNED_SHORT.

* module/system/foreign.scm (short, unsigned-short): New exports.
  (integer-ref, integer-set): Support (= (sizeof TYPE) 2).
  (%read-short, %write-short!, %read-unsigned-short,
  %write-unsigned-short!): New variables.
  (*writers*): Add support for `short' and `unsigned-short'.
  (*readers*): Likewise.

* test-suite/tests/foreign.test ("structs")["int8, pointer, short,
  double"]: New test.