bpt/guile.git
13 years agofix testing code in web/server
Andy Wingo [Sun, 12 Dec 2010 22:33:33 +0000 (23:33 +0100)]
fix testing code in web/server

* module/web/server.scm (call-with-encoded-output-string): Fix some code
  I accidentally left in while testing. Re-tested the difference in
  speed; pleasantly surprised.

* module/web/uri.scm: Make the same change here.

13 years agoforeign: c-struct parsing simplification
Andy Wingo [Sun, 12 Dec 2010 22:13:08 +0000 (23:13 +0100)]
foreign: c-struct parsing simplification

* module/system/foreign.scm: Revert much of fb636a1cce. Short et al are
  not distinct types -- they are all aliases to e.g. int16. The only
  case that was not covered before was the pointer case.
  (bytevector-pointer-ref, bytevector-pointer-set!): Implement these,
  and use them for pointers.

13 years ago1.9.13 news to main body
Andy Wingo [Sun, 12 Dec 2010 21:45:47 +0000 (22:45 +0100)]
1.9.13 news to main body

* NEWS: Fold 1.9.13 text into the main text.

13 years agohttp-read robustness
Andy Wingo [Sun, 12 Dec 2010 20:59:29 +0000 (21:59 +0100)]
http-read robustness

* module/web/server/http.scm (http-read): Record the client index in
  more cases in which code could throw an error.

13 years ago(web uri) can uri-decode non-utf-8 payloads
Andy Wingo [Sat, 11 Dec 2010 18:14:58 +0000 (19:14 +0100)]
(web uri) can uri-decode non-utf-8 payloads

* module/web/uri.scm (call-with-encoded-output-string, encode-string):
  Copy from server.scm
  (decode-string): Copy from tekuti.
  (uri-decode): The #:charset arg is a string, like
  port-encoding. Support other charsets.
  (uri-encode): Charset is a string. Other encodings still not nicely
  supported. Hmm.

13 years agoadd return/values hack to compile-glil for lua
Andy Wingo [Fri, 10 Dec 2010 16:49:37 +0000 (17:49 +0100)]
add return/values hack to compile-glil for lua

* module/language/tree-il/compile-glil.scm (*primcall-ops*): Add a hack
  like 'return but for multiple values, for lua.

13 years agornrs control only depends on (guile)
Andy Wingo [Fri, 10 Dec 2010 16:48:38 +0000 (17:48 +0100)]
rnrs control only depends on (guile)

* module/rnrs/control.scm: Depend only on (guile).

13 years agofix self-tail-calls for lexical procs with optional, rest, or kwargs
Andy Wingo [Fri, 10 Dec 2010 12:02:24 +0000 (13:02 +0100)]
fix self-tail-calls for lexical procs with optional, rest, or kwargs

* module/language/tree-il/compile-glil.scm (flatten-lambda): Don't emit
  a self-label, because when we can't match the args for a lexical call,
  we have no space to shuffle args and jump.
  (flatten): Apply the self-tail-call optimization to optional args
  too, but only if the procedure is fix-allocated. If we can't apply the
  optimization, use the normal tail-call sequence.

* test-suite/tests/optargs.test ("lambda* inits"): Add tests.

13 years agoclarify compile-glil error messages
Andy Wingo [Thu, 9 Dec 2010 20:53:46 +0000 (21:53 +0100)]
clarify compile-glil error messages

* module/language/tree-il/compile-glil.scm (vars->bind-list, flatten):
  Make internal self-checking error messages more clear, for
  implementors of other languages.

13 years agoGet rid of `define-macro' in the SRFI 26 implementation
Andreas Rottmann [Tue, 7 Dec 2010 22:13:55 +0000 (23:13 +0100)]
Get rid of `define-macro' in the SRFI 26 implementation

* module/srfi/srfi-26.scm (cut, cute): Implement using `syntax-case'.
  The new implementation is mostly just a transcription of the old code;
  the reference implementation which relies only on `syntax-rules' may
  (or may not) be considered more elegant :-).

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
13 years agoUse `current-processor-count' to determine the number of future-workers.
Ludovic Courtès [Tue, 7 Dec 2010 22:11:53 +0000 (23:11 +0100)]
Use `current-processor-count' to determine the number of future-workers.

* module/ice-9/futures.scm (%worker-count): Use
  `current-processor-count'.

* doc/ref/api-scheduling.texi (Futures): Add note about side-effects and
  I/O.  Mention `current-processor-count'.

13 years agoAdd `total-processor-count' and `current-processor-count'.
Ludovic Courtès [Tue, 7 Dec 2010 22:10:41 +0000 (23:10 +0100)]
Add `total-processor-count' and `current-processor-count'.

* libguile/posix.c (scm_total_processor_count,
  scm_current_processor_count): New functions.

* libguile/posix.h (scm_total_processor_count,
  scm_current_processor_count): New declarations.

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

* doc/ref/posix.texi (Processes): Document `total-processor-count' and
  `current-processor-count'.

13 years agoImprove doc of `getaffinity' and `setaffinity'.
Ludovic Courtès [Tue, 7 Dec 2010 21:56:07 +0000 (22:56 +0100)]
Improve doc of `getaffinity' and `setaffinity'.

* doc/ref/posix.texi (Processes): Add cross-reference from `setaffinity'
  and `getaffinity' to the corresponding node in the glibc manual.

* libguile/posix.c (scm_getaffinity, scm_setaffinity): Likewise.

13 years agoTemporarily fix `unistr.in.h' to allow compilation with `-Wundef'.
Ludovic Courtès [Tue, 7 Dec 2010 21:49:46 +0000 (22:49 +0100)]
Temporarily fix `unistr.in.h' to allow compilation with `-Wundef'.

See <http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/24225> for details.

* lib/unistr.in.h: Change #if's into #ifdef's.

13 years agoUse Gnulib's `nproc'.
Ludovic Courtès [Tue, 7 Dec 2010 20:43:04 +0000 (21:43 +0100)]
Use Gnulib's `nproc'.

This updates Gnulib to v0.0-4496-g6491120.

* m4/gnulib-cache.m4: Add `nproc'.

13 years agoBuild dlopenable modules with `-module'.
Ludovic Courtès [Tue, 7 Dec 2010 19:45:29 +0000 (20:45 +0100)]
Build dlopenable modules with `-module'.

* test-suite/standalone/Makefile.am (libtest_asmobs_la_LDFLAGS,
  libtest_ffi_la_LDFLAGS, libtest_extensions_la_LDFLAGS): Add `-module'.

13 years agoAdd a record type printer for vlists/vhashes.
Ludovic Courtès [Tue, 7 Dec 2010 19:43:49 +0000 (20:43 +0100)]
Add a record type printer for vlists/vhashes.

* module/ice-9/vlist.scm (<vlist>): Add a record type printer.

13 years agolexical function binding for elisp
Brian Templeton [Mon, 16 Aug 2010 07:20:55 +0000 (03:20 -0400)]
lexical function binding for elisp

* module/language/elisp/compile-tree-il.scm (access-variable)
  (reference-variable, set-variable!): Handle globally-bound non-special
  variables.

  (bind-lexically?): Create lexical bindings for flet and flet*.

* module/language/elisp/runtime.scm (reference-variable, set-variable!):
  Handle globally-bound non-special variables.

  (built-in-func): Set the variable directly instead of storing the
  function in a fluid.

* module/language/elisp/runtime/subrs.scm (funcall): Call apply
  directly.

* test-suite/tests/elisp-compiler.test ("Function Definitions")["flet
  and flet*"]:

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agouse unbound fluids instead of `void' sentinel value
Brian Templeton [Sat, 14 Aug 2010 23:28:56 +0000 (19:28 -0400)]
use unbound fluids instead of `void' sentinel value

* module/language/elisp/compile-tree-il.scm (reference-with-check)
  (compile-without-void-checks, want-void-check?): Remove.

  (compile-function, compile-pair): Use `reference-variable' instead of
  `reference-with-check'.

  (compile-defvar): Only set `sym' if `sym' is not bound to a bound
  fluid, rather than requiring that its value be `void'.

  (process-options!): Remove `#:disable-void-check' option handling.

* module/language/elisp/runtime.scm (void)
  (reference-variable-with-check): Remove.

  (ensure-fluid!): Use an undefined fluid as the initial value for
  global variables.

* module/language/elisp/runtime/function-slot.scm (without-void-checks):
  Don't import or re-export.

* module/language/elisp/runtime/macros.scm (prog1, cond, or, dolist):
  Don't use `without-void-checks'.

* module/language/elisp/runtime/subrs.scm (symbol-value)
  (symbol-function, apply): Use `reference-variable' instead of
  `reference-variable-with-check'.

  (makunbound, fmakunbound, boundp, fboundp): Unset the variable's fluid
  (or the variable itself, if it isn't bound to a fluid).

* test-suite/tests/elisp-compiler.test ("Variable
  Setting/Referencing")["disabled void check (all)", "disabled void
  check (symbol list)", "without-void-checks"]: Remove.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agofunction's argument can be a symbol
Brian Templeton [Thu, 22 Jul 2010 20:33:53 +0000 (16:33 -0400)]
function's argument can be a symbol

* module/language/elisp/compile-tree-il.scm (compile-function): the form
  `(function SYMBOL)' evaluates to the functional value of SYMBOL

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agoallow `(setcar nil nil)' and `(setcdr nil nil)'
Brian Templeton [Thu, 22 Jul 2010 20:25:29 +0000 (16:25 -0400)]
allow `(setcar nil nil)' and `(setcdr nil nil)'

* module/language/elisp/runtime/subrs.scm (setcar, setcdr): Allow
  setting the car or cdr of `nil' to `nil'.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agosupport "#'" syntax for function expressions
Brian Templeton [Thu, 22 Jul 2010 19:12:50 +0000 (15:12 -0400)]
support "#'" syntax for function expressions

* module/language/elisp/lexer.scm (lex):
* module/language/elisp/parser.scm (get-expression): Support sharpsign
  single-quote syntax as an abbreviation for `function' expressions.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agosetq can take any number of arguments
Brian Templeton [Sat, 10 Jul 2010 06:47:16 +0000 (02:47 -0400)]
setq can take any number of arguments

* module/language/elisp/compile-tree-il.scm (compile-setq): Return nil
  if called with no arguments, and set the last variable to nil if its
  value is omitted.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agouse correct names for quasiquotation operators
Brian Templeton [Sat, 10 Jul 2010 00:33:32 +0000 (20:33 -0400)]
use correct names for quasiquotation operators

Use #{`}#, #{,}# and #{,@}# as the quasiquote, unquote and
unquote-splicing operators, respectively. Previously they were named
escaping.

* module/language/elisp/compile-tree-il.scm (unquote?): Change "\," to
  "#{,}#".
  (unquote-splicing): Change "\,@" to "#{,@}#".
  (#{compile-`}#): Rename from #{compile-\`}#.
* module/language/elisp/runtime/function-slot.scm: Import #{compile-`}#
  instead of #{compile-\`}#, and re-export as #{`}# instead of as
  #{\`}#.
* module/language/elisp/parser.scm (quotation-symbols):
* test-suite/tests/elisp-compiler.test ("Eval", "Quotation"):
* test-suite/tests/elisp-reader.test ("Parser"): Change "\`", "\,", and
  "\,@" to "#{`}#", "#{,}#" and "#{,@}#", respectively.

13 years agostore special operators in the function slot
Brian Templeton [Fri, 9 Jul 2010 23:52:48 +0000 (19:52 -0400)]
store special operators in the function slot

If the function slot of a symbol contains a pair with `special-operator'
in the car and a procedure in the cdr, the procedure is called to
compile the form to Tree-IL. This is similar to other Emacs Lisp
implementations, in which special operators are subrs.

* module/language/elisp/compile-tree-il.scm: Restructured to store
  special operator definitions in the function slot. Import `(language
  elisp runtime)' for `defspecial'. Export special operators so that
  `(language elisp runtime function-slot)' can re-export them.

  (backquote?): Removed; the backquote symbol is defined as a special
  operator, so it's no longer used in `compile-pair'.

  (is-macro?, get-macro): Replaced by `find-operator'.
  (find-operator): New procedure.

  (compile-progn, compile-if, compile-defconst, compile-defvar,
  compile-setq, compile-let, compile-lexical-let, compile-flet,
  compile-let*, compile-lexical-let*, compile-flet*,
  compile-without-void-checks, compile-with-always-lexical,
  compile-guile-ref, compile-guile-primitive, compile-while,
  compile-function, compile-defmacro, compile-defun, #{compile-`}#,
  compile-quote): New special operators with definitions taken from the
  pmatch form in `compile-pair'. There is no special operator `lambda';
  it is now a macro, as in other Elisp implementations.

  (compile-pair): Instead of directly compiling special forms, check for
  a special operator object in the function slot.

* module/language/elisp/runtime.scm: Export `defspecial'.
  (make-id): New function.
  (built-in-macro): Prefix macros with `macro-'.
  (defspecial): New syntax.

* module/language/elisp/runtime/function-slot.scm: Import and re-export
  special operators. Rename imported special operators and macros to
  remove prefixes. Re-export new macro `lambda'.

* module/language/elisp/runtime/macros.scm (macro-lambda): New Elisp
  macro.

13 years agoupdate elisp reader tests to handle EOF tokens
Brian Templeton [Fri, 2 Jul 2010 02:38:23 +0000 (22:38 -0400)]
update elisp reader tests to handle EOF tokens

* test-suite/tests/elisp-reader.test (lex-all, "end-of-input",
  "lexer/1"): Check for an EOF token instead of the symbol `*eoi*'.

13 years agomake user-defined macros available at runtime
Brian Templeton [Wed, 30 Jun 2010 20:54:45 +0000 (16:54 -0400)]
make user-defined macros available at runtime

* module/language/elisp/compile-tree-il.scm (ensuring-globals): New
  procedure.
  (define-macro!): Remove.
  (compile-pair) <defmacro>: Make macro available at runtime, not only
  during compilation.
  (compile-tree-il): Use `ensuring-globals'.

13 years agoallow fluid macro bindings
Brian Templeton [Wed, 30 Jun 2010 20:48:19 +0000 (16:48 -0400)]
allow fluid macro bindings

* module/language/elisp/compile-tree-il.scm (define-macro!, get-macro):
  Allow fluid macro bindings.

13 years agonew `load' subr
Brian Templeton [Wed, 30 Jun 2010 01:18:05 +0000 (21:18 -0400)]
new `load' subr

* module/language/elisp/runtime/subrs.scm: Define new subr `load'.
* module/language/elisp/runtime/function-slot.scm: Re-export `load'.

13 years agoIgnore #:warnings compiler option
Brian Templeton [Wed, 30 Jun 2010 01:13:18 +0000 (21:13 -0400)]
Ignore #:warnings compiler option

* module/language/elisp/compile-tree-il.scm (process-options!): Ignore
  #:warnings compiler option.

13 years agohandle EOF correctly in parser and lexer
Brian Templeton [Fri, 25 Jun 2010 03:03:08 +0000 (23:03 -0400)]
handle EOF correctly in parser and lexer

* module/language/elisp/lexer.scm (lex, get-lexer/1): Return a valid
  token at EOF.
* module/language/elisp/parser.scm (get-expression): Raise an error if
  EOF is reached.
  (read-elisp): If at EOF, return the EOF object instead of attempting
  to read an expression.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agostore macro definitions in the function slot
Brian Templeton [Wed, 23 Jun 2010 23:31:33 +0000 (19:31 -0400)]
store macro definitions in the function slot

Guile Emacs Lisp previously kept macros in a separate macro slot; now
macros are stored as macro objects in the function slot for
compatibility with other implementations.

* module/language/elisp/compile-tree-il.scm (macro-slot): Remove.
  (is-macro?): Check that the argument is a symbol. Now-unnecessary
  check removed in `compile-tree-il'.
  (macro?, define-macro!, get-macro): Store macro definitions in the
  function slot, not in a separate macro slot.
* module/language/elisp/runtime.scm (built-in-macro): Wrap the macro
  function in a macro object (i.e., cons the symbol `macro' onto it).
* module/language/elisp/runtime/function-slot.scm: Move contents to
  "subrs.scm". Re-export function and macro definitions instead of
  defining functions directly in this module.
* module/language/elisp/runtime/macro-slot.scm: Move contents to
  "macros.scm" and remove.
* module/language/elisp/runtime/macros.scm: New file containing macro
  definitions from "macro-slot.scm".
* module/language/elisp/runtime/subrs.scm: New file containing function
  definitions from "function-slot.scm".

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agouse existing bindings record for defmacro
Brian Templeton [Fri, 18 Jun 2010 00:25:42 +0000 (20:25 -0400)]
use existing bindings record for defmacro

* module/language/elisp/compile-tree-il.scm (compile-pair): Use existing
  bindings record during macro definition.

13 years agouse tree-il's support for optional arguments
Brian Templeton [Wed, 16 Jun 2010 21:18:30 +0000 (17:18 -0400)]
use tree-il's support for optional arguments

* module/language/elisp/compile-tree-il.scm (compile-lambda): Use
  Tree-IL's support for optional arguments.
  (process-optionals, process-rest): Remove.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agomake `pass-if-equal' literal in `compile-test'
Brian Templeton [Wed, 23 Jun 2010 23:40:03 +0000 (19:40 -0400)]
make `pass-if-equal' literal in `compile-test'

* test-suite/tests/elisp-compiler.test (compile-test): Add
  `pass-if-equal' to the list of literal identifiers

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agoreindent
Brian Templeton [Mon, 7 Jun 2010 20:38:23 +0000 (16:38 -0400)]
reindent

* module/language/elisp/bindings.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/elisp/lexer.scm:
* module/language/elisp/parser.scm:
* module/language/elisp/runtime.scm:
* module/language/elisp/runtime/function-slot.scm:
* module/language/elisp/runtime/macro-slot.scm:
* module/language/elisp/spec.scm: Reindent.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agoreformat comments
Brian Templeton [Mon, 7 Jun 2010 20:38:00 +0000 (16:38 -0400)]
reformat comments

* module/language/elisp/bindings.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/elisp/lexer.scm:
* module/language/elisp/parser.scm:
* module/language/elisp/runtime.scm:
* module/language/elisp/runtime/function-slot.scm:
* module/language/elisp/runtime/macro-slot.scm:
* module/language/elisp/runtime/value-slot.scm: Reformat comments.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agowhitespace changes
Brian Templeton [Mon, 7 Jun 2010 20:37:24 +0000 (16:37 -0400)]
whitespace changes

* module/language/elisp/bindings.scm:
* module/language/elisp/compile-tree-il.scm:
* module/language/elisp/lexer.scm:
* module/language/elisp/parser.scm:
* module/language/elisp/runtime.scm:
* module/language/elisp/runtime/function-slot.scm:
* module/language/elisp/runtime/macro-slot.scm: Ensure that all
  top-level forms and comments are separated by exactly one newline.
  Remove blank lines in most procedure bodies. Delete trailing
  whitespace.

Signed-off-by: Andy Wingo <wingo@pobox.com>
13 years agoautoload compile-file in (guile-user)
Brian Templeton [Wed, 14 Jul 2010 21:47:37 +0000 (17:47 -0400)]
autoload compile-file in (guile-user)

* module/ice-9/boot-9.scm (guile-user): Autoload `compile-file'.

13 years agovariable-unset!
Brian Templeton [Sat, 14 Aug 2010 23:00:20 +0000 (19:00 -0400)]
variable-unset!

* libguile/variable.c (scm_variable_unset_x): New function.
* libguile/variable.h (scm_variable_unset_x): New prototype.

13 years agounbound fluids
Brian Templeton [Sat, 14 Aug 2010 22:35:17 +0000 (18:35 -0400)]
unbound fluids

* libguile/fluids.c (scm_make_undefined_fluid, scm_fluid_unset_x)
  (scm_fluid_bound_p): New functions.

  (fluid_ref): New function; like scm_fluid_ref, but will not throw an
  error for unbound fluids.
  (scm_fluid_ref, swap_fluid): Use `fluid_ref'.

* libguile/fluids.h (scm_make_undefined_fluid, scm_fluid_unset_x)
  (scm_fluid_bound_p): New prototypes.

* libguile/vm-i-system.c (fluid_ref): If fluid is unbound, jump to
  `vm_error_unbound_fluid'.
* libguile/vm-engine.c (VM_NAME)[vm_error_unbound_fluid]: New error
  message.

* test-suite/tests/fluids.test ("unbound fluids")["fluid-ref of unbound
  fluid", "fluid-bound? of bound fluid", "fluid-bound? of unbound
  fluid", "unbound fluids can be set", "bound fluids can be unset"]: New
  tests.

13 years agobetter unbound variable errors in the vm
Andy Wingo [Tue, 7 Dec 2010 11:26:07 +0000 (12:26 +0100)]
better unbound variable errors in the vm

* libguile/vm-i-system.c (variable-ref, toplevel-ref)
  (long-toplevel-ref): Fixup callers.

* libguile/vm-engine.c (vm_error_unbound): Don't use vm-error for
  unbound vars, use misc-error. Don't include VM: in the string. Take
  the name directly in finish_args, not as a list.

13 years agomake guile-test work without configuration
Brian Templeton [Wed, 14 Jul 2010 00:55:45 +0000 (20:55 -0400)]
make guile-test work without configuration

* test-suite/guile-test: Use "../meta/guile" as the interpreter instead
  of "../libguile/guile".
  (default-test-suite): New function, replacing the variable of the same
  name. Look for tests in the same directory as the guile-test script.
  Throw an error if not invoked as `guile-test'.
  (test-suite): The old default value of `default-test-suite' could now
  throw an error, and this already gets initialized in `main', so don't
  provide an initial value.

13 years agoPut `figures' into standard texinfo form
Neil Jerram [Mon, 6 Dec 2010 23:02:12 +0000 (23:02 +0000)]
Put `figures' into standard texinfo form

* doc/ref/goops.texi (Example, Inheritance): Remove unnecessary figure
  references.  Use @float and @ref.
  (Class precedence list): Ditto.

13 years agoMerge `tutorial' and `reference' treatments of the same basic GOOPS
Neil Jerram [Mon, 6 Dec 2010 22:28:39 +0000 (22:28 +0000)]
Merge `tutorial' and `reference' treatments of the same basic GOOPS
material

* doc/ref/goops.texi (GOOPS): Move use of (oop goops) here.

  (Class Definition): Merged with `Defining New Classes'

  (Instance Creation): Insert before covering slot options.  Merge in
  material from `Creating Instances'.

  (Slot Options): Merged some better wording and index entries from
  the tutorial version.

  (Slot Description Example): New node, containing the <my-complex>
  material from the tutorial.

  (Methods and Generic Functions, Inheritance): Tutorial sections
  moved into main line of the manual.

* doc/ref/goops-tutorial.texi: Nothing left here now.

13 years agoMinor textual markups
Neil Jerram [Mon, 6 Dec 2010 20:24:58 +0000 (20:24 +0000)]
Minor textual markups

* doc/ref/goops-tutorial.texi (Class definition): No reason to assume
  particular familiarity with CLOS.
  (Instance creation and slot access): Remove a couple of words.

13 years agoscm_setvbuf doesn't throw away current buffers
Andy Wingo [Mon, 6 Dec 2010 18:59:15 +0000 (19:59 +0100)]
scm_setvbuf doesn't throw away current buffers

* libguile/ports.c (scm_drain_input): Slight optimization.

* libguile/fports.c (scm_setvbuf): If there is buffered output, flush
  it.  If there is input, drain it, and then unread it after updating
  the buffers.  Much more sensible than dropping it silently...

13 years agohttp-read calls setvbuf only once
Andy Wingo [Mon, 6 Dec 2010 18:52:51 +0000 (19:52 +0100)]
http-read calls setvbuf only once

* module/web/server/http.scm (http-read): Don't play the setvbuf dance,
  it was throwing away buffered input. Instead just call setvbuf once
  before doing any reads or writes.

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.