bpt/guile.git
10 years agoCommon numeric operations are left-to-right associative.
Mark H Weaver [Mon, 12 Aug 2013 23:40:32 +0000 (19:40 -0400)]
Common numeric operations are left-to-right associative.

* module/language/tree-il/primitives.scm (define-primitive-expander):
  Use 'match-lambda*' instead of 'case-lambda' for pattern matching.
  (*primitive-expand-table*): In primitive expanders for '+', '*', '-',
  '/', 'logior', and 'logand', assume conventional left-to-right
  associativity.

10 years agoNumerical comparisons are not negatable.
Mark H Weaver [Mon, 12 Aug 2013 22:08:59 +0000 (18:08 -0400)]
Numerical comparisons are not negatable.

* module/language/tree-il/primitives.scm (*negatable-primitives*):
  Remove (< <= > >=) from the list of negatable primitives.

10 years agoBroken Turkish UTF-8 locale still unresolved in FreeBSD 9.1.
Mark H Weaver [Mon, 12 Aug 2013 02:38:49 +0000 (22:38 -0400)]
Broken Turkish UTF-8 locale still unresolved in FreeBSD 9.1.

* test-suite/tests/i18n.test (under-turkish-utf8-locale-or-unresolved):
  Disable tests of Turkish UTF-8 locale in FreeBSD 9.1.

10 years agoFix inappropriate uses of scm_syserror in numbers.c.
Mark H Weaver [Sat, 10 Aug 2013 15:47:54 +0000 (11:47 -0400)]
Fix inappropriate uses of scm_syserror in numbers.c.

* libguile/numbers.c (mem2ureal, left_shift_exact_integer,
  floor_right_shift_exact_integer, round_right_shift_exact_integer):
  Use 'assert' instead of 'scm_syserror' to indicate a case that should
  never happen.

10 years agodereference-pointer: check for null pointer.
Mark H Weaver [Fri, 9 Aug 2013 22:23:56 +0000 (18:23 -0400)]
dereference-pointer: check for null pointer.

* libguile/foreign.c (scm_dereference_pointer): Check for attempts to
  dereference a null pointer.

* test-suite/tests/foreign.test ("null pointer"): Add test.

10 years agoFix numerator and denominator handling of signed zeroes and infinities.
Mark H Weaver [Fri, 9 Aug 2013 09:32:23 +0000 (05:32 -0400)]
Fix numerator and denominator handling of signed zeroes and infinities.

* libguile/numbers.c (scm_numerator, scm_denominator): Handle signed
  zeroes and infinities in accordance with the corresponding R6RS flonum
  procedures.

* module/rnrs/arithmetic/flonums.scm (flnumerator, fldenominator):
  Remove special handling of infinities.

* test-suite/tests/numbers.test (numerator, denominator): Add tests.
  Convert existing tests to use 'pass-if-equal'.

* test-suite/tests/r6rs-arithmetic-flonums.test (flnumerator): Fix
  broken test of (flnumerator -0.0).

10 years agoDecompiler: fix handling of empty 'case-lambda' expressions.
Mark H Weaver [Wed, 7 Aug 2013 09:54:15 +0000 (05:54 -0400)]
Decompiler: fix handling of empty 'case-lambda' expressions.

* module/language/scheme/decompile-tree-il.scm (choose-output-names):
  A <lambda> with no <lambda-case> decompiles into a 'case-lambda'
  primitive.  Ensure that 'case-lambda' is not shadowed by a lexical.

10 years agoFix display of symbols containing backslashes.
David Kastrup [Tue, 6 Aug 2013 22:01:54 +0000 (18:01 -0400)]
Fix display of symbols containing backslashes.

Fixes <http://bugs.gnu.org/15033>.

* libguile/print.c (print_extended_symbol): Double print backslashes.

Signed-off-by: Mark H Weaver <mhw@netris.org>
10 years agoAdd files from 'copysign' and 'isfinite' Gnulib modules.
Mark H Weaver [Tue, 6 Aug 2013 21:16:04 +0000 (17:16 -0400)]
Add files from 'copysign' and 'isfinite' Gnulib modules.

* lib/copysign.c:
* lib/isfinite.c:
* lib/isnanf-nolibm.h:
* lib/isnanl-nolibm.h:
* lib/signbitd.c:
* lib/signbitf.c:
* lib/signbitl.c:
* m4/copysign.m4:
* m4/isfinite.m4:
* m4/signbit.m4: New files.

10 years agoVM: ash: Use SCM_SRS and handle large right shift in fast path.
Mark H Weaver [Tue, 6 Aug 2013 20:38:32 +0000 (16:38 -0400)]
VM: ash: Use SCM_SRS and handle large right shift in fast path.

* libguile/vm-i-scheme.c (ash): Use SCM_SRS.  Handle inum right shift by
  more than SCM_I_FIXNUM_BIT-1 bits in fast path.

10 years agoUse Gnulib's 'isfinite' in numbers.c.
Mark H Weaver [Tue, 6 Aug 2013 20:26:46 +0000 (16:26 -0400)]
Use Gnulib's 'isfinite' in numbers.c.

* libguile/numbers.c (DOUBLE_IS_FINITE, DOUBLE_IS_POSITIVE_INFINITY,
  DOUBLE_IS_NEGATIVE_INFINITY): Remove.
  (scm_odd_p, scm_even_p, scm_finite_p, icmplx2str, scm_rational_p,
  scm_inexact_to_exact): Use 'isfinite' instead of 'DOUBLE_IS_FINITE'.

10 years agoUse Gnulib's 'copysign' in numbers.c.
Mark H Weaver [Tue, 6 Aug 2013 20:21:26 +0000 (16:21 -0400)]
Use Gnulib's 'copysign' in numbers.c.

* libguile/numbers.c (double_is_non_negative_zero): Remove.
  (idbl2str, scm_max, scm_min, scm_angle, log_of_shifted_double,
  scm_log10): Use 'copysign' to check signs of zeroes,
  instead of 'double_is_non_negative_zero'.

10 years agoImport 'copysign' and 'isfinite' modules from Gnulib.
Mark H Weaver [Tue, 6 Aug 2013 19:56:32 +0000 (15:56 -0400)]
Import 'copysign' and 'isfinite' modules from Gnulib.

* lib/Makefile.am:
* m4/gnulib-cache.m4:
* m4/gnulib-comp.m4: Add 'copysign' and 'isfinite' Gnulib modules.

10 years agoVM: ASM_ADD and ASM_SUB for x86: clobber _CX not "rcx".
Mark H Weaver [Sun, 4 Aug 2013 23:39:43 +0000 (19:39 -0400)]
VM: ASM_ADD and ASM_SUB for x86: clobber _CX not "rcx".

* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB): Clobber _CX not "rcx".

10 years agoVM: Define ASM_MUL on ARM only if SMULL instruction is supported.
Mark H Weaver [Sun, 4 Aug 2013 22:01:52 +0000 (18:01 -0400)]
VM: Define ASM_MUL on ARM only if SMULL instruction is supported.

* libguile/vm-i-scheme.c (ASM_MUL): Define only if the target
  architecture is known to implement the SMULL instruction.

10 years agoVM: Implement ASM_ADD, ASM_SUB, and ASM_MUL for ARM processors.
Mark H Weaver [Fri, 2 Aug 2013 00:31:21 +0000 (20:31 -0400)]
VM: Implement ASM_ADD, ASM_SUB, and ASM_MUL for ARM processors.

* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB, ASM_MUL): Implement for ARM.

10 years agoVM: Avoid untagging inums in 'logand' and 'logior'.
Mark H Weaver [Thu, 1 Aug 2013 19:31:39 +0000 (15:31 -0400)]
VM: Avoid untagging inums in 'logand' and 'logior'.

* libguile/vm-i-scheme.c (logand, logior): Avoid untagging.

10 years agoVM: Add ASM_MUL for x86.
Mark H Weaver [Sat, 3 Aug 2013 19:05:59 +0000 (15:05 -0400)]
VM: Add ASM_MUL for x86.

* libguile/vm-i-scheme.c (ASM_MUL): New macro.
  (mul): Use ASM_MUL if available.

10 years agoVM: Support 32-bit x86 in ASM_ADD and ASM_SUB.
Mark H Weaver [Sat, 3 Aug 2013 18:58:28 +0000 (14:58 -0400)]
VM: Support 32-bit x86 in ASM_ADD and ASM_SUB.

* libguile/vm-i-scheme.c (_CX): New macro.
  (ASM_ADD, ASM_SUB): Replace references to "rcx" with _CX.

10 years agoVM: Add "cc" to the clobber list of ASM_ADD and ASM_SUB.
Mark H Weaver [Sat, 3 Aug 2013 18:59:54 +0000 (14:59 -0400)]
VM: Add "cc" to the clobber list of ASM_ADD and ASM_SUB.

* libguile/vm-i-scheme.c (ASM_ADD, ASM_SUB): Add "cc" to the clobber
  list.  Suggested by Göran Weinholt <goran@weinholt.se>.

10 years agoVM: Avoid overflow in ASM_ADD when the result is most-positive-fixnum.
Mark H Weaver [Sat, 3 Aug 2013 18:51:07 +0000 (14:51 -0400)]
VM: Avoid overflow in ASM_ADD when the result is most-positive-fixnum.

* libguile/vm-i-scheme.c (ASM_ADD): Remove the tag from one of the
  operands before adding, to avoid overflow when the result is the most
  positive fixnum.

10 years agoVM: Avoid signed overflows in 'add1' and 'sub1'.
Mark H Weaver [Sat, 3 Aug 2013 18:46:40 +0000 (14:46 -0400)]
VM: Avoid signed overflows in 'add1' and 'sub1'.

* libguile/vm-i-scheme.c (INUM_STEP): New macro.
  (add1, sub1): Avoid signed overflows, and use INUM_STEP.

10 years agoVM: Redefine INUM_MIN and INUM_MAX without assumptions.
Mark H Weaver [Thu, 1 Aug 2013 18:01:58 +0000 (14:01 -0400)]
VM: Redefine INUM_MIN and INUM_MAX without assumptions.

* libguile/vm-i-scheme.c (INUM_MIN, INUM_MAX): Redefine to avoid
  assumptions about the representation of inums.

10 years agoAdd 'scm_i_from_double' and use it.
Mark H Weaver [Thu, 1 Aug 2013 17:50:41 +0000 (13:50 -0400)]
Add 'scm_i_from_double' and use it.

* libguile/numbers.c (scm_i_from_double): New static function.
  (scm_from_double): Just call 'scm_i_from_double'.
  (scm_inf, scm_nan, scm_abs, scm_i_inexact_floor_quotient,
  scm_i_inexact_floor_remainder, scm_i_inexact_floor_divide,
  scm_i_inexact_ceiling_quotient, scm_i_inexact_ceiling_remainder,
  scm_i_inexact_ceiling_divide, scm_i_inexact_truncate_quotient,
  scm_i_inexact_truncate_remainder, scm_i_inexact_truncate_divide,
  scm_i_inexact_centered_quotient, scm_i_inexact_centered_remainder,
  scm_i_inexact_centered_divide, scm_i_inexact_round_quotient,
  scm_i_inexact_round_remainder, scm_i_inexact_round_divide,
  scm_max, scm_min, scm_sum, scm_difference, scm_product,
  scm_divide, scm_truncate_number, scm_round_number, scm_floor,
  scm_ceiling, scm_expt, scm_sin, scm_cos, scm_tan, scm_sinh,
  scm_cosh, scm_tanh, scm_asin, scm_acos, scm_atan, scm_sys_asinh,
  scm_sys_acosh, scm_sys_atanh, scm_real_part, scm_imag_part,
  scm_magnitude, scm_angle, scm_exact_to_inexact, log_of_shifted_double,
  log_of_fraction, scm_log10, scm_exp, scm_sqrt, scm_init_numbers):
  Use 'scm_i_from_double' instead of 'scm_from_double'.

10 years agoOptimize R6RS bitwise operators.
Mark H Weaver [Sun, 21 Jul 2013 14:00:48 +0000 (10:00 -0400)]
Optimize R6RS bitwise operators.

* module/rnrs/arithmetic/bitwise.scm (bitwise-if, bitwise-length,
  bitwise-first-bit-set, bitwise-bit-field, bitwise-reverse-bit-field):
  Replace these with aliases to the identical SRFI-60 operators
  'bitwise-if', 'integer-length', 'first-set-bit', 'bit-field', and
  'reverse-bit-field'.

  (bitwise-copy-bit, bitwise-copy-bit-field, bitwise-rotate-bit-field):
  Reimplement these based upon the similar SRFI-60 operators 'copy-bit',
  'copy-bit-field', and 'rotate-bit-field'.

* test-suite/tests/r6rs-arithmetic-bitwise.test (bitwise-copy-bit): Fix
  test to conform to the specification, which requires the third
  argument to be either 0 or 1.

* test-suite/tests/r6rs-arithmetic-fixnums.test (fxcopy-bit): Fix test
  to conform to the specification, which requires the third argument to
  be either 0 or 1.

10 years agoFix incorrect rationalize tests.
Mark H Weaver [Sun, 21 Jul 2013 12:09:46 +0000 (08:09 -0400)]
Fix incorrect rationalize tests.

* test-suite/tests/fractions.test (fractions): Fix rationalize tests.

10 years agoFix minor formatting error in 'rationalize'.
Mark H Weaver [Sun, 21 Jul 2013 11:20:03 +0000 (07:20 -0400)]
Fix minor formatting error in 'rationalize'.

* libguile/numbers.c (scm_rationalize): Fix formatting.

10 years agoRewrite 'rationalize' to fix bugs and improve efficiency.
Mark H Weaver [Sat, 20 Jul 2013 16:29:02 +0000 (12:29 -0400)]
Rewrite 'rationalize' to fix bugs and improve efficiency.

Fixes <http://bugs.gnu.org/14905>.
Reported by Göran Weinholt <goran@weinholt.se>.

* libguile/numbers.c (scm_rationalize): Rewrite.  Previously an
  incorrect algorithm was used which failed in many cases.

* test-suite/tests/numbers.test (rationalize): Add tests.

10 years agoModify SCM_UNPACK type check to avoid warnings in clang.
Mark H Weaver [Thu, 18 Jul 2013 18:10:43 +0000 (14:10 -0400)]
Modify SCM_UNPACK type check to avoid warnings in clang.

* libguile/tags.h (SCM_UNPACK): Change (*(SCM*)0=(x)) to
  (*(volatile SCM *)0=(x)), to avoid null-dereference warnings
  from clang.  Reported by Shane Celis <shane.celis@gmail.com>.

10 years agoFix 'SCM_SYSCALL' to really swallow EINTR.
Ludovic Courtès [Wed, 17 Jul 2013 15:57:43 +0000 (17:57 +0200)]
Fix 'SCM_SYSCALL' to really swallow EINTR.

* libguile/_scm.h (SCM_SYSCALL): Keep looping upon EINTR.
  Reported at
  <http://lists.gnu.org/archive/html/guile-devel/2013-06/msg00050.html>.

10 years agobuild: Add `gdbinit' to the distribution.
Ludovic Courtès [Wed, 17 Jul 2013 13:11:51 +0000 (15:11 +0200)]
build: Add `gdbinit' to the distribution.

* Makefile.am (EXTRA_DIST): Add gdbinit.

10 years agoAdd support for HTTP proxies.
Mark H Weaver [Fri, 7 Jun 2013 04:47:33 +0000 (00:47 -0400)]
Add support for HTTP proxies.

* module/web/http.scm (http-proxy-port?, set-http-proxy-port?!): New
  exported procedures.
  (write-request-line): If we're using an http proxy, write an
  absolute-URI in the request line.

* module/web/client.scm: Import (web http).
  (current-http-proxy): New exported parameter.
  (open-socket-for-uri): If 'current-http-proxy' is not false,
  connect to the proxy instead of the URI host, and use
  'set-http-proxy-port?!' to make note of that fact.

* doc/ref/web.texi (Web Client): Document 'current-http-proxy'.

10 years agoFix R6RS 'fixnum-width'.
Mark H Weaver [Tue, 16 Jul 2013 21:38:14 +0000 (17:38 -0400)]
Fix R6RS 'fixnum-width'.

Fixes <http://bugs.gnu.org/14879>.
Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/fixnums.scm (fixnum-width): Rewrite to avoid
  inexact arithmetic, and correct the off-by-one error.

* test-suite/tests/r6rs-arithmetic-fixnums.test (fixnum-width): Add
  tests.

10 years agoUpdate copyright dates of recently-changed R6RS bitwise/flonums files.
Mark H Weaver [Tue, 16 Jul 2013 16:12:25 +0000 (12:12 -0400)]
Update copyright dates of recently-changed R6RS bitwise/flonums files.

* module/rnrs/arithmetic/bitwise.scm:
  module/rnrs/arithmetic/flonums.scm:
  test-suite/tests/r6rs-arithmetic-bitwise.test:
  test-suite/tests/r6rs-arithmetic-flonums.test: Add 2013 to the
  copyright dates.

10 years agoFix 'fxbit-count' for negative arguments.
Mark H Weaver [Tue, 16 Jul 2013 16:06:45 +0000 (12:06 -0400)]
Fix 'fxbit-count' for negative arguments.

Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/fixnums.scm (fxbit-count): If the argument is
  negative, return the 'bitwise-not' of the result of 'logcount', as per
  R6RS.  Previously, 'fxbit-count' was identical to 'logcount'.

* test-suite/tests/r6rs-arithmetic-fixnums.test (fxbit-count): Add test.

10 years agogcd and lcm support inexact integer arguments.
Mark H Weaver [Tue, 16 Jul 2013 10:38:38 +0000 (06:38 -0400)]
gcd and lcm support inexact integer arguments.

Fixes <http://bugs.gnu.org/14870>.
Reported by Göran Weinholt <goran@weinholt.se>.

* libguile/numbers.c (scm_gcd, scm_lcm): Support inexact integers.

* test-suite/tests/numbers.test (gcd, lcm): Add tests.

10 years agomin and max: NaNs beat infinities, per R6RS errata.
Mark H Weaver [Tue, 16 Jul 2013 09:18:15 +0000 (05:18 -0400)]
min and max: NaNs beat infinities, per R6RS errata.

Fixes <http://bugs.gnu.org/14865>.
Reported by Göran Weinholt <goran@weinholt.se>.

* libguile/numbers.c (scm_min, scm_max): NaNs beat infinities, as per
  the R6RS errata.

* test-suite/tests/numbers.test (min, max): Update tests.

10 years agoFlonum operations always return flonums.
Mark H Weaver [Tue, 16 Jul 2013 08:43:07 +0000 (04:43 -0400)]
Flonum operations always return flonums.

Fixes <http://bugs.gnu.org/14871>.
Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/flonums.scm (ensure-flonum): New procedure.
  (fllog): Rewrite using case-lambda.  Handle negative zeroes.  Use
  'ensure-flonum'.
  (flatan): Rewrite using case-lambda.
  (flasin, flacos, flsqrt, flexpt): Use 'ensure-flonum'.

* test-suite/tests/r6rs-arithmetic-flonums.test
  (fllog, flasin, flacos, flsqrt, flexpt): Add tests.

10 years agoflfinite? applied to a NaN returns false.
Mark H Weaver [Tue, 16 Jul 2013 07:42:52 +0000 (03:42 -0400)]
flfinite? applied to a NaN returns false.

Fixes <http://bugs.gnu.org/14868>.
Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/flonums.scm (flfinite?): If the argument is a
  NaN, return false.

* test-suite/tests/r6rs-arithmetic-flonums.test (flfinite?): Add test.

10 years agoflonum? returns false for complex number objects.
Mark H Weaver [Tue, 16 Jul 2013 07:38:27 +0000 (03:38 -0400)]
flonum? returns false for complex number objects.

Fixes <http://bugs.gnu.org/14866>.
Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/flonums.scm (flonum?): Use 'real?' instead of
  'number?'.

* test-suite/tests/r6rs-arithmetic-flonums.test (flonum?): Add tests.

10 years agoAllow fl+ and fl* to accept zero arguments.
Mark H Weaver [Tue, 16 Jul 2013 07:33:02 +0000 (03:33 -0400)]
Allow fl+ and fl* to accept zero arguments.

Fixes <http://bugs.gnu.org/14869>.
Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/flonums.scm (fl+, fl*): Accept zero arguments.

* test-suite/tests/r6rs-arithmetic-flonums.test (fl+, fl*): Add tests.

10 years agonumbers.test: Fix inum/flonum comparison test on 32-bit machines.
Mark H Weaver [Tue, 16 Jul 2013 05:46:05 +0000 (01:46 -0400)]
numbers.test: Fix inum/flonum comparison test on 32-bit machines.

* test-suite/tests/numbers.test (<): Fix inum/flonum test.

10 years agoAvoid lossy conversion from inum to double in numerical comparisons.
Mark H Weaver [Tue, 16 Jul 2013 04:26:11 +0000 (00:26 -0400)]
Avoid lossy conversion from inum to double in numerical comparisons.

* libguile/numbers.c (scm_less_p): Avoid converting inums to doubles.

* test-suite/tests/numbers.test (<): Add tests.

10 years agonumbers.test: Avoid inexact arithmetic in computation of fixnum-bit.
Mark H Weaver [Tue, 16 Jul 2013 04:22:10 +0000 (00:22 -0400)]
numbers.test: Avoid inexact arithmetic in computation of fixnum-bit.

* test-suite/tests/numbers.test (fixnum-bit): Rewrite to avoid
  inexact arithmetic.

10 years agoFix bugs in numerical equality predicate.
Mark H Weaver [Tue, 16 Jul 2013 04:18:40 +0000 (00:18 -0400)]
Fix bugs in numerical equality predicate.

* libguile/numbers.c (scm_num_eq_p): Fix bug comparing fractions to
  infinities (reported by Göran Weinholt <goran@weinholt.se>).  Fix
  erroneous comment describing the logic behind inum/flonum comparison.
  Use similar logic for inum/complex comparison to avoid rounding
  errors.  Make minor indentation fixes and simplifications.

* test-suite/tests/numbers.test (=): Add tests.

10 years agoFix rounding in scm_i_divide2double for negative arguments.
Mark H Weaver [Tue, 16 Jul 2013 04:00:23 +0000 (00:00 -0400)]
Fix rounding in scm_i_divide2double for negative arguments.

* libguile/numbers.c (INUM_LOSSLESSLY_CONVERTIBLE_TO_DOUBLE):
  New macro.
  (scm_i_divide2double): Use INUM_LOSSLESSLY_CONVERTIBLE_TO_DOUBLE to
  determine if our fast path is safe.  Previously, negative arguments
  were not checked properly.

* test-suite/tests/numbers.test (exact->inexact): Add tests.

10 years agoFix VM 'ash' for right shifts by large amounts.
Mark H Weaver [Sun, 14 Jul 2013 18:47:10 +0000 (14:47 -0400)]
Fix VM 'ash' for right shifts by large amounts.

Fixes <http://bugs.gnu.org/14864>.
Reported by Göran Weinholt <goran@weinholt.se>.

* libguile/vm-i-scheme.c (ash): Fallback to 'scm_ash' for right shifts
  with counts >= SCM_I_FIXNUM_BIT, since '>>' is not guaranteed to work
  correctly for large counts.

10 years agoFix 'bitwise-bit-count' for negative arguments.
Mark H Weaver [Sun, 14 Jul 2013 18:08:33 +0000 (14:08 -0400)]
Fix 'bitwise-bit-count' for negative arguments.

Fixes <http://bugs.gnu.org/14864>.
Reported by Göran Weinholt <goran@weinholt.se>.

* module/rnrs/arithmetic/bitwise.scm (bitwise-bit-count): If the
  argument is negative, return the 'bitwise-not' of the result of
  'logcount', as per R6RS.  Previously, 'bitwise-bit-count' was
  identical to 'logcount'.

10 years agoFix bug in remqueue in threads.c when removing last element.
Mark H Weaver [Mon, 17 Jun 2013 18:43:58 +0000 (14:43 -0400)]
Fix bug in remqueue in threads.c when removing last element.

Reported and debugged by Andrew Gaylard <ag@computer.org>.

* libguile/threads.c (remqueue): When removing the last element from a
  queue with more than one element, set (car q) to the previous element.

* THANKS: Thank Andrew Gaylard.

10 years agoFix #ifdefery for `setegid'.
Ludovic Courtès [Sun, 16 Jun 2013 19:47:39 +0000 (21:47 +0200)]
Fix #ifdefery for `setegid'.

* libguile/posix.c (scm_setegid): Change to #ifdef HAVE_SETEGID.

10 years agotests: Don't rely on `scm_call_2' being visible.
Ludovic Courtès [Sun, 16 Jun 2013 18:58:10 +0000 (20:58 +0200)]
tests: Don't rely on `scm_call_2' being visible.

* test-suite/tests/coverage.test ("procedure-execution-count")["called
  from C"]: Throw 'unresolved when `scm_call_2' cannot be resolved.
  Reported by Eli Zaretskii <eliz@gnu.org>.

10 years agoAugment `.dir-locals.el'.
Ludovic Courtès [Sun, 16 Jun 2013 18:56:31 +0000 (20:56 +0200)]
Augment `.dir-locals.el'.

10 years agotests: Remove symlink only when it exists.
Ludovic Courtès [Sun, 16 Jun 2013 14:54:12 +0000 (16:54 +0200)]
tests: Remove symlink only when it exists.

* test-suite/tests/filesys.test: Delete (test-symlink) only if it
  exists---i.e., not on Windows.
  Reported by Eli Zaretskii <eliz@gnu.org>.

10 years agotests: Skip FFI tests that use `qsort' when it's not accessible.
Ludovic Courtès [Sun, 16 Jun 2013 14:52:38 +0000 (16:52 +0200)]
tests: Skip FFI tests that use `qsort' when it's not accessible.

* test-suite/tests/foreign.test ("procedure->pointer")[qsort]: Wrap in
  `false-if-exception'.
  ["qsort", "qsort, wrong return type", "qsort, wrong arity"]: Throw
  'unresolved when QSORT if #f.
  Reported by Eli Zaretskii <eliz@gnu.org>.

10 years agotests: Don't rely on $TMPDIR and /tmp on Windows.
Ludovic Courtès [Sun, 16 Jun 2013 14:42:01 +0000 (16:42 +0200)]
tests: Don't rely on $TMPDIR and /tmp on Windows.

* test-suite/standalone/test-unwind.c (check_ports)[__MINGW32__]: Use
  $TEMP, $TMP, or / as the value for TMPDIR.
  Patch by Eli Zaretskii <eliz@gnu.org>.

10 years agotests: Use double quotes around shell arguments, for Windows.
Ludovic Courtès [Sun, 16 Jun 2013 14:39:14 +0000 (16:39 +0200)]
tests: Use double quotes around shell arguments, for Windows.

* test-suite/standalone/test-system-cmds (test-system-cmd): Use double
  quotes around shell arguments.
  Reported by Eli Zaretskii <eliz@gnu.org>.

10 years agoDefine `AF_UNIX' only when Unix-domain sockets are supported.
Ludovic Courtès [Sun, 16 Jun 2013 14:19:21 +0000 (16:19 +0200)]
Define `AF_UNIX' only when Unix-domain sockets are supported.

* libguile/socket.c (scm_init_socket): Defined `AF_UNIX' only when
  `HAVE_UNIX_DOMAIN_SOCKETS' is defined.
  Reported by Eli Zaretskii <eliz@gnu.org>.

10 years agoAllow #f as timeout argument to unlock-mutex and SRFI-18 mutex-unlock!
Mark H Weaver [Mon, 10 Jun 2013 06:05:17 +0000 (02:05 -0400)]
Allow #f as timeout argument to unlock-mutex and SRFI-18 mutex-unlock!

Reported by Chaos Eternal <chaoseternal@shlug.org>
Based on a patch by Nala Ginrut <nalaginrut@gmail.com>

* libguile/threads.c (scm_unlock_mutex_timed): If 'timeout' argument
  is false, interpret that as no timeout.

* doc/ref/api-scheduling.texi (Mutexes and Condition Variables):
  Update documentation.

10 years agoFix tests for 'scm_c_bind_keyword_arguments'.
Mark H Weaver [Mon, 10 Jun 2013 06:26:11 +0000 (02:26 -0400)]
Fix tests for 'scm_c_bind_keyword_arguments'.

* test-suite/standalone/test-scm-c-bind-keyword-arguments.c (error_handler):
  Remove function.
  (unrecognized_keyword_error_handler, invalid_keyword_error_handler,
  odd_length_error_handler): New functions.
  (test_scm_c_bind_keyword_arguments): Use new error handler functions.

10 years agoReport the faulty keyword in errors raised by `scm_c_bind_keyword_arguments'.
Ludovic Courtès [Tue, 4 Jun 2013 22:25:39 +0000 (00:25 +0200)]
Report the faulty keyword in errors raised by `scm_c_bind_keyword_arguments'.

Reported by Mark H. Weaver.

* libguile/keywords.c (scm_c_bind_keyword_arguments): Use
  `scm_error_scm' instead of `scm_error'.  Pass the faulty keyword
  enclosed in a list as the last argument.
* test-suite/tests/optargs.test ("scm_c_bind_keyword_arguments"): New
  test prefix.

10 years agoPrint the faulty object upon invalid-keyword errors.
Ludovic Courtès [Mon, 3 Jun 2013 22:29:59 +0000 (00:29 +0200)]
Print the faulty object upon invalid-keyword errors.

* libguile/vm.c (vm_error_kwargs_invalid_keyword,
  vm_error_kwargs_unrecognized_keyword): Add parameter.  Pass it
  enclosed in a list as the last argument to `scm_error_scm'.
* libguile/vm-i-system.c (bind_kwargs): Adjust accordingly.
* libguile/eval.c (error_invalid_keyword, error_unrecognized_keyword):
  Add parameter.
  (prepare_boot_closure_env_for_apply): Adjust accordingly.
* module/ice-9/eval.scm (primitive-eval): Likewise.
* libguile/error.c (scm_error_scm): Mention `keyword-argument-error' in
  docstring.
* module/ice-9/boot-9.scm (keyword-error-printer): New procedure; use it.
* test-suite/tests/optargs.test (c&e, with-test-prefix/c&e): Remove.
  ("define*")["unrecognized keyword"]: Test the value passed along the
  `keyword-argument-error' exception.
  ["invalid keyword"]: New test.
* doc/ref/api-control.texi (Error Reporting): Update `scm-error'
  description.

11 years agoweb: uri-encode hexadecimal percent-encoding is now uppercase
Aleix Conchillo Flaque [Thu, 2 May 2013 19:13:31 +0000 (12:13 -0700)]
web: uri-encode hexadecimal percent-encoding is now uppercase

* module/web/uri.scm (uri-encode): the hexadecimal percent-encoding %HH
  is now uppercased as suggested by RFC3986:

      "For consistency, URI producers and normalizers should use
       uppercase hexadecimal digits for all percent-encodings."

* test-suite/tests/web-uri.test ("encode"): update tests.

11 years agoManual: fix 'my-or' examples to use let-bound variable.
Mark H Weaver [Sun, 14 Apr 2013 17:36:20 +0000 (13:36 -0400)]
Manual: fix 'my-or' examples to use let-bound variable.

Fixes <http://bugs.gnu.org/14203> reported by Nikita Karetnikov.

* doc/ref/api-macros.texi (Defining Macros, Syntax Rules): Fix
  definition of 'my-or' example macro to use the let-bound variable.

11 years agotests: Use shell constructs that /bin/sh on Solaris 10 can understand.
Ludovic Courtès [Sun, 14 Apr 2013 13:46:17 +0000 (15:46 +0200)]
tests: Use shell constructs that /bin/sh on Solaris 10 can understand.

Partly fixes <http://bugs.gnu.org/14042>.
Reported by Marc Girod <marc.girod@gmail.com>

* test-suite/standalone/test-language: Use a shell construct that
  /bin/sh on Solaris 10 can understand.

11 years agoUsing 'pass-if-equal' in coding.test.
Mark H Weaver [Sun, 14 Apr 2013 06:29:25 +0000 (02:29 -0400)]
Using 'pass-if-equal' in coding.test.

* test-suite/tests/coding.test ("block comments", "line comments"):
  Use 'pass-if-equal'.

11 years agoAdjust BOM tests to reflect the fact that big endian is used by default.
Mark H Weaver [Sun, 14 Apr 2013 05:50:47 +0000 (01:50 -0400)]
Adjust BOM tests to reflect the fact that big endian is used by default.

* test-suite/tests/ports.test ("BOM not discarded unless at start of
  UTF-16 stream", "BOM not discarded unless at start of UTF-32 stream"):
  Adjust tests to reflect the fact that, in the absence of a BOM, big
  endian will be used by default for the "UTF-16" and "UTF-32"
  encodings.

11 years agoAdd 2012 and 2013 to copyright notice on numbers.test.
Mark H Weaver [Thu, 11 Apr 2013 00:07:22 +0000 (20:07 -0400)]
Add 2012 and 2013 to copyright notice on numbers.test.

* test-suite/tests/numbers.test: Add 2012 and 2013 to copyright notice.
  It was modified both of those years.

11 years agoDo not add $(EXEEXT) to guild or guile-tools.
Mark H Weaver [Wed, 10 Apr 2013 12:23:16 +0000 (08:23 -0400)]
Do not add $(EXEEXT) to guild or guile-tools.

* meta/Makefile.am (install-exec-hook): Do not add $(EXEEXT) to guild or
  guile-tools.

11 years agoMention `open-file' in NEWS.
Ludovic Courtès [Wed, 10 Apr 2013 05:52:36 +0000 (07:52 +0200)]
Mention `open-file' in NEWS.

11 years agodoc: Require libunistring 0.9.3 in `README'.
Ludovic Courtès [Wed, 10 Apr 2013 05:52:25 +0000 (07:52 +0200)]
doc: Require libunistring 0.9.3 in `README'.

* README: Require libunistring 0.9.3.  The <unitypes.h> header in 0.9.1
  lacks the _UC_ATTRIBUTE_CONST definition, leading to build failures.

11 years agobuild: Tell `gen-scmconfig' whether the system has `struct timespec'.
Ludovic Courtès [Tue, 9 Apr 2013 23:39:02 +0000 (01:39 +0200)]
build: Tell `gen-scmconfig' whether the system has `struct timespec'.

* configure.ac: Reinstate `struct timespec' check removed in commit
  7e7c6f6a937005b08fffd5aeccdf992459b07137, but define
  `HAVE_SYSTEM_STRUCT_TIMESPEC' instead of `HAVE_STRUCT_TIMESPEC'.
* libguile/gen-scmconfig.c (main): Change `HAVE_STRUCT_TIMESPEC' to
  `HAVE_SYSTEM_STRUCT_TIMESPEC'.

11 years agoBump version number for 2.0.9.
Ludovic Courtès [Tue, 9 Apr 2013 23:10:04 +0000 (01:10 +0200)]
Bump version number for 2.0.9.

* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.

11 years agodoc: Update `release.org'.
Ludovic Courtès [Tue, 9 Apr 2013 23:09:28 +0000 (01:09 +0200)]
doc: Update `release.org'.

* doc/release.org: Recommend "distcheck".  Add `makeinfo' to the
  bootstrap tool list.

11 years agostime: Remove #ifdef HAVE_*_H for headers provided by Gnulib.
Ludovic Courtès [Tue, 9 Apr 2013 22:13:54 +0000 (00:13 +0200)]
stime: Remove #ifdef HAVE_*_H for headers provided by Gnulib.

* libguile/stime.c: Remove #ifdef HAVE_SYS_TIMES_H, HAVE_SYS_TYPES_H,
  and HAVE_STRING_H since those headers are always provided by Gnulib
  when the corresponding macro is undefined.  Fixes a regression on
  MinGW introduced by commit 40e2a31.

11 years agoMake `build-aux/gendocs.sh' executable.
Ludovic Courtès [Tue, 9 Apr 2013 22:10:23 +0000 (00:10 +0200)]
Make `build-aux/gendocs.sh' executable.

11 years agoBump version number for 2.0.8.
Ludovic Courtès [Tue, 9 Apr 2013 20:51:48 +0000 (22:51 +0200)]
Bump version number for 2.0.8.

* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
  (LIBGUILE_INTERFACE_CURRENT): Increment, to account for new C
  functions `scm_c_bind_keyword_arguments' et al.
  (LIBGUILE_INTERFACE_AGE): Increment.

11 years agotests: Skip FFI tests involving `scm_is_pair' when `dynamic-func' fails.
Ludovic Courtès [Tue, 9 Apr 2013 20:37:06 +0000 (22:37 +0200)]
tests: Skip FFI tests involving `scm_is_pair' when `dynamic-func' fails.

* test-suite/tests/foreign.test ("make-pointer")["equal? modulo
  finalizer", "equal? modulo finalizer (set-pointer-finalizer!)"]: Wrap
  `dynamic-func' in `false-if-exception' (static builds on NetBSD 5.1
  raise "Symbol not found" here.)

11 years agodoc: Cosmetic change for `release.org'.
Ludovic Courtès [Tue, 9 Apr 2013 19:48:58 +0000 (21:48 +0200)]
doc: Cosmetic change for `release.org'.

* doc/release.org: Add #+STARTUP.

11 years agoUpdate `THANKS'.
Ludovic Courtès [Tue, 9 Apr 2013 19:48:04 +0000 (21:48 +0200)]
Update `THANKS'.

11 years agoupdate NEWS
Andy Wingo [Tue, 9 Apr 2013 20:45:35 +0000 (22:45 +0200)]
update NEWS

* NEWS: Updates.

11 years agofix stime patch for HAVE_TIMES removal
Andy Wingo [Tue, 9 Apr 2013 20:12:28 +0000 (22:12 +0200)]
fix stime patch for HAVE_TIMES removal

* libguile/stime.c (scm_init_stime): Fix previous patch.  At this point
  in the source, we definitely have a run-time function, but don't
  necessarily have a real-time function.

11 years agosimplify configure checks for functionality provided by gnulib
Andy Wingo [Tue, 9 Apr 2013 19:58:30 +0000 (21:58 +0200)]
simplify configure checks for functionality provided by gnulib

* configure.ac: Remove checks for pipe, stftime, times, and select, as
  our Gnulib modules already ensure they are provided.

* libguile/stime.c: Rely on gnulib providing `times'.

11 years agoMinor 'THANKS' fix.
Mark H Weaver [Tue, 9 Apr 2013 19:24:18 +0000 (15:24 -0400)]
Minor 'THANKS' fix.

11 years agoFix alignment in 'THANKS'.
Mark H Weaver [Tue, 9 Apr 2013 19:23:20 +0000 (15:23 -0400)]
Fix alignment in 'THANKS'.

11 years agoUpdate bug report section of 'THANKS'.
Mark H Weaver [Tue, 9 Apr 2013 19:21:12 +0000 (15:21 -0400)]
Update bug report section of 'THANKS'.

11 years agoUpdate 'THANKS'.
Mark H Weaver [Tue, 9 Apr 2013 18:07:14 +0000 (14:07 -0400)]
Update 'THANKS'.

11 years agoManual: Don't promise to signal an error for an illegal 'letrec'.
Mark H Weaver [Tue, 9 Apr 2013 17:54:39 +0000 (13:54 -0400)]
Manual: Don't promise to signal an error for an illegal 'letrec'.

Reported by Nikita Karetnikov <nikita@karetnikov.org>.

* doc/ref/api-binding.texi (Local Bindings): Remove the incorrect claim
  that improperly accessing a letrec-bound variable during evaluation of
  its initializers will necessarily cause an error to be signalled.

11 years agotests: Skip IPv6 socket tests when OS support is missing.
Ludovic Courtès [Tue, 9 Apr 2013 06:49:06 +0000 (08:49 +0200)]
tests: Skip IPv6 socket tests when OS support is missing.

Reported by Samuel Thibault <samuel.thibault@gnu.org>
and Peter Simons <simons@cryp.to>.

* test-suite/tests/00-socket.test ("AF_INET6/SOCK_STREAM"): Throw
  `unresolved' when `bind' throws EADDRNOTAVAIL.

11 years agoUpdate 'NEWS'.
Mark H Weaver [Mon, 8 Apr 2013 14:15:12 +0000 (10:15 -0400)]
Update 'NEWS'.

11 years agoUpdate 'NEWS'.
Mark H Weaver [Mon, 8 Apr 2013 12:58:00 +0000 (08:58 -0400)]
Update 'NEWS'.

11 years agoConsume a peeked EOF at the REPL.
Mark H Weaver [Mon, 8 Apr 2013 12:44:02 +0000 (08:44 -0400)]
Consume a peeked EOF at the REPL.

* module/system/repl/repl.scm (meta-reader): Consume peeked EOF.

11 years agoMiscellaneous 'sendfile' fixes and improved tests.
Mark H Weaver [Mon, 8 Apr 2013 04:36:00 +0000 (00:36 -0400)]
Miscellaneous 'sendfile' fixes and improved tests.

* libguile/filesys.c (scm_sendfile): In Linux-style sendfile(2) code, if
  EINTR or EAGAIN occurs, set result to 1 (not 0) so that we actually
  keep going.  In non-sendfile(2) code, deal gracefully with short reads
  due to EOF.

* test-suite/tests/filesys.test ("sendfile"): Use 'let*' to guarantee
  the needed order of operations: write (test-file) and then read it.
  Add code to check the written data (not just the returned length) in
  all tests, including the cases that hit EOF prematurely.

11 years agoUpdate 'NEWS'.
Mark H Weaver [Sun, 7 Apr 2013 21:47:44 +0000 (17:47 -0400)]
Update 'NEWS'.

11 years agoChange `sendfile' to loop until everything has been sent.
Ludovic Courtès [Sun, 7 Apr 2013 21:43:21 +0000 (23:43 +0200)]
Change `sendfile' to loop until everything has been sent.

* libguile/filesys.c (scm_sendfile)[HAVE_SYS_SENDFILE_H &&
  HAVE_SENDFILE]: Compare RESULT with C_COUNT.  Loop until C_COUNT bytes
  have been sent.
* doc/ref/posix.texi (File System): Update the description.  Explain the
  new semantics.
* test-suite/tests/filesys.test ("sendfile"): Rewrite using
  `pass-if-equal'.  Check the return value for all the tests.
  ["file with offset past the end", "file with offset near the end"]:
  New tests.

11 years agoRemove outdated and misplaced "Included Guile Modules" node from manual.
Mark H Weaver [Sun, 7 Apr 2013 19:45:38 +0000 (15:45 -0400)]
Remove outdated and misplaced "Included Guile Modules" node from manual.

* doc/ref/api-modules.texi (Included Guile Modules): Remove.
  (Using Guile Modules): Fix cross reference.

11 years agoClarify 'file-encoding' docs: heuristics may be improved later.
Mark H Weaver [Sun, 7 Apr 2013 16:07:33 +0000 (12:07 -0400)]
Clarify 'file-encoding' docs: heuristics may be improved later.

* doc/ref/api-evaluation.texi (Character Encoding of Source Files):
  Mention UTF-8 as another common encoding used for Scheme source files,
  and that it is used by default.  Change the description to leave open
  the possibility of adding additional heuristics in the future.
  Mention that if the coding declaration is in a #!-style block comment,
  it must be the first such comment in the file.  Mention the
  '#:guess-encoding' keyword argument.

11 years agoAdd keyword arguments to file opening procedures.
Mark H Weaver [Sun, 7 Apr 2013 03:19:55 +0000 (23:19 -0400)]
Add keyword arguments to file opening procedures.

* libguile/fports.c (scm_open_file_with_encoding): New API function,
  containing the code previously found in 'scm_open_file', but modified
  to accept the new 'guess_encoding' and 'encoding' arguments.

  (scm_open_file): Now just a simple wrapper that calls
  'scm_open_file_with_encoding'.

  (scm_i_open_file): New implementation of 'open-file' that accepts
  keyword arguments '#:guess-encoding' and '#:encoding', and calls
  'scm_open_file_with_encoding'.

  (scm_init_fports_keywords): New initialization function that gets
  called after keywords are initialized.

* libguile/fports.h (scm_open_file_with_encoding,
  scm_init_fports_keywords): Add prototypes.

* libguile/init.c (scm_i_init_guile): Call 'scm_init_fports_keywords'.

* module/ice-9/boot-9.scm: Add enhanced versions of 'open-input-file',
  'open-output-file', 'call-with-input-file', 'call-with-output-file',
  'with-input-from-file', 'with-output-to-file', and
  'with-error-to-file', that accept keyword arguments '#:binary',
  '#:encoding', and (for input port constructors) '#:guess-encoding'.

* doc/ref/api-io.texi (File Ports): Update documentation.

* test-suite/tests/ports.test ("keyword arguments for file openers"):
  Add tests.

11 years agoAdd record type printer for srfi-41.
Chris K. Jester-Young [Sun, 7 Apr 2013 16:44:18 +0000 (12:44 -0400)]
Add record type printer for srfi-41.

* module/srfi/srfi-41.scm: Add record type printer for streams.
  (stream-promise-visit): New helper for visiting stream promises.

11 years agoAdd record type printer for srfi-45.
Chris K. Jester-Young [Sun, 7 Apr 2013 16:43:17 +0000 (12:43 -0400)]
Add record type printer for srfi-45.

* module/srfi/srfi-45.scm: Add record type printer for promises.
  (promise-visit): New helper for visiting lazy promises.

11 years agoImplement efficient 'scm_unget_bytes' and 'unget-bytevector'.
Mark H Weaver [Sat, 6 Apr 2013 05:42:45 +0000 (01:42 -0400)]
Implement efficient 'scm_unget_bytes' and 'unget-bytevector'.

* libguile/ports.c (scm_i_unget_bytes): New static function.
  (scm_unget_bytes): New API function.
  (scm_unget_byte): Rewrite to simply call 'scm_i_unget_bytes'.
  (scm_ungetc, scm_peek_char, looking_at_bytes): Use 'scm_i_unget_bytes'.

* libguile/ports.h: Add prototype for 'scm_unget_bytes'.

* libguile/fports.c (scm_setvbuf): Use 'scm_unget_bytes'.

* libguile/r6rs-ports.c (scm_unget_bytevector): New procedure.

* module/ice-9/binary-ports.scm (unget-bytevector): New export.

* doc/ref/api-io.texi (R6RS Binary Input): Add documentation.
  (R6RS I/O Ports): Update brief description of (ice-9 binary-ports) to
  reflect the new reality: it is no longer a subset of (rnrs io ports).

* test-suite/tests/ports.test ("unget-bytevector"): Add test.