Noah Lavine [Wed, 2 Feb 2011 14:52:10 +0000 (09:52 -0500)]
macro documentation fixup
* doc/ref/api-macros.texi: make the difference between pattern variables
and lexical variables a bit clearer.
Ludovic Courtès [Wed, 2 Feb 2011 17:55:29 +0000 (18:55 +0100)]
Disable use of thread-local storage on FreeBSD.
* acinclude.m4 (GUILE_THREAD_LOCAL_STORAGE): Explicitly require
`AC_CANONICAL_HOST'. Disable on FreeBSD.
Ludovic Courtès [Wed, 2 Feb 2011 17:42:19 +0000 (18:42 +0100)]
Update `NEWS'.
* NEWS: Update.
Ludovic Courtès [Wed, 2 Feb 2011 17:00:49 +0000 (18:00 +0100)]
R6RS: Have `put-char', `put-string', etc. raise an `&i/o-encoding-error'.
* module/rnrs/io/ports.scm (&i/o-encoding): New error condition type.
(with-i/o-encoding-error): New macro.
(put-char, put-datum, put-string): Use it.
* test-suite/tests/r6rs-ports.test ("8.2.6 Input and output
ports")["transcoded-port, output [error handling mode = raise]"]: New
test.
Ludovic Courtès [Wed, 2 Feb 2011 16:38:03 +0000 (17:38 +0100)]
Change `scm_encoding_error' to pass the port and faulty character.
* libguile/strings.c (scm_encoding_error): Remove the `from', `to', and
`string_or_bv' parameters; add `port' and `chr'.
(scm_to_stringn): Update accordingly.
* libguile/strings.h (scm_encoding_error): Update accordingly.
* libguile/ports.c (scm_ungetc): Update accordingly.
* libguile/print.c (iprin1, scm_write_char): Update accordingly.
* test-suite/tests/encoding-escapes.test ("display output
errors")["ultima", "Rashomon"]: Check the arguments of
`encoding-error'.
["tekniko"]: New test.
* test-suite/tests/ports.test ("string ports")["wrong encoding"]: Adjust
to new `encoding-error' arguments.
Ludovic Courtès [Wed, 2 Feb 2011 16:33:12 +0000 (17:33 +0100)]
Upon port encoding error, always write as much as possible.
* libguile/print.c (display_string): Upon error, always write the
OUTPUT_LEN bytes of output, regardless of the conversion strategy.
Ludovic Courtès [Wed, 2 Feb 2011 15:19:48 +0000 (16:19 +0100)]
R6RS: Have `get-char', `get-line', etc. raise an `&i/o-decoding-error'.
* module/rnrs/io/ports.scm (&i/o-decoding): New error condition type.
(with-i/o-decoding-error): New macro.
(get-char, get-datum, get-line, get-string-all, lookahead-char): Use
it.
* test-suite/tests/r6rs-ports.test ("8.2.6 Input and output
ports")["transcoded-port [error handling mode = raise]"]: Use `guard'
and `i/o-decoding-error?'.
Ludovic Courtès [Wed, 2 Feb 2011 15:17:48 +0000 (16:17 +0100)]
Avoid circular dependency between (rnrs base) and (rnrs exceptions).
* module/rnrs/base.scm (raise): Define as a macro instead of a
procedure.
Ludovic Courtès [Wed, 2 Feb 2011 14:52:56 +0000 (15:52 +0100)]
Have `read-char' & co. throw to `decoding-error'.
* libguile/ports.c (scm_read_char): Mention `decoding-error' in the
docstring.
(get_codepoint): Change to return an error code; add `codepoint'
output parameter. Don't raise an error from here.
(scm_getc): Raise an error with `scm_decoding_error' if
`get_codepoint' returns an error.
(scm_peek_char): Likewise. Update docstring.
* libguile/strings.c (scm_decoding_error_key): New variable.
(scm_decoding_error): New function.
(scm_from_stringn): Use `scm_decoding_error' instead of
`scm_encoding_error'.
* libguile/strings.h (scm_decoding_error): New declaration.
* test-suite/tests/ports.test ("string ports")["read-char, wrong
encoding, error"]: Change to expect `decoding-error'. Make sure PORT
points past the error.
["read-char, wrong encoding, escape"]: Likewise.
["peek-char, wrong encoding, error"]: New test.
* test-suite/tests/r6rs-ports.test ("7.2.11 Binary
Output")["put-bytevector with wrong-encoding string port"]: Change to
expect `decoding-error'.
("8.2.6 Input and output ports")["transcoded-port [error handling
mode = raise]"]: Likewise.
* test-suite/tests/rdelim.test ("read-line")["decoding error", "decoding
error, substitute"]: New tests.
* doc/ref/api-io.texi (Reading): Update documentation of `read-char' and
`peek-char'.
(Line/Delimited): Update documentation of `read-line'.
Ludovic Courtès [Wed, 2 Feb 2011 14:13:07 +0000 (15:13 +0100)]
Use `#ifdef HAVE_...', not `#if'.
* test-suite/standalone/test-round.c (test_scm_c_round): Use `#ifdef
HAVE_FESETROUND', not `#if'.
Ludovic Courtès [Wed, 2 Feb 2011 14:12:26 +0000 (15:12 +0100)]
Fix typo.
* libguile/srfi-1.c (scm_srfi1_concatenate_x): Fix `FUNC_NAME'.
Michael Gran [Wed, 2 Feb 2011 13:45:37 +0000 (05:45 -0800)]
Use 'substring' instead of obsoleted 'make-shared-substring'
* module/system/repl/describe.scm (display-description): replace
make-shared-substring with substring
Andreas Rottmann [Tue, 1 Feb 2011 22:50:09 +0000 (23:50 +0100)]
Fix `show' REPL meta-command
* module/system/repl/command.scm (warranty, copying, version): Use
`define-meta-command' to define these procedures, so they are entered
into the *command-infos* table.
Mark H Weaver [Thu, 27 Jan 2011 20:57:38 +0000 (15:57 -0500)]
Improve discussion of exactness propagation in manual
* doc/ref/api-data.texi (Exact and Inexact Numbers): Improve the
discussion of exactness propagation. Mention that there are
exceptions to the rule that calculations involving inexact numbers
must product an inexact result.
Mark H Weaver [Tue, 1 Feb 2011 11:50:48 +0000 (06:50 -0500)]
Move comment about trig functions back where it belongs
* libguile/numbers.c: Move a comment about the trigonometric functions
next to those functions. At some point they became separated, when
scm_expt was placed between them.
Mark H Weaver [Tue, 1 Feb 2011 11:30:29 +0000 (06:30 -0500)]
Handle products with exact 0 differently
* libguile/numbers.c (scm_product): Handle exact 0 differently. A
product containing an exact 0 now returns an exact 0 if and only if
the other arguments are all exact. An inexact zero is returned if and
only if the other arguments are all finite but not all exact. If an
infinite or NaN value is present, a NaN value is returned.
Previously, any product containing an exact 0 yielded an exact 0,
regardless of the other arguments.
A note on the rationale for (* 0 0.0) returning 0.0 and not exact 0:
The exactness propagation rules allow us to return an exact result in
the presence of inexact arguments only if the values of the inexact
arguments do not affect the result. In this case, the value of the
inexact argument _does_ affect the result, because an infinite or NaN
value causes the result to be a NaN.
A note on the rationale for (* 0 +inf.0) being a NaN and not exact 0:
The R6RS requires that (/ 0 0.0) return a NaN value, and that (/ 0.0)
return +inf.0. We would like (/ x y) to be the same as (* x (/ y)),
and in particular, for (/ 0 0.0) to be the same as (* 0 (/ 0.0)),
which reduces to (* 0 +inf.0). Therefore (* 0 +inf.0) should return
a NaN.
* test-suite/tests/numbers.test: Add many multiplication tests.
* NEWS: Add NEWS entry.
Mark H Weaver [Tue, 1 Feb 2011 10:22:40 +0000 (05:22 -0500)]
More discriminating NaN predicates for numbers.test
* test-suite/tests/numbers.test: (real-nan?, complex-nan?,
imaginary-nan?): Add more discriminating NaN testing predicates
internal to numbers.test, and convert several uses of `nan?'
to use these instead:
* `real-nan?' checks that its argument is real and a NaN.
* `complex-nan?' checks that both the real and imaginary
parts of its argument are NaNs.
* `imaginary-nan?' checks that its argument's real part
is zero and the imaginary part is a NaN.
Mark H Weaver [Tue, 1 Feb 2011 10:19:24 +0000 (05:19 -0500)]
Fix bugs in `rationalize'
* libguile/numbers.c (scm_rationalize): Fix bugs. Previously, it
returned exact integers unmodified, although that was incorrect if
the epsilon was at least 1 or inexact, e.g. (rationalize 4 1) should
return 3 per R5RS and R6RS, but previously it returned 4. Also
handle cases involving infinities and NaNs properly, per R6RS.
* test-suite/tests/numbers.test: Add test cases for `rationalize'.
* NEWS: Add NEWS entry
Mark H Weaver [Tue, 1 Feb 2011 09:40:33 +0000 (04:40 -0500)]
Fix and combine NEWS entries on `infinite?' and `finite?'
* NEWS: Fix and combine NEWS entries on `infinite?' and `finite?'.
Previous, they stated that these predicates now work on non-real
complex numbers, but that is not the case.
Mark H Weaver [Tue, 1 Feb 2011 09:31:13 +0000 (04:31 -0500)]
Update copyright date of manual, and a small fix
* doc/ref/guile.texi: Update copyright date to 2011.
* doc/ref/r6rs.texi (rnrs base): Fix typo: `rem0' -> `div0'.
Andy Wingo [Mon, 31 Jan 2011 22:20:32 +0000 (23:20 +0100)]
update NEWS
* NEWS: Update.
Mark H Weaver [Sun, 30 Jan 2011 15:51:36 +0000 (10:51 -0500)]
Improve extensibility of `expt' and `integer-expt'
* libguile/numbers.c (scm_integer_expt): No longer require that the
first argument be a number, in order to improve extensibility. This
allows us to efficiently raise arbitrary objects to an integer power
as long as we can multiply those objects. For example, this allows us
to efficiently exponentiate matrices if we define only multiplication
methods for matrices. Note also that scm_expt calls this procedure
whenever the exponent is an integer, regardless of the type of the
first argument. Also rearrange the order in which we test special
cases.
* test-suite/tests/numbers.test (expt, integer-expt): Comment out tests
that required `(expt #t 0)' and `(integer-expt #t 0)' to throw
exceptions. Add tests for (expt #t 2) and `(integer-expt #t 2)
instead.
* NEWS: Add NEWS entry
Andy Wingo [Mon, 31 Jan 2011 20:02:24 +0000 (21:02 +0100)]
toplevel vars added by syntax expansion are unbound
* module/ice-9/psyntax.scm (chi-top): When adding to the toplevel
environment at compile-time, default to undefined variables, not
variables defined to #f.
* module/ice-9/psyntax-pp.scm: Regenerate.
* module/ice-9/boot-9.scm (module-add!): Add a new pre-modules version
of this function, so we can add variables the environment, not just
values.
(module-define!): Use module-add!.
Mark H Weaver [Mon, 31 Jan 2011 17:03:02 +0000 (12:03 -0500)]
Rename {euclidean,centered}_quo_rem to {euclidean,centered}_divide
* libguile/numbers.c (euclidean_quo_rem): Rename to euclidean_divide.
(centered_quo_rem): Rename to {euclidean,centered}_divide.
* libguile/numbers.h: Rename euclidean_quo_rem to euclidean_divide and
centered_quo_rem to centered_divide.
* doc/ref/api-data.texi: Rename euclidean_quo_rem to euclidean_divide and
centered_quo_rem to centered_divide.
Ludovic Courtès [Mon, 31 Jan 2011 18:26:01 +0000 (19:26 +0100)]
Disable stand-alone tests that require `dlopen' when `--disable-shared'.
* configure.ac (HAVE_SHARED_LIBRARIES): New Automake conditional.
* test-suite/standalone/Makefile.am (check_SCRIPTS): Add `test-asmobs',
`test-ffi', and `test-extensions' only when `HAVE_SHARED_LIBRARIES'.
Mark H Weaver [Mon, 31 Jan 2011 05:42:35 +0000 (00:42 -0500)]
Rework the testing framework for number-theoretic division operators
* test-suite/tests/numbers.test (test-eqv?): Remove special handling of
zeroes. Zeroes are now compared like all other numbers. Exact
numbers are compared with `eqv?' and inexact numbers are compared to
within test-epsilon.
Rework the testing framework for number-theoretic division operators:
`euclidean/', `euclidean-quotient', `euclidean-remainder',
`centered/', `centered-quotient', and `centered-remainder'.
Previously we compared all test results against a simple scheme
implementation of the same operations. However, these operations have
discontinuous jumps where a tiny change in the inputs can lead to a
large change in the outputs, e.g.:
(euclidean/ 130.
00000000000 10/7) ==> 91.0 and 0.0
(euclidean/ 129.
99999999999 10/7) ==> 90.0 and 1.
42857142856141
In the new testing scheme, we compare values against the simple
implementations only if the input arguments contain an infinity or a
NaN. In the common case of two finite arguments, we simply make sure
that the outputs of all three operators (e.g. `euclidean/',
`euclidean-quotient', `euclidean-remainder') equal each other, that
outputs are exact iff both inputs are exact, and that the required
properties of the operator are met: that Q is an integer, that R is
within the specified range, and that N = Q*D + R.
Ludovic Courtès [Sun, 30 Jan 2011 21:47:35 +0000 (22:47 +0100)]
Add `pointer?'.
* libguile/foreign.c (scm_pointer_p): New function.
* libguile/foreign.h (scm_pointer_p): New declaration.
* module/system/foreign.scm: Export `pointer?'.
* test-suite/tests/foreign.test ("null pointer")["pointer?"]: New
test.
("make-pointer")["pointer?"]: New test.
* doc/ref/api-foreign.texi (Foreign Variables): Document `pointer?'.
Ludovic Courtès [Sun, 30 Jan 2011 21:05:21 +0000 (22:05 +0100)]
Remove the "has finalizer?" bit from pointer objects.
* libguile/foreign.h (SCM_POINTER_HAS_FINALIZER): Remove.
* libguile/foreign.c (scm_from_pointer): Store nothing more than
`scm_tc7_pointer' in the type slot.
Ludovic Courtès [Sun, 30 Jan 2011 21:00:35 +0000 (22:00 +0100)]
Add `define-wrapped-pointer-type'.
* module/system/foreign.scm (define-wrapped-pointer-type): New macro.
* doc/ref/api-foreign.texi (Foreign Types): Mention the `*' symbol.
(Void Pointers and Byte Access): Document `define-wrapped-pointer-type'.
* test-suite/tests/foreign.test ("define-wrapped-pointer-type"): New
test prefix.
Mark H Weaver [Sun, 30 Jan 2011 14:52:51 +0000 (09:52 -0500)]
Improve extensibility of core numeric procedures
* libguile/numbers.c (scm_quotient, scm_remainder, scm_modulo,
scm_zero_p, scm_positive_p, scm_negative_p, scm_real_part,
scm_imag_part, scm_numerator, scm_denominator, scm_magnitude,
scm_angle, scm_exact_to_inexact): Change from SCM_GPROC to
SCM_PRIMITIVE_GENERIC. As a side effect, all of these procedures now
have documentation strings.
(scm_exact_p, scm_inexact_p, scm_odd_p, scm_even_p, scm_finite_p,
scm_inf_p, scm_nan_p, scm_expt, scm_inexact_to_exact, scm_log,
scm_log10, scm_exp, scm_sqrt): Change from SCM_DEFINE to
SCM_PRIMITIVE_GENERIC, and make sure the code allows these functions
to be extended in practice.
(scm_real_part, scm_imag_part, scm_numerator, scm_denominator,
scm_inexact_to_exact): Simplify type dispatch code.
(scm_sqrt): Rename formal argument from x to z, since complex numbers
are supported.
(scm_abs): Fix empty FUNC_NAME.
* libguile/numbers.h (scm_finite_p): Add missing prototype.
(scm_inf_p, scm_nan_p): Rename formal parameter from n to x, since
the domain is the real numbers.
* test-suite/tests/numbers.test: Test for documentation strings. Change
from `expect-fail' to `pass-if' for several of these, and add tests
for others. Also add other tests for `real-part' and `imag-part',
which previously had none.
Mark H Weaver [Sun, 30 Jan 2011 13:48:28 +0000 (08:48 -0500)]
Add two new sets of fast quotient and remainder operators
* libguile/numbers.c (scm_euclidean_quo_and_rem, scm_euclidean_quotient,
scm_euclidean_remainder, scm_centered_quo_and_rem,
scm_centered_quotient, scm_centered_remainder): New extensible
procedures `euclidean/', `euclidean-quotient', `euclidean-remainder',
`centered/', `centered-quotient', `centered-remainder'.
* libguile/numbers.h: Add function prototypes.
* module/rnrs/base.scm: Remove incorrect stub implementations of `div',
`mod', `div-and-mod', `div0', `mod0', and `div0-and-mod0'. Instead do
renaming imports of `euclidean-quotient', `euclidean-remainder',
`euclidean/', `centered-quotient', `centered-remainder', and
`centered/', which are equivalent to the R6RS operators.
* module/rnrs/arithmetic/fixnums.scm (fxdiv, fxmod, fxdiv-and-mod,
fxdiv0, fxmod0, fxdiv0-and-mod0): Remove redundant checks for division
by zero and unnecessary complexity.
(fx+/carry): Remove unneeded calls to `inexact->exact'.
* module/rnrs/arithmetic/flonums.scm (fldiv, flmod, fldiv-and-mod,
fldiv0, flmod0, fldiv0-and-mod0): Remove redundant checks for division
by zero and unnecessary complexity. Remove unneeded calls to
`inexact->exact' and `exact->inexact'
* test-suite/tests/numbers.test: (test-eqv?): New internal predicate for
comparing numerical outputs with expected values.
Add extensive test code for `euclidean/', `euclidean-quotient',
`euclidean-remainder', `centered/', `centered-quotient',
`centered-remainder'.
* test-suite/tests/r6rs-arithmetic-fixnums.test: Fix some broken test
cases, and remove `unresolved' test markers for `fxdiv', `fxmod',
`fxdiv-and-mod', `fxdiv0', `fxmod0', and `fxdiv0-and-mod0'.
* test-suite/tests/r6rs-arithmetic-flonums.test: Remove `unresolved'
test markers for `fldiv', `flmod', `fldiv-and-mod', `fldiv0',
`flmod0', and `fldiv0-and-mod0'.
* doc/ref/api-data.texi (Arithmetic): Document `euclidean/',
`euclidean-quotient', `euclidean-remainder', `centered/',
`centered-quotient', and `centered-remainder'.
(Operations on Integer Values): Add cross-references to `euclidean/'
et al, from `quotient', `remainder', and `modulo'.
* doc/ref/r6rs.texi (rnrs base): Improve documentation for `div', `mod',
`div-and-mod', `div0', `mod0', and `div0-and-mod0'. Add
cross-references to `euclidean/' et al.
* NEWS: Add NEWS entry.
Mark H Weaver [Sat, 29 Jan 2011 04:58:02 +0000 (23:58 -0500)]
Add SCM_LIKELY and SCM_UNLIKELY for optimization
* libguile/numbers.c (scm_abs, scm_quotient, scm_remainder, scm_modulo):
Add SCM_LIKELY and SCM_UNLIKELY in several places for optimization.
(scm_remainder): Add comment about C99 "%" semantics.
Strip away a redundant set of braces.
Mark H Weaver [Sun, 30 Jan 2011 03:07:49 +0000 (22:07 -0500)]
Fix GOOPS method compilation bug when no next-method exists
* module/oop/goops/compile.scm (compute-cmethod): Fix a bug
that caused the method compiler to barf while compiling a
method that calls (next-method), if there is no applicable
next method.
Mark H Weaver [Sat, 29 Jan 2011 04:42:01 +0000 (23:42 -0500)]
Implement R6RS `real-valued?', `rational-valued?', `integer-valued?'
* module/rnrs/base.scm (real-valued?, rational-valued?,
integer-valued?): Implement in compliance with R6RS.
* test-suite/tests/r6rs-base.test: Add test cases for
`real-valued?', `rational-valued?', and `integer-valued?'.
* NEWS: Add NEWS entries.
Mark H Weaver [Sat, 29 Jan 2011 04:32:20 +0000 (23:32 -0500)]
Infinities and NaNs are no longer rational
* libguile/numbers.c (scm_rational_p): Return #f for infinities and
NaNs, per R6RS. Previously it returned #t for real infinities
and NaNs. They are still considered real by scm_real `real?'
however, per R6RS. Also simplify the code.
(scm_real_p): New implementation to reflect the fact that the
rationals and reals are no longer the same set. Previously it just
called scm_rational_p.
(scm_integer_p): Simplify the code.
* test-suite/tests/numbers.test: Add test cases for `rational?'
and `real?' applied to infinities and NaNs.
* doc/ref/api-data.texi (Real and Rational Numbers): Update docs to
reflect the fact that infinities and NaNs are no longer rational, and
that `real?' no longer implies `rational?'. Improve discussion of
infinities and NaNs.
* NEWS: Add NEWS entries, and combine with an earlier entry about
infinities no longer being integers.
Mark H Weaver [Sat, 29 Jan 2011 00:57:41 +0000 (19:57 -0500)]
`equal?' and `eqv?' are now equivalent for numbers
Change `equal?' to work like `eqv?' for numbers.
Previously they worked differently in some cases, e.g.
when comparing signed zeroes or NaNs. For example,
(equal? 0.0 -0.0) returned #t but (eqv? 0.0 -0.0)
returned #f, and (equal? +nan.0 +nan.0) returned #f
but (eqv? +nan.0 +nan.0) returned #t.
* libguile/numbers.c (scm_real_equalp, scm_bigequal,
scm_complex_equalp, scm_i_fraction_equalp): Move to eq.c.
* libguile/eq.c (scm_real_equalp): Compare flonums using
real_eqv instead of ==, so that NaNs are now considered
equal, and to distinguish signed zeroes.
(scm_complex_equalp): Compare real and imaginary
components using real_eqv instead of ==, so that NaNs are
now considered equal, and to distinguish signed zeroes.
(scm_bigequal): Use scm_i_bigcmp instead of duplicating it.
(real_eqv): Test for NaNs using isnan(x) instead of
(x != x), and use SCM_UNLIKELY for optimization.
(scm_eqv_p): Use scm_bigequal, scm_real_equalp,
scm_complex_equalp, and scm_i_fraction_equalp to compare
numbers, instead of inline code. Those predicates now do
what scm_eqv_p formerly did internally. Replace if
statements with switch statements, as is done in
scm_equal_p. Remove useless code to check equality of
fractions with different SCM_CELL_TYPEs; this was for a
tentative "lazy reduction bit" which was never developed.
(scm_eqv_p, scm_equal_p): Remove useless code to check
equality between inexact reals and non-real complex numbers
with zero imaginary part. Such numbers do not exist,
because the current code is careful to never create them.
* test-suite/tests/numbers.test: Add test cases for
`eqv?' and `equal?'. Change existing test case for
`(equal? +nan.0 +nan.0)' to expect #t instead of #f.
* NEWS: Add NEWS entries.
Mark H Weaver [Sat, 29 Jan 2011 00:13:47 +0000 (19:13 -0500)]
Remove useless test and fix spelling errors
* test-suite/tests/numbers.test: Remove test for lazy reduction bit of
fractions, which was never implemented. Fix some spelling errors.
Ludovic Courtès [Sat, 29 Jan 2011 22:31:38 +0000 (23:31 +0100)]
Don't remove `standard-library.texi' upon "make clean".
* doc/ref/Makefile.am (CLEANFILES): Rename to...
(DISTCLEANFILES): ... this. So that "make clean" doesn't remove
`standard-library.texi'. Reported by Hans Åberg <haberg-1@telia.com>.
Ludovic Courtès [Sat, 29 Jan 2011 21:28:48 +0000 (22:28 +0100)]
Add missing include for MinGW.
* libguile/ports.h: Include <unistd.h>.
Ludovic Courtès [Sat, 29 Jan 2011 21:26:42 +0000 (22:26 +0100)]
Make `inet-ntop' and `inet-pton' available even when !HAVE_IPV6.
* libguile/socket.c (scm_inet_pton, scm_inet_ntop): Move out of `#ifdef
HAVE_IPV6' and conditionalize the IPv6-specific bits. Reported by
Jan Nieuwenhuizen <janneke@gnu.org>.
Jan Nieuwenhuizen [Sat, 29 Jan 2011 18:51:37 +0000 (19:51 +0100)]
When cross building, run GUILE_FOR_BUILD instead of just-built guile.
* meta/guile.in: Run @GUILE_FOR_BUILD@ when cross-compiling.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Ludovic Courtès [Sat, 29 Jan 2011 20:46:44 +0000 (21:46 +0100)]
Have `srfi-19.test' use the non-deprecated `format' style.
* test-suite/tests/srfi-19.test: Fix all uses of `format' to pass a port
or Boolean as the first argument.
Ludovic Courtès [Sat, 29 Jan 2011 20:24:04 +0000 (21:24 +0100)]
Add a test for `send' and `recv!'.
* test-suite/tests/socket.test ("AF_UNIX/SOCK_STREAM")["bind (bis)",
"listen (bis)", "recv!", "accept (bis)"]: New tests.
Ludovic Courtès [Sat, 29 Jan 2011 20:34:44 +0000 (21:34 +0100)]
Have `recv!', `send', etc. accept a bytevector.
* libguile/socket.c (scm_recv, scm_send, scm_recvfrom, scm_sendto):
Expect the buffer to be a bytevector. Move the string-handling
code under `#if SCM_ENABLE_DEPRECATED == 1' and issue a deprecation
warning.
* test-suite/tests/socket.test ("AF_UNIX/SOCK_DGRAM")["sendto",
"sendto/sockaddr"]: Adjust accordingly.
* doc/ref/posix.texi (Network Sockets and Communication): Update
documentation of `recv!', `send', `recvfrom!', and `sendto'.
Ludovic Courtès [Sat, 29 Jan 2011 15:41:53 +0000 (16:41 +0100)]
Add `-lgc' to `Libs' in `guile-2.0.pc'.
This accounts for the fact that some public Guile macros and inline
functions use libgc functions.
* meta/guile-2.0.pc.in (Libs.private): Move @BDW_GC_LIBS@ to...
(Libs): ... here. Reported by Hans Aberg <haberg-1@telia.com>.
* meta/guile-2.0-uninstalled.pc.in: Likewise.
Andy Wingo [Fri, 28 Jan 2011 16:11:56 +0000 (17:11 +0100)]
update api-evaluation.texi
* doc/ref/api-evaluation.texi (Compilation): Update compile-file and
compiled-file-name docs.
Mark H Weaver [Wed, 26 Jan 2011 10:21:03 +0000 (05:21 -0500)]
Fix bugs when negating SCM_MOST_POSITIVE_FIXNUM+1
* libguile/numbers.c (scm_difference, scm_product):
Fix bugs when negating SCM_MOST_POSITIVE_FIXNUM+1,
aka -SCM_MOST_NEGATIVE_FIXNUM. Previously, these cases
failed to normalize the result to a fixnum, causing
`=', `eqv?' and `equal?' to fail, e.g.:
(= most-negative-fixnum (- 0 (- most-negative-fixnum)))
(= most-negative-fixnum (* -1 (- most-negative-fixnum)))
(= most-negative-fixnum (* (- most-negative-fixnum) -1))
* test-suite/test/numbers.test: Add test cases to detect
bugs when negating SCM_MOST_POSITIVE_FIXNUM+1 and
SCM_MOST_NEGATIVE_FIXNUM by various methods.
Mark H Weaver [Fri, 28 Jan 2011 12:51:37 +0000 (13:51 +0100)]
note inf? / nan? domain in NEWS
* NEWS: Add NEWS entry.
Andy Wingo [Wed, 26 Jan 2011 09:34:55 +0000 (04:34 -0500)]
domain of inf?, finite?, nan? is the real numbers
* libguile/numbers.c (scm_inf_p, scm_finite_p, scm_nan_p): The domain of
these functions is the real numbers. Error on other input.
* doc/ref/api-data.texi (Reals and Rationals): Update the documentation
accordingly.
* test-suite/tests/numbers.test ("finite?", "inf?"): Update tests.
Mark H Weaver [Wed, 26 Jan 2011 07:50:03 +0000 (02:50 -0500)]
Remove useless code from do_divide
* libguile/numbers.c (do_divide): Remove code which handled a case
that never occurs: a zero bignum.
Mark H Weaver [Wed, 26 Jan 2011 14:36:05 +0000 (09:36 -0500)]
Optimize scm_exact_p by making use of SCM_INEXACTP
* libguile/numbers.c (scm_exact_p): Optimize by making use of the
SCM_INEXACTP macro.
(scm_inexact_p): Move it next to scm_exact_p, and add else's.
* test-suite/tests/numbers.test: Add test cases for `exact?'
and `inexact?' applied to infinities and NaNs.
Mark H Weaver [Wed, 26 Jan 2011 14:34:02 +0000 (09:34 -0500)]
Implement `finite?' in core and fix R6RS `finite?' and `infinite?'
* libguile/numbers.c (scm_finite_p): Add new predicate `finite?' from
R6RS to guile core, which returns #t if and only if its argument is
neither infinite nor a NaN. Note that this is not the same as (not
(inf? x)) or (not (infinite? x)), since NaNs are neither finite nor
infinite.
* test-suite/tests/numbers.test: Add test cases for `finite?'.
* module/rnrs/base.scm: Import `inf?' as `infinite?' instead of
reimplementing it. Previously, the R6RS implementation of
`infinite?' did not detect non-real complex infinities, nor did it
throw exceptions for non-numbers. (Note that NaNs _are_ considered
numbers by scheme, despite their name).
Import `finite?' instead of reimplementing it. Previously, the R6RS
implementation of `finite?' returned #t for both NaNs and non-real
complex infinities, in violation of R6RS.
* NEWS: Add NEWS entries, and reorganize existing numerics-related
entries together under one subheading.
* doc/ref/api-data.texi (Real and Rational Numbers): Add docs for
`finite?' and scm_finite_p.
Mark H Weaver [Tue, 25 Jan 2011 23:58:47 +0000 (18:58 -0500)]
Add SCM_INUM1 to numbers.h, and make use of it and SCM_INUM0 in numbers.c
* libguile/numbers.h: Add SCM_INUM1, a name for the fixnum 1. This is
analogous to SCM_INUM0, a name for 0, which already existed.
* libguile/numbers.c: Change occurrences of SCM_I_MAKINUM (0) and
SCM_I_MAKINUM (1) to SCM_INUM0 and SCM_INUM1, respectively.
Mark H Weaver [Tue, 25 Jan 2011 23:53:36 +0000 (18:53 -0500)]
Fix NEWS entry regarding changes to `expt' for zero base
NEWS: Fix NEWS entry regarding changes to `expt' when base is zero
Mark H Weaver [Tue, 25 Jan 2011 23:35:22 +0000 (18:35 -0500)]
Do not apply `inf?' or `nan?' to strings
* module/ice-9/format.scm (format): Test to make sure an argument is a
number before applying `inf?' and `nan?' to it. Formerly, format
would call `inf?' and `nan?' on arguments that might be either a
number or a string, although those predicates should ideally throw an
exception when applied to non-number objects.
Mark H Weaver [Tue, 25 Jan 2011 23:29:47 +0000 (18:29 -0500)]
Fix incorrect FUNC_NAME for scm_current_processor_count
* libguile/posix.c (scm_current_processor_count):
Fix incorrect FUNC_NAME (was s_scm_total_processor_count)
Andy Wingo [Thu, 27 Jan 2011 17:18:10 +0000 (18:18 +0100)]
fix guile-tools getopt
* meta/guile-tools.in (getopt): Define a local version of getopt that
stops parsing options when it sees a non-option.
Andy Wingo [Thu, 27 Jan 2011 12:13:23 +0000 (13:13 +0100)]
fix THANKS
* THANKS: Fix.
Andy Wingo [Thu, 27 Jan 2011 12:11:02 +0000 (13:11 +0100)]
for mmap objcodes, store the fd in the third word, as a scheme int
This leaves space for native code.
* libguile/objcodes.h (SCM_OBJCODE_NATIVE_CODE)
(SCM_SET_OBJCODE_NATIVE_CODE): Reserve the fourth word of objcode for
"native code", whatever that means.
* libguile/objcodes.c: Update a comment.
(make_objcode_by_mmap): Put the fd in the third word.
Andy Wingo [Thu, 27 Jan 2011 11:44:53 +0000 (12:44 +0100)]
objcode type is an enumeration, not flags
* libguile/objcodes.h (SCM_OBJCODE_TYPE_MMAP)
(SCM_OBJCODE_TYPE_BYTEVECTOR, SCM_OBJCODE_TYPE_SLICE)
(SCM_OBJCODE_TYPE_STATIC): Enumerate objcode types instead of
expressing them as flags.
(SCM_OBJCODE_TYPE): Type is held in bits 8-15.
(SCM_OBJCODE_FLAGS): Flags are now shifted by 16 bits, not 8.
(SCM_MAKE_OBJCODE_TAG): New helper.
* libguile/continuations.c (STATIC_OBJCODE_TAG):
* libguile/control.c (STATIC_OBJCODE_TAG):
* libguile/foreign.c (STATIC_OBJCODE_TAG):
* libguile/gsubr.c (STATIC_OBJCODE_TAG):
* libguile/smob.c (STATIC_OBJCODE_TAG):
* libguile/objcodes.c (make_objcode_by_mmap, scm_c_make_objcode_slice)
(scm_bytecode_to_objcode): : Use SCM_MAKE_OBJCODE_TAG.
Andy Wingo [Thu, 27 Jan 2011 10:24:22 +0000 (11:24 +0100)]
guile-tools gracefully errors for missing scripts
* meta/guile-tools.in (find-script): Use the #:ensure arg of
resolve-module.
(main): Display a comprehensible error message if we don't find a
script.
Andy Wingo [Thu, 27 Jan 2011 10:15:01 +0000 (11:15 +0100)]
guile-tools uses getopt-long
* meta/guile-tools.in: Use getopt-long.
Andy Wingo [Thu, 27 Jan 2011 09:57:18 +0000 (10:57 +0100)]
guile-tools uses srfi-1
* meta/guile-tools.in (guile-tools): Use srfi-1 here, now that we can.
Andy Wingo [Thu, 27 Jan 2011 09:49:51 +0000 (10:49 +0100)]
fix error handling in variable-ref family of instructions
* libguile/vm-i-system.c (variable-ref, variable-set, variable-bound?):
Check that the argument is actually a variable. Thanks to Kevin
Holmes for the report.
* libguile/vm-engine.c (vm_engine): Error handling down here.
* THANKS: Update.
Ludovic Courtès [Wed, 26 Jan 2011 23:16:54 +0000 (00:16 +0100)]
Use `scm_from_latin1_stringn' in `objcodes.c'.
* libguile/objcodes.c (make_objcode_by_mmap): Use
`scm_from_latin1_stringn', not `scm_from_locale_stringn', to display
the invalid cookie in the error case.
Ludovic Courtès [Wed, 26 Jan 2011 23:15:58 +0000 (00:15 +0100)]
Fix buffer overflow in `read-line'.
* libguile/rdelim.c (SCM_DEFINE): Compare INDEX to LINE_BUFFER_SIZE, not
`sizeof (buf)'.
Ludovic Courtès [Wed, 26 Jan 2011 22:45:13 +0000 (23:45 +0100)]
Add ECMAScript parser tests.
* test-suite/tests/ecmascript.test ("parser"): Add parser tests for the
previous fixes.
Noah Lavine [Tue, 11 Jan 2011 22:58:34 +0000 (17:58 -0500)]
Parse Decimal Numbers
* module/language/ecmascript/parse.scm: handle numbers with leading
decimals correctly.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Noah Lavine [Tue, 11 Jan 2011 23:03:04 +0000 (18:03 -0500)]
Fix Hex Constants
* module/language/ecmascript/tokenize.scm: hexadecimal constants can
now use 'X' in addition to 'x'.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Noah Lavine [Tue, 11 Jan 2011 22:41:21 +0000 (17:41 -0500)]
Ecmascript Syntax
* module/language/ecmascript/tokenize.scm: an unbreakable space
counts as whitespace.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Noah Lavine [Tue, 11 Jan 2011 22:29:09 +0000 (17:29 -0500)]
Ecmascript Syntax Fix
* module/language/ecmascript/parse.scm: allow empty function bodies.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Ludovic Courtès [Wed, 26 Jan 2011 22:02:41 +0000 (23:02 +0100)]
Add a `read-line' benchmark.
* benchmark-suite/benchmarks/ports.bm ("rdelim"): New benchmark prefix.
Ludovic Courtès [Wed, 26 Jan 2011 21:59:45 +0000 (22:59 +0100)]
Tweak `read-line'.
* libguile/rdelim.c (LINE_BUFFER_SIZE): Set to 1 KiB instead of 4 KiB.
(scm_read_line): Initialize STRING to #f so we actually use the fast
path.
Andy Wingo [Wed, 26 Jan 2011 21:09:06 +0000 (22:09 +0100)]
more sensible error if compiled-file-name returns false in compile-file
* module/system/base/compile.scm (compile-file): Error if no output-file
is given and compiled-file-name returns false.
Andy Wingo [Wed, 26 Jan 2011 20:48:20 +0000 (21:48 +0100)]
fix THANKS
* THANKS: Fix Hans' surname.
Andy Wingo [Wed, 26 Jan 2011 20:44:12 +0000 (21:44 +0100)]
fix error-handling of apply to non-list
* libguile/vm-engine.c (vm_error_apply_to_non_list): Sync registers
before erroring. Fix type of finish_args. Thanks to Hans Aberg for
the report.
Andy Wingo [Wed, 26 Jan 2011 19:40:07 +0000 (20:40 +0100)]
update README for copyright year ranges
* README: Add note about copyright year ranges. Remove reference to
guile-tut.info.
Andy Wingo [Wed, 26 Jan 2011 19:13:16 +0000 (20:13 +0100)]
fix format ~f documentation for width combined with overflowchar
* doc/ref/misc-modules.texi (Formatted Output): Adapt ~f documentation
to indicate that the output will always have a decimal point. Thanks
to Fu-gangqiang for the report.
* THANKS: Update.
Julian Graham [Wed, 26 Jan 2011 08:32:48 +0000 (03:32 -0500)]
Additional documentation for symbol manipulation functions.
* doc/ref/api-data.texi (Symbol Primitives): Document `symbol',
`list->symbol', and `symbol-append'.
Ludovic Courtès [Tue, 25 Jan 2011 23:24:34 +0000 (00:24 +0100)]
Rewrite `read-line' in terms of `scm_getc'.
As a result `read-line' handles decoding and decoding errors the same
way as `scm_getc'. It's also simpler and free of `malloc' calls.
* libguile/rdelim.c (scm_do_read_line): Remove.
(scm_read_line): Rewrite as a loop that calls `scm_getc'.
* test-suite/tests/rdelim.test: New file.
* test-suite/Makefile.am (SCM_TESTS): Add `tests/rdelim.test'.
Ludovic Courtès [Tue, 25 Jan 2011 23:16:10 +0000 (00:16 +0100)]
Have `scm_getc' honor the port's conversion strategy.
* libguile/ports.c (get_codepoint): Reset `pt->input_cd' upon failure.
If `pt->ilseq_handler' is `SCM_ICONVEH_QUESTION_MARK', then return a
question mark.
[failure]: Use `scm_encoding_error' when raising an error.
* test-suite/lib.scm (exception:encoding-error): Adjust regexp.
* test-suite/tests/ports.test ("string ports")["read-char, wrong
encoding, error", "read-char, wrong encoding, escape", "read-char,
wrong encoding, substitute"]: New tests.
Ludovic Courtès [Tue, 25 Jan 2011 23:05:27 +0000 (00:05 +0100)]
Test substitution and escaping on port output.
* test-suite/tests/ports.test ("string ports")["wrong encoding,
substitute", "wrong encoding, escape"]: New tests.
Ludovic Courtès [Tue, 25 Jan 2011 22:36:35 +0000 (23:36 +0100)]
Add `scm_{to,from}_utf32_string'.
* libguile/strings.c (scm_from_utf32_string, scm_from_utf32_stringn,
scm_to_utf32_string, scm_to_utf32_stringn): New functions.
* libguile/strings.h (scm_from_utf32_string, scm_from_utf32_stringn,
scm_to_utf32_string, scm_to_utf32_stringn): New declarations.
* doc/ref/api-data.texi (Conversion to/from C): Document
`scm_{to,from}_{utf8,utf32}_stringn'.
Ludovic Courtès [Tue, 25 Jan 2011 22:24:36 +0000 (23:24 +0100)]
Optimize `scm_{to,from}_latin1_string'.
* libguile/strings.c (scm_from_latin1_stringn): Directly return a narrow
string instead of going through `scm_from_stringn'.
(scm_to_latin1_stringn): Directly return a copy of STR's raw bytes when
it's narrow.
Andy Wingo [Tue, 25 Jan 2011 16:59:45 +0000 (17:59 +0100)]
stexi->shtml supports itemx
* module/texinfo/html.scm (entry, rules): Allow @itemx,
Ludovic Courtès [Mon, 24 Jan 2011 22:37:46 +0000 (23:37 +0100)]
Install the current locale when starting the REPL.
* module/ice-9/top-repl.scm (top-repl): Install the current locale.
Ludovic Courtès [Mon, 24 Jan 2011 22:13:03 +0000 (23:13 +0100)]
Remove useless branches in the port code.
* libguile/ports.c (scm_i_get_port_encoding): Remove useless `if'.
(scm_set_port_encoding_x): Remove redundant `find_valid_encoding'
call.
Ludovic Courtès [Mon, 24 Jan 2011 22:11:21 +0000 (23:11 +0100)]
Always initialize a port's encoding name.
* libguile/ports.c (scm_i_set_port_encoding_x): Always initialize
PT->encoding to something non-NULL. This fixes callers of
`scm_encoding_error' such that they always pass a non-NULL encoding
name. Reported by Matei Conovici.
Andy Wingo [Mon, 24 Jan 2011 21:48:26 +0000 (22:48 +0100)]
update the man page
* doc/guile.1: Update a bit.
Ludovic Courtès [Mon, 24 Jan 2011 20:44:44 +0000 (21:44 +0100)]
Choose the input source file encoding in a locale-independent way.
This is so that compiling the same code on environments with different
locale settings yields the same result.
* module/system/base/compile.scm (compile-file): When ENC if #f, default
to "UTF-8" instead of `(fluid-ref %default-port-encoding)'.
* doc/ref/api-evaluation.texi (Compilation): Document the default output
file name and default source file encoding for `compile-file' and
`guile-tools compile'.
Ludovic Courtès [Sun, 23 Jan 2011 22:43:50 +0000 (23:43 +0100)]
Remove unexpected non-ASCII character.
* module/language/tree-il/fix-letrec.scm: Replace U+2019 with an ASCII
quote. The iconv implementation on FreeBSD would immediately notice
and bail out when reading it under a US-ASCII locale.
Ludovic Courtès [Sun, 23 Jan 2011 00:26:07 +0000 (01:26 +0100)]
Rewrite `scm_lfwrite_substr' in terms of `scm_display'.
* libguile/ports.c (scm_lfwrite_substr): Rewrite in terms of
`scm_display'.
Ludovic Courtès [Sun, 23 Jan 2011 00:14:51 +0000 (01:14 +0100)]
Remove `scm_lfwrite_str'.
* libguile/ports.c (scm_lfwrite_str): Remove.
* libguile/ports.h (scm_lfwrite_str): Remove declaration.
* libguile/numbers.c (scm_i_print_fraction): Use `scm_display' instead
of `scm_lfwrite_str'.
Ludovic Courtès [Sat, 22 Jan 2011 23:20:07 +0000 (00:20 +0100)]
Augment `THANKS'.
Ludovic Courtès [Sat, 22 Jan 2011 23:13:27 +0000 (00:13 +0100)]
Hide the string escaping hacks.
* libguile/strings.c (scm_i_unistring_escapes_to_guile_escapes): Rename
to...
(unistring_escapes_to_guile_escapes): ... this. Make `static'.
(scm_i_unistring_escapes_to_r6rs_escapes): Rename to...
(unistring_escapes_to_r6rs_escapes): ... this. Make `static'.
* libguile/strings.h (scm_i_unistring_escapes_to_guile_escapes,
scm_i_unistring_escapes_to_r6rs_escapes): Remove declarations.
Ludovic Courtès [Sat, 22 Jan 2011 23:18:27 +0000 (00:18 +0100)]
Rewrite `read-char', `display', etc. using iconv calls instead of libunistring.
Thanks to Bruno Haible for his suggestions. See
<http://lists.gnu.org/archive/html/bug-libunistring/2010-09/msg00007.html>,
for details.
* libguile/ports.c (register_finalizer_for_port): Always register a
finalizer for PORT.
(finalize_port): Close ENTRY->input_cd and ENTRY->output_cd.
(scm_new_port_table_entry): Initialize the `input_cd' and `output_cd'
fields.
(utf8_to_codepoint): New function.
(get_codepoint): Rewrite to use `iconv' instead of libunistring.
(scm_i_set_port_encoding_x): Initialize the `input_cd' and `output_cd'
fields.
(update_port_lf): Move upward. Use `switch' instead of `if's.
* libguile/ports.h (scm_t_port)[input_cd, output_cd]: New fields.
* libguile/print.c (codepoint_to_utf8, display_string): New functions.
(display_character): Use `display_string'.
(write_combining_character): Likewise.
(iprin1): Use `display_string' instead of `scm_lfwrite_str', and
`display_character' instead of `scm_putc'.
(write_character): Likewise.
(write_character_escaped): New function.
* test-suite/tests/encoding-escapes.test ("display output
escapes")["Rashomon"]: Use lower-case escapes.
["fake escape"]: New test.
Andy Wingo [Sat, 22 Jan 2011 23:06:24 +0000 (00:06 +0100)]
infinities are no longer integers
* libguile/numbers.c (scm_is_integer): Infinities are not integers, per
the R6RS.
(scm_even_p, scm_odd_p): Passing an infinity to even? or odd? is an
error.
* test-suite/tests/numbers.test ("integer?"): Adapt test.
("expt"): Add tests for +inf.0 and -inf.0 exponents.
* NEWS: Add NEWS entries.
Andy Wingo [Sat, 22 Jan 2011 18:56:23 +0000 (19:56 +0100)]
web.texi fix
* doc/ref/web.texi (HTTP Headers): Fix transfer-encoding example.
Andy Wingo [Sat, 22 Jan 2011 18:55:31 +0000 (19:55 +0100)]
scm_with_guile calls GC_call_with_gc_active
* configure.ac: Check for GC_call_with_gc_active.
* libguile/threads.h (scm_i_thread): Remove "top", as it's not used.
* libguile/threads.c (with_gc_inactive, with_gc_active): Define shims to
GC_do_blocking and GC_call_with_gc_active.
(scm_i_init_thread_for_guile): Don't do thread base adjustment here,
do it in scm_i_with_guile_and_parent. The previous logic would never
be run.
(scm_i_with_guile_and_parent): If we enter Guile mode, leave it too.
Take care of adjusting the thread stack base here too. Also, call
with_gc_active.
(scm_without_guile): Refactor.
Andy Wingo [Fri, 21 Jan 2011 08:23:06 +0000 (09:23 +0100)]
update NEWS for hungry-eol-escapes
* NEWS: Update for hungry-eol-escapes.