Mark H Weaver [Tue, 18 Jun 2019 07:28:18 +0000 (03:28 -0400)]
fport_seek: Eliminate a fruitless use of 'off_t_or_off64_t'.
This is a followup to commit
91ba73b397fcc2a36ae7e434522a924c7a8887d0.
* libguile/fports.c (fport_seek): Use 'lseek' instead of
'lseek_or_lseek64', and use 'scm_t_off' uniformly. That's the type used
in the function signature, and there's no benefit to using a wider type
internally. Remove the overflow check, which is no longer needed.
Mark H Weaver [Sun, 28 Apr 2019 07:55:40 +0000 (03:55 -0400)]
Fix documentation of R6RS 'binary-port?' to reflect reality.
* doc/ref/r6rs.texi (rnrs io ports): Improve the descriptions of
'binary-port?' and 'textual-port?'.
* module/rnrs/io/ports.scm (binary-port?, textual-port?): Update the
docstrings.
Mark H Weaver [Sat, 11 May 2019 07:47:41 +0000 (03:47 -0400)]
open-process: Fix dup(2) and execvp(2) error handling.
Previously, in the case where OUT is 0, or ERR is 0 or 1,
e.g. when (current-error-port) points to STDOUT, the code in
'start_child' to relocate OUT/ERR out of the way to another file
descriptor had multiple bugs:
(1) It neglected to close the original file descriptor.
(2) It checked 'errno' without first checking the return value of
dup(2). This doesn't work because dup(2) leaves 'errno' unchanged
if there's no error.
(3) In case 'errno' contained EINTR, the retry code failed because
OUT (or ERR) was overwritten by the result of the previous failed
dup(2) call.
This commit fixes these problems, as well as another problem with
'execvp' error reporting.
* libguile/posix.c (renumber_file_descriptor): New static helper
function.
(start_child): Use 'renumber_file_descriptor'. If 'execvp' fails, write
the error message to file descriptor 2. Previously, we wrote the error
message to ERR, which was the old file descriptor before being relocated
to 2.
Mark H Weaver [Sat, 11 May 2019 07:44:58 +0000 (03:44 -0400)]
Refresh a stale comment.
* libguile/numbers.h: In a comment, update the count of number subtypes.
Mark H Weaver [Tue, 18 Jun 2019 06:09:16 +0000 (02:09 -0400)]
scm_mkstrport: Optimize the POS -> BYTE_POS conversion.
* libguile/strports.c (scm_mkstrport): Use 'scm_c_string_utf8_length' to
avoid the conversion to UTF-8.
Mark H Weaver [Wed, 17 Apr 2019 03:13:37 +0000 (23:13 -0400)]
Make 'get-bytevector-some' and 'get-bytevector-some!' suspendable.
* module/ice-9/suspendable-ports.scm (get-bytevector-some)
(get-bytevector-some!): New procedures.
(port-bindings): Add them.
Mark H Weaver [Mon, 8 Apr 2019 10:21:20 +0000 (06:21 -0400)]
open-pipe*: Improve performance of OPEN_BOTH mode.
* module/ice-9/popen.scm (make-rw-port): Re-implement using R6RS
custom binary input/output ports.
Mark H Weaver [Wed, 17 Apr 2019 03:13:06 +0000 (23:13 -0400)]
Add get-bytevector-some!.
* libguile/r6rs-ports.c (scm_get_bytevector_some_x): New procedure.
* libguile/r6rs-ports.h (scm_get_bytevector_some_x): Add prototype.
(scm_unget_bytevector): Move prototype next to 'scm_get_bytevector_some_x'.
* module/ice-9/binary-ports.scm: Export 'get-bytevector-some!'.
* doc/ref/api-io.texi (Binary I/O): Document it.
Mark H Weaver [Wed, 29 May 2019 19:31:42 +0000 (15:31 -0400)]
scm_to_stringn: Avoid passing NULL to c_strcasecmp.
Reported by Massimiliano Gubinelli <m.gubinelli@gmail.com> in
<https://lists.gnu.org/archive/html/guile-user/2019-05/msg00070.html>.
* libguile/strings.c (scm_to_stringn): Check for (encoding == NULL)
before passing it to 'c_strcasecmp'. Eliminate redundant 'enc'
variable.
Mark H Weaver [Fri, 31 May 2019 02:07:48 +0000 (22:07 -0400)]
time.test: Use 'pass-if-equal' in more tests.
* test-suite/tests/time.test ("strftime"): Change some uses of 'pass-if'
to instead use 'pass-if-equal'.
Mark H Weaver [Wed, 22 May 2019 03:15:41 +0000 (23:15 -0400)]
Fix typo in tags.h comment.
* libguile/tags.h: Fix typo in comment.
Mark H Weaver [Sat, 25 May 2019 09:20:42 +0000 (05:20 -0400)]
Save and restore errno in the signal handler.
* libguile/scmsigs.c (take_signal): Save and restore errno.
Mark H Weaver [Fri, 19 Apr 2019 04:59:59 +0000 (00:59 -0400)]
Improve overflow checks in bytevector, string, and I/O operations.
* libguile/bytevectors.c (INTEGER_ACCESSOR_PROLOGUE)
(scm_bytevector_copy_x, bytevector_large_set): Rewrite checks to reliably
detect overflows.
(make_bytevector): Constrain the bytevector length to avoid later
overflows during allocation.
(make_bytevector_from_buffer): Fix indentation.
(scm_bytevector_length): Use 'scm_from_size_t' to convert a 'size_t',
not 'scm_from_uint'.
* libguile/fports.c (fport_seek): Check for overflow before the implicit
conversion of the return value.
* libguile/guardians.c (guardian_print): Use 'scm_from_ulong' to convert
an 'unsigned long', not 'scm_from_uint'.
* libguile/ports.c (scm_unread_string): Change a variable to type 'size_t'.
(scm_seek, scm_truncate_file): Use 'scm_t_off' instead of
'off_t_or_off64_t' to avoid implicit type conversions that could
overflow, because 'ptob->seek' and 'ptob->truncate' use 'scm_t_off'.
* libguile/r6rs-ports.c (bytevector_input_port_seek)
(custom_binary_port_seek, bytevector_output_port_seek): Rewrite offset
calculations to reliably detect overflows. Use 'scm_from_off_t' to
convert a 'scm_t_off', not 'scm_from_long' nor 'scm_from_int'.
(scm_get_bytevector_n_x, scm_get_bytevector_all, scm_unget_bytevector)
(bytevector_output_port_write): Rewrite checks to reliably detect
overflows. Use 'size_t' where appropriate.
(bytevector_output_port_buffer_grow): Rewrite size calculations to
reliably detect overflows. Minor change in the calculation of the new
size: now it is max(min_size, 2*current_size), whereas previously it
would multiply current_size by the smallest power of 2 needed to surpass
min_size.
* libguile/strings.c (make_stringbuf): Constrain the stringbuf length to
avoid later overflows during allocation.
(scm_string_append): Change overflow check to use INT_ADD_OVERFLOW.
* libguile/strports.c (string_port_write): Rewrite size calculations to
reliably detect overflows.
(string_port_seek): Rewrite offset calculations to reliably detect
overflows. Use 'scm_from_off_t' to convert a 'scm_t_off', not
'scm_from_long'.
(string_port_truncate): Use 'scm_from_off_t' to convert a 'scm_t_off',
not 'scm_from_off_t_or_off64_t'.
* libguile/vectors.c (scm_c_make_vector): Change a variable to type
'size_t'.
Timothy Sample [Sun, 2 Jun 2019 18:41:20 +0000 (14:41 -0400)]
Make URI handling locale independent.
Fixes <https://bugs.gnu.org/35785>.
* module/web/uri.scm (digits, hex-digits, letters): New variables.
(ipv4-regexp, ipv6-regexp, domain-label-regexp, top-label-regexp,
userinfo-pat, host-pat, ipv6-host-pat, port-pat, scheme-pat): Explicitly
list each character instead of using character ranges.
* test-suite/tests/web-uri.test: Add corresponding tests.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Ludovic Courtès [Tue, 4 Jun 2019 19:20:15 +0000 (21:20 +0200)]
'basename' correctly handles "/" and "//".
* libguile/filesys.c (scm_basename): Special-case "/" and "//".
* test-suite/tests/filesys.test ("basename"): New test prefix.
Mark H Weaver [Tue, 14 May 2019 05:39:39 +0000 (01:39 -0400)]
Update iconv.m4 from gnulib.
* m4/iconv.m4: Update from
gnulib-v0.1-2176-ga79f2a287.
Mark H Weaver [Tue, 7 May 2019 01:11:26 +0000 (21:11 -0400)]
Strings, i18n: Limit the use of alloca to approximately 8 kilobytes.
* libguile/i18n.c (SCM_MAX_ALLOCA): New macro.
(SCM_STRING_TO_U32_BUF): Accept an additional variable to remember
whether we used malloc to allocate the buffer. Use malloc if the
allocation size is greater than SCM_MAX_ALLOCA.
(SCM_CLEANUP_U32_BUF): New macro.
(compare_u32_strings, compare_u32_strings_ci, str_to_case): Adapt.
* libguile/strings.c (SCM_MAX_ALLOCA): New macro.
(normalize_str, unistring_escapes_to_r6rs_escapes): Use malloc if the
allocation size is greater than SCM_MAX_ALLOCA.
* test-suite/tests/i18n.test, test-suite/tests/strings.test: Add tests.
Mark H Weaver [Wed, 1 May 2019 09:20:36 +0000 (05:20 -0400)]
put-u8: Always write a single byte, regardless of the port encoding.
Previously, 'put-u8' used textual I/O to write a single character,
relying on the usual practice of setting the port encoding to ISO-8859-1
for binary ports.
* libguile/r6rs-ports.c (scm_put_u8): Use 'scm_c_write', not 'scm_putc'.
Mark H Weaver [Sun, 28 Apr 2019 07:45:11 +0000 (03:45 -0400)]
Optimize fixnum exact integer square roots.
* libguile/numbers.c (scm_exact_integer_sqrt, scm_sqrt)
(exact_integer_is_perfect_square, exact_integer_floor_square_root):
Where it is trivial to do so, use GMP's low-level mpn functions to
avoid heap allocation.
Mark H Weaver [Fri, 19 Apr 2019 07:09:37 +0000 (03:09 -0400)]
Avoid 'with-latin1-locale' in binary I/O tests.
* test-suite/tests/r6rs-ports.test ("put-bytevector [2 args]")
("put-bytevector [3 args]", "put-bytevector [4 args]"): Set the default
port encoding instead of setting the locale.
Mark H Weaver [Tue, 7 May 2019 01:13:18 +0000 (21:13 -0400)]
Fix indentation in scm_sum.
Mark H Weaver [Wed, 17 Apr 2019 11:32:23 +0000 (07:32 -0400)]
Fix typo in comment.
Mark H Weaver [Tue, 7 May 2019 06:28:26 +0000 (02:28 -0400)]
Add 'scm_c_make_char' and use it where appropriate.
This reverts the change to SCM_MAKE_CHAR made in the previous commit
63818453ad226cd3c2d1fd8ade12e3d7c1d43c05, which used an arithmetic trick
to avoid evaluating its argument more than once.
Here, we restore the previous implementation of SCM_MAKE_CHAR, which
evaluates its argument twice. Instead, we introduce a new inlinable
function 'scm_c_make_char' and replace uses of SCM_MAKE_CHAR with calls
to 'scm_c_make_char' where appropriate.
* libguile/chars.h (scm_c_make_char): New inline function.
* libguile/inline.c: Include chars.h.
* libguile/srfi-13.c (REF_IN_CHARSET, scm_string_any, scm_string_every)
(scm_string_trim, scm_string_trim_right, scm_string_trim_both)
(scm_string_index, scm_string_index_right, scm_string_skip)
(scm_string_skip_right, scm_string_count, string_titlecase_x)
(string_reverse_x, scm_string_fold, scm_string_fold_right)
(scm_string_for_each, scm_string_filter, scm_string_delete):
Use 'scm_c_make_char' instead of 'SCM_MAKE_CHAR' in cases where the
argument calls a function.
* libguile/chars.c (scm_char_upcase, scm_char_downcase, scm_char_titlecase),
libguile/ports.c (scm_port_decode_char),
libguile/print.c (scm_simple_format),
libguile/read.c (scm_read_character),
libguile/strings.c (scm_string_ref, scm_c_string_ref),
libguile/vm-engine.c ("string-ref"): Ditto.
Mark H Weaver [Wed, 17 Apr 2019 03:11:42 +0000 (23:11 -0400)]
Reimplement SCM_MAKE_CHAR to evaluate its argument only once.
The motivation for this change is that SCM_MAKE_CHAR is sometimes passed
an expression that involves a procedure call that is not always trivial.
In other cases, the results are not guaranteed to be the same both
times, which could lead to the creation of invalid SCM objects.
* libguile/chars.h (SCM_MAKE_CHAR): Reimplement.
Andrea Azzarone [Thu, 11 Apr 2019 15:30:58 +0000 (16:30 +0100)]
Fix gc.test "after-gc-hook gets called" failures.
* libguile/scmsigs.c (signal_delivery_thread): Call scm_async_tick to
give any pending asyncs a chance to run before we block indefinitely
waiting for a signal to arrive.
Mark H Weaver [Mon, 15 Apr 2019 23:16:28 +0000 (19:16 -0400)]
Update user-visible copyright years.
* doc/ref/guile.texi: Update years in copyright notice.
* module/ice-9/command-line.scm (version-etc): Update 'copyright-year'.
* module/system/repl/common.scm (*version*): Update copyright years.
Mark H Weaver [Tue, 2 Apr 2019 02:11:35 +0000 (22:11 -0400)]
Avoid passing NULL to 'memcpy' and 'memcmp'.
Reported by Jeffrey Walton <noloader@gmail.com> in
<https://lists.gnu.org/archive/html/guile-devel/2019-03/msg00001.html>.
Note that C11 section 7.1.4 (Use of library functions) states that:
"unless explicitly stated otherwise in the detailed descriptions [of
library functions] that follow: If an argument to a function has an
invalid value (such as ... a null pointer ...) ..., the behavior is
undefined." Note that 'strxfrm' is an example of a standard C function
that explicitly states otherwise, allowing NULL to be passed in the
first argument if the size argument is zero, but no similar allowance is
specified for 'memcpy' or 'memcmp'.
* libguile/bytevectors.c (scm_uniform_array_to_bytevector): Call memcpy
only if 'byte_len' is non-zero.
* libguile/srfi-14.c (charsets_equal): Call memcmp only if the number of
ranges is non-zero.
* libguile/stime.c (setzone): Pass 1-character buffer to
'scm_to_locale_stringbuf', instead of NULL.
* libguile/strings.c (scm_to_locale_stringbuf): Call memcpy only if the
number of bytes to copy is non-zero.
Mark H Weaver [Mon, 15 Apr 2019 04:17:21 +0000 (00:17 -0400)]
Remove vestigial comment in tags.h.
* libguile/tags.h: Remove a vestigial comment which seems to have been
separated from its associated code long ago.
Mark H Weaver [Thu, 15 Nov 2018 07:47:22 +0000 (02:47 -0500)]
Fix typo in comment.
* module/ice-9/boot-9.scm: Fix typo.
Michael Gran [Sun, 24 Feb 2019 07:23:19 +0000 (23:23 -0800)]
Disable test for current value of setitimer on Cygwin
* test-suite/tests/signals.test ("current itimers are 0"): throws unresolved
for cygwin
Michael Gran [Sun, 24 Feb 2019 07:16:31 +0000 (23:16 -0800)]
Make locale monetary conversion tests be less strict on terminal whitespace
* test-suite/tests/i18n.test (monetary-amount->locale-string): modified
Michael Gran [Sun, 24 Feb 2019 00:33:50 +0000 (16:33 -0800)]
Handle newlib C library's langinfo constant names
The newlib C library (used in Cygwin) has alternative names for
nl_langinfo GNU extensions
* configure.ac (_NL_NUMERIC_GROUPING): new test
* libguile/i18n.c (INT_CURR_SYMBOL, MON_DECIMAL_POINT, MON_THOUSANDS_SEP)
(MON_GROUPING, POSITIVE_SIGN, NEGATIVE_SIGN, GROUPING, INT_FRAC_DIGITS)
(FRAC_DIGITS, P_CS_PRECEDES, P_SEP_BY_SPACE, N_CS_PRECEDES, N_SEP_BY_SPACE)
(P_SIGN_POSN, N_SIGN_POSN, INT_P_CS_PRECEDES, INT_P_SEP_BY_SPACE)
(INT_N_CS_PRECEDES, INT_N_SEP_BY_SPACE, INT_P_SIGN_POSN, INT_N_SIGN_POSN)
[HAVE_DECL__NL_NUMERIC_GROUPING]: map to newlib C constants, when present
Michael Gran [Sun, 24 Feb 2019 00:19:05 +0000 (16:19 -0800)]
Add a fallback value for the locale-monetary-decimal-point
* module/ice-9/i18n.scm (locale-monetary-decimal-point): use "." as fallback
Andy Wingo [Fri, 22 Feb 2019 14:25:21 +0000 (15:25 +0100)]
Fix race when expanding syntax-parameterize and define-syntax-parameter
* module/ice-9/psyntax.scm (put-global-definition-hook)
(get-global-definition-hook): Inline into uses.
(make-binding): Change format of lexically defined or rebound syntax
parameters to just be the transformer, not a list of the transformer.
(resolve-identifier, expand-install-global, expand-body)
(syntax-parameterize): Adapt to use the variable object (box) holding
the top-level syntax parameter as the "key" for lookups into the
lexical environment, instead of a fresh object associated with the
syntax transformer.
* module/ice-9/psyntax-pp.scm: Regenerate.
Fixes #27476, a horrible race when one thread is expanding a
syntax-parameterize form including uses, and another thread is expanding
the corresponding define-syntax-parameter. See
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=27476#102.
Andy Wingo [Fri, 1 Feb 2019 16:18:50 +0000 (17:18 +0100)]
Fix crypt-on-glibc test error
* test-suite/tests/posix.test ("crypt"): Allow for the given salt being
valid. Thanks to Jonathan Brielmaier for the report and debugging!
Mike Gran [Sun, 10 Feb 2019 00:59:38 +0000 (16:59 -0800)]
Fix binary output on files created by mkstemp!
Some operating systems require a O_BINARY flag.
* libguile/filesys.c (scm_i_mkstemp): Don't mask out O_BINARY flag
* test-suite/tests/posix.test ("binary mode honored"): new test
Mike Gran [Sun, 10 Feb 2019 00:39:19 +0000 (16:39 -0800)]
Avoid leaking a file descriptor in test-unwind
* test-suite/standalone/test-unwind.c (check_ports): explicitly close temp file
Mike Gran [Sun, 10 Feb 2019 00:20:13 +0000 (16:20 -0800)]
Fix strftime compile with null threads
* libguile/stime.c (scm_strftime): use correct pthread lock function
Mike Gran [Sat, 9 Feb 2019 17:54:55 +0000 (09:54 -0800)]
Remove redefinition of when & unless in snarf-check-and-output-texi
* module/scripts/snarf-check-and-output-texi.scm (when, unless): removed
Mike Gran [Sat, 9 Feb 2019 17:44:28 +0000 (09:44 -0800)]
Don't mutate read-only string in ports test
* test-suite/tests/ports.test ("valid wide mode string"): modified
Ludovic Courtès [Sat, 15 Dec 2018 17:04:27 +0000 (18:04 +0100)]
Do not warn the user when 'madvise' returns ENOSYS.
* libguile/vm.c (return_unused_stack_to_os): Avoid 'perror' calls when
'madvise' returns ENOSYS.
Daniel Llorens [Wed, 12 Dec 2018 07:01:05 +0000 (08:01 +0100)]
Fix tests for SRFI-19 date->string ~N
Daniel Llorens [Mon, 10 Dec 2018 10:57:05 +0000 (11:57 +0100)]
Support ~N in SRFI-19 string->date
* module/srfi/srfi-19.scm (fractional-integer-reader,
make-fractional-integer-reader): From reference implementation.
(reader-directives): Handle #\N, from reference implementation.
* test-suite/tests/srfi-19: Add tests for string->date ~N.
* doc/ref/srfi-modules.texi (string->date): Add line for ~N.
Mark H Weaver [Mon, 12 Nov 2018 04:07:47 +0000 (23:07 -0500)]
Update (ice-9 match) to include selected bug fixes from upstream.
Fixes <https://bugs.gnu.org/22925> and other bugs.
* module/ice-9/match.upstream.scm: Apply selected fixes from the
upstream match.scm in Chibi-Scheme.
* test-suite/tests/match.test.upstream: Add more tests from upstream.
Mark H Weaver [Mon, 12 Nov 2018 04:02:00 +0000 (23:02 -0500)]
Fix spelling of ellipsis in (ice-9 match).
* module/ice-9/match.upstream.scm: Change several occurrences
of 'ellipse' and 'ellipses' to 'ellipsis', to more closely match
match.scm from Chibi-Scheme.
Mikael Djurfeldt [Wed, 31 Oct 2018 18:08:58 +0000 (19:08 +0100)]
Documentation fixes
* doc/ref/api-control:
* doc/ref/compiler.texi: Language fixes
* doc/ref/compiler ($kfun): Renamed argument clauses -> clause.
Mikael Djurfeldt [Thu, 25 Oct 2018 11:53:47 +0000 (13:53 +0200)]
Bootstrap optimization
* bootstrap/Makefile.am: Build both eval.go and psyntax-pp.go before
the rest of the .go files so that they are handled by a fast macro
expander. This saves time for a parallel build.
Mikael Djurfeldt [Wed, 24 Oct 2018 18:56:16 +0000 (20:56 +0200)]
Add texinfo dependency to README
* README: Add texinfo dependency.
Mark H Weaver [Tue, 23 Oct 2018 00:19:39 +0000 (20:19 -0400)]
SRFI-19: Minor refactor of leap second table lookups.
* module/srfi/srfi-19.scm (leap-second-delta): Replace with ...
(utc->tai): ... this.
(leap-second-neg-delta): Replace with ...
(tai->utc): ... this.
(current-time-tai, priv:time-tai->time-utc!, priv:time-utc->time-tai!)
(time-tai->julian-day, time-monotonic->julian-day): Adapt accordingly.
Mark H Weaver [Mon, 22 Oct 2018 07:21:40 +0000 (03:21 -0400)]
SRFI-19: time-utc->date: Support non-integer nanoseconds values.
* module/srfi/srfi-19.scm (time-utc->date): Use 'floor-remainder'
instead of 'modulo'.
Mark H Weaver [Sun, 21 Oct 2018 23:38:18 +0000 (19:38 -0400)]
SRFI-19: Check for incompatible types in time comparisons.
Fixes <https://bugs.gnu.org/26163>.
Reported by Zefram <zefram@fysh.org>.
* module/srfi/srfi-19.scm (time-compare-check): New procedure.
(time=?): Use 'time-compare-check' to check the arguments and raise an
error in case of mismatched types. Previously, mismatched types would
cause time=? to return #f.
(time>?, time<?, time>=?, time<=?, time-difference!): Use
'time-compare-check' to check the arguments.
Mark H Weaver [Sun, 21 Oct 2018 23:21:47 +0000 (19:21 -0400)]
SRFI-19: Fix normalization of seconds and nanoseconds in time records.
Fixes <https://bugs.gnu.org/26162>.
Reported by Zefram <zefram@fysh.org>.
* module/srfi/srfi-19.scm (time-normalize!): Rewrite.
* test-suite/tests/srfi-19.test: Add tests.
Mark H Weaver [Sun, 21 Oct 2018 03:30:15 +0000 (23:30 -0400)]
SRFI-19: Add a few more tests.
This is a followup to commit
a58c7abd72648f77e4ede5f62a2c4e7969bb7f95.
* test-suite/tests/srfi-19.test: Add tests for large positive years.
Mark H Weaver [Sun, 21 Oct 2018 03:02:16 +0000 (23:02 -0400)]
SRFI-19: Fix handling of negative years and negative julian days.
Fixes <https://bugs.gnu.org/21906>.
Mitigates <https://bugs.gnu.org/21903> and <https://bugs.gnu.org/21904>.
Reported by: Zefram <zefram@fysh.org>.
* module/srfi/srfi-19.scm (encode-julian-day-number)
(decode-julian-day-number, date-week-number): Use 'floor-quotient'
instead of 'quotient', and 'floor' instead of 'truncate', where
appropriate.
(time-utc->date): Ensure that the 'nanoseconds' field of the returned
date is non-negative.
(leap-year): Handle negative years properly, and reformulate the
computation.
(week-day): Handle negative years properly. Use 'floor-quotient'
instead of 'quotient' where appropriate.
(directives): In the handler for '~Y' format escapes, improve the
handling of years outside of the range 0-9999.
(read-directives): Add a FIXME comment to fix the '~Y' reader to handle
years outside of the range 0-9999.
* test-suite/tests/srfi-19.test: Import (srfi srfi-1). Use Guile's
modern keyword notation in the 'define-module' form. Add more tests.
Mark H Weaver [Sat, 20 Oct 2018 07:34:56 +0000 (03:34 -0400)]
SRFI-19: Fix TAI->UTC conversions, leap second handling, etc.
Fixes <https://bugs.gnu.org/21911>.
Fixes <https://bugs.gnu.org/22034>.
Fixes <https://bugs.gnu.org/21902>.
Partially fixes <https://bugs.gnu.org/21904>.
Reported by Zefram <zefram@fysh.org>.
* doc/ref/srfi-modules.texi (SRFI-19 Introduction): Fix the definitions
of Julian Day and Modified Julian Day. Give the correct full names of
UTC and TAI.
* module/srfi/srfi-19.scm: Import (srfi srfi-1). Use modern Guile
keyword syntax in the 'define-module' form.
(leap-second-neg-delta): New procedure, derived from a similar procedure
in the latest upstream SRFI-19 reference implementation.
(priv:time-tai->time-utc!, time-tai->julian-day)
(time-monotonic->julian-day): Use 'leap-second-neg-delta'.
(local-tz-offset): Fix comment.
(leap-second?): Remove.
(tai-before-leap-second?): New procedure, derived from upstream SRFI-19.
(time-utc->date): Use 'define*' to handle the optional argument. Remove
the leap second handling, following upstream SRFI-19.
(time-tai->date): Rewrite in terms of 'time-utc->date'. Add special
leap second handling, following upstream SRFI-19.
(time-monotonic->date): Rewrite in terms of 'time-tai->date'.
(date->time-tai, date->time-monotonic): Add special leap second
handling, following upstream SRFI-19.
(directives): In the entry for the "~Y" escape in 'date->string', pad
the year field to 4 characters, following upstream SRFI-19.
* test-suite/tests/srfi-19.test: Add tests.
Mark H Weaver [Sat, 20 Oct 2018 01:54:34 +0000 (21:54 -0400)]
scm_seed_to_random_state: Support wide string arguments.
Partially fixes <https://bugs.gnu.org/33044>.
Reported by Tom de Vries <tdevries@suse.de>.
* libguile/random.c (scm_seed_to_random_state): Use 'scm_to_utf8_string'
(or 'scm_to_latin1_string' for a narrow string, for compatibility) to
convert the string into raw bytes for use by 'scm_c_make_rstate'. Make
sure the length in bytes fits within an 'int'.
Mark H Weaver [Sat, 20 Oct 2018 01:52:39 +0000 (21:52 -0400)]
Fix typo in strings.h.
* libguile/strings.h: In a comment, add the missing "i_" in
"scm_i_is_narrow_string".
Mark H Weaver [Sun, 14 Oct 2018 03:02:05 +0000 (23:02 -0400)]
Fix type inferencing for 'nil?' and 'null?' predicates.
Fixes <https://bugs.gnu.org/33036>.
Reported by <calcium@disroot.org>.
* module/language/cps/types.scm (define-simple-type-inferrer):
Apply (logand (&type val) <>) uniformly. Previously, this was done only
in the false branch. Rename local variable to 'type*', to allow the
macro operand 'type' to be an arbitrary expression.
(*type-inferrers*)<null?>: Add &nil to the set of possible types.
(*type-inferrers*)<nil?>: Add &false and &null to the set the possible
types.
* module/language/cps/type-fold.scm (*branch-folders*)<null?>: Add &nil
to the set of possible types.
(*branch-folders*)<nil?>: Add &false and &null to the set the possible
types.
* test-suite/tests/compiler.test: Add tests.
Mark H Weaver [Tue, 16 Oct 2018 06:34:18 +0000 (02:34 -0400)]
Use 'scm_from_utf8_{string,symbol,keyword}' for C string literals.
Partial fix for <https://bugs.gnu.org/33044>.
Reported by Tom de Vries <tdevries@suse.de>.
Fix several instances of the mistake of using 'scm_from_locale_*' for C
strings that originally came from a C string literal. Change several
uses of 'scm_from_latin1_*' as well, to promote the practice of writing
code that works for arbitrary C string literals.
Also add missing years to the copyright notices of changed files, based
on the git history.
* libguile/debug-malloc.c, libguile/deprecation.c, libguile/error.c,
libguile/eval.c, libguile/expand.c, libguile/extensions.c,
libguile/filesys.c, libguile/init.c, libguile/load.c,
libguile/modules.c, libguile/pairs.c, libguile/posix.c,
libguile/print.c, libguile/random.c, libguile/read.c,
libguile/regex-posix.c, libguile/snarf.h, libguile/srfi-13.c,
libguile/stacks.c, libguile/stime.c, libguile/strports.c,
libguile/values.c: Use 'scm_from_utf8_*' where appropriate.
Mark H Weaver [Tue, 16 Oct 2018 08:20:47 +0000 (04:20 -0400)]
Fix typos, indentation and error reporting in SRFI-19.
* module/srfi/srfi-19.scm: Fix typos in comments, indentation, and pass
the correct 'caller' name to 'time-error' in several places.
Mark H Weaver [Tue, 16 Oct 2018 06:50:30 +0000 (02:50 -0400)]
Update SRFI-19 leap second table.
* module/srfi/srfi-19.scm (leap-second-table): Update to include the
leap second on 1 January 2017.
Chris Marusich [Sun, 14 Oct 2018 07:47:23 +0000 (00:47 -0700)]
Clarify the manual's "Processes" section.
* doc/ref/posix.texi (Processes): Use the phrase "integer status value"
consistently, and add a cross-reference to the section of the glibc
manual that explains what it is.
Mark H Weaver [Sun, 14 Oct 2018 09:29:52 +0000 (05:29 -0400)]
In 'ash' and 'round-ash', handle right shift count of LONG_MIN.
Fixes <https://bugs.gnu.org/21901>.
Reported by Zefram <zefram@fysh.org>.
* libguile/numbers.c: Add another top-level 'verify' to ensure that
LONG_MIN is not a fixnum.
(scm_ash, scm_round_ash): Ensure that when the shift count is LONG_MIN,
it is not handled via the normal code path, to avoid signed overflow
when the shift count is negated.
* test-suite/tests/numbers.test: Add tests.
Mark H Weaver [Sun, 14 Oct 2018 09:24:14 +0000 (05:24 -0400)]
Fix 'round-ash' of negative integers by huge right shift counts.
This is a followup to commit
011aec7e240ef987931548d90c53e6692c85d01c.
When rounding, right shifting a negative integer by a huge shift count
results in 0, not -1.
* libguile/numbers.c: Add top-level 'verify' to ensure that the
assumptions in 'scm_ash' and 'scm_round_ash' are valid.
(scm_round_ash): In the case that handles huge right shifts, require
that the shift count _exceeds_ the integer length, and return 0 instead
of -1.
* test-suite/tests/numbers.test: Adjust tests accordingly.
Mark H Weaver [Sun, 14 Oct 2018 07:18:35 +0000 (03:18 -0400)]
Gracefully handle huge shift counts in 'ash' and 'round-ash'.
Fixes <https://bugs.gnu.org/32644>.
Reported by Stefan Israelsson Tampe <stefan.itampe@gmail.com>.
The need for this arose because the type inferrer for 'ursh' sometimes
passes (- 1 (expt 2 64)) as the second argument to 'ash'.
* libguile/numbers.c (scm_ash, scm_round_ash): Gracefully handle several
cases where the shift count does not fit in a C 'long'.
* test-suite/tests/numbers.test: Add tests.
Mark H Weaver [Sun, 14 Oct 2018 06:22:22 +0000 (02:22 -0400)]
Fix list validation of *list->bytevector procedures.
Fixes <https://bugs.gnu.org/32938>.
Reported by Josh Datko <jbd@cryptotronix.com>.
* libguile/validate.h (SCM_VALIDATE_LIST_COPYLEN)
(SCM_VALIDATE_NONEMPTYLIST_COPYLEN): Use '!=' instead of '>=' to
validate the result of 'scm_ilength' after it has been stored in
the user variable 'cvar'.
* test-suite/tests/bytevectors.test: Add tests. Use '#:use-module'
instead of ':use-module' in 'define-module' form.
Mark H Weaver [Sun, 14 Oct 2018 05:32:58 +0000 (01:32 -0400)]
Improve the documentation for 'nil?'.
* libguile/boolean.c (scm_nil_p): Improve docstring.
* doc/ref/api-languages.texi (Nil): Add documentation for 'nil?', along
with a description of how Elisp interprets Scheme booleans and
end-of-list.
Daniel Llorens [Wed, 10 Oct 2018 17:45:30 +0000 (19:45 +0200)]
Fix 32/64 bit bug in INTEGER_ACCESSOR_PROLOGUE
Mark H Weaver [Thu, 27 Sep 2018 05:00:11 +0000 (01:00 -0400)]
Fix 'atomic-box-compare-and-swap!'.
Fixes <https://bugs.gnu.org/32786>.
'scm_atomic_compare_and_swap_scm' is a thin wrapper around
'atomic_compare_exchange_weak' (where available), and therefore it may
spuriously fail on some platforms, leaving the atomic object unchanged
even when the observed value is equal to the expected value. Since
'scm_atomic_compare_and_swap_scm' returns both a boolean result and the
observed value, the caller is able to detect spurious failures when
using that API.
'atomic-box-compare-and-swap!' presents a simpler API, returning only
the observed value. The documentation advises callers to assume that
the exchange succeeded if the observed value is 'eq?' to the expected
value. It's therefore not possible to report spurious failures with
this API.
'atomic-box-compare-and-swap!' uses 'scm_atomic_compare_and_swap_scm',
and prior to this commit would simply ignore the boolean result and
return the observed value. In case of spurious failures, the caller
would legitimately conclude that the exchange had succeeded.
With this commit, 'atomic-box-compare-and-swap!' now retries in case of
spurious failures.
* libguile/atomic.c (scm_atomic_box_compare_and_swap_x): If
'scm_atomic_compare_and_swap_scm' returns false and the observed value
is equal to 'expected', then try again.
* libguile/vm-engine.c (atomic-box-compare-and-swap!): Ditto.
Ludovic Courtès [Sun, 23 Sep 2018 14:39:42 +0000 (16:39 +0200)]
Define AT_SYMLINK_NOFOLLOW et al.
* libguile/posix.c (scm_init_posix): Define AT_SYMLINK_NOFOLLOW,
AT_SYMLINK_FOLLOW, AT_NO_AUTOMOUNT, and AT_EMPTY_PATH when available.
(scm_utime): Mention AT_SYMLINK_NOFOLLOW.
* doc/ref/posix.texi (File System): Update accordingly.
* test-suite/tests/posix.test ("utime")["AT_SYMLINK_NOFOLLOW"]: New test.
Ludovic Courtès [Sun, 23 Sep 2018 14:28:29 +0000 (16:28 +0200)]
time: Use #: for 'define-module' clauses.
* module/ice-9/time.scm: Use #: instead of : in 'define-module' form.
Ludovic Courtès [Sun, 23 Sep 2018 14:27:32 +0000 (16:27 +0200)]
time: Support expressions that return any number of values.
* module/ice-9/time.scm (time-proc): Call PROC with 'call-with-values';
return all its values.
Ludovic Courtès [Sun, 23 Sep 2018 14:25:23 +0000 (16:25 +0200)]
time: Use 'syntax-rules' instead of 'define-macro'.
* module/ice-9/time.scm (time): Rewrite using 'define-syntax-rule'.
Mark H Weaver [Thu, 2 Aug 2018 14:05:17 +0000 (10:05 -0400)]
Fix R6RS call-with-{input,output}-file to open textual ports.
Fixes <https://bugs.gnu.org/32329>.
Reported and diagnosed by Göran Weinholt <goran@weinholt.se>.
* module/rnrs/io/simple.scm (call-with-input-file)
(call-with-output-file): Use 'open-{input,output}-file' to open the port
in textual mode. Previously 'open-file-{input,output}-port' was used,
which opened the port in binary mode.
Ludovic Courtès [Tue, 24 Jul 2018 10:07:03 +0000 (12:07 +0200)]
srfi-19: Remove unused procedure.
* module/srfi/srfi-19.scm (date->broken-down-time): Remove.
Ludovic Courtès [Tue, 24 Jul 2018 09:53:02 +0000 (11:53 +0200)]
Add -Wshadowed-toplevel.
* module/language/tree-il/analyze.scm (shadowed-toplevel-analysis): New
variable.
* module/language/tree-il/compile-cps.scm (%warning-passes): Add it.
* module/system/base/message.scm (%warning-types): Add it.
* test-suite/tests/tree-il.test ("warnings")["shadowed-toplevel"]: New
test prefix.
* module/ice-9/boot-9.scm (%auto-compilation-options): Add it.
* doc/ref/api-evaluation.texi (Compilation): Add 'shadowed-toplevel' and
'macro-use-before-definition'.
Ludovic Courtès [Fri, 20 Jul 2018 09:43:27 +0000 (11:43 +0200)]
r6rs-ports: 'put-bytevector' accepts 64-bit integers.
* libguile/r6rs-ports.c (scm_put_bytevector): Use 'size_t' for c_start,
c_count, and c_len.
Ludovic Courtès [Thu, 19 Jul 2018 15:58:39 +0000 (17:58 +0200)]
compile: Update copyright year.
* module/scripts/compile.scm (show-version): Update copyright year.
Ludovic Courtès [Thu, 19 Jul 2018 15:57:24 +0000 (17:57 +0200)]
compile: Improve error message.
* module/scripts/compile.scm (parse-args): Add missing newline in
"unrecognized option" message.
Ludovic Courtès [Thu, 19 Jul 2018 15:54:30 +0000 (17:54 +0200)]
compile: Add '-x' flag.
* module/scripts/compile.scm (%options, compile): Add '-x'.
* doc/ref/api-evaluation.texi (Compilation): Document it.
Ludovic Courtès [Thu, 19 Jul 2018 15:45:54 +0000 (17:45 +0200)]
r6rs-ports: Accept 'port-position' values greater than 2^32.
Reported by Ricardo Wurmus <rekado@elephly.net>.
Fixes <https://bugs.gnu.org/32161>.
* libguile/r6rs-ports.c (custom_binary_port_seek): Use 'scm_to_off_t'
instead of 'scm_to_int'.
* test-suite/tests/r6rs-ports.test ("8.2.7 Input Ports")["custom binary
input port position, long offset"]: New test.
Mark H Weaver [Thu, 5 Jul 2018 00:34:38 +0000 (20:34 -0400)]
Make srfi-71 visible through 'cond-expand'.
This is a followup to commit
eb90831ce81bcb85ae96d27011ebe71955cdf75d.
* module/srfi/srfi-71.scm: Add missing 'cond-expand-provide'.
Ludovic Courtès [Mon, 2 Jul 2018 08:58:22 +0000 (10:58 +0200)]
Update release docs.
* doc/release.org: Update web site instructions.
Ludovic Courtès [Sun, 1 Jul 2018 21:29:59 +0000 (23:29 +0200)]
Bump version for Guile 2.2.4.
* GUILE-VERSION (GUILE_MICRO_VERSION): Increment.
(LIBGUILE_INTERFACE_REVISION): Increment.
Ludovic Courtès [Sun, 1 Jul 2018 21:27:57 +0000 (23:27 +0200)]
build: Really build srfi/srfi-71.scm.
Commit
eb90831ce81bcb85ae96d27011ebe71955cdf75d added it to the wrong
makefile.
* module/Makefile.am (SOURCES): Add srfi/srfi-71.scm.
* module/srfi/Makefile.am: Remove. It's a leftover from the 2009 build
system rework in commit
3bb299b3f0d5b31957a6447d095ed723268019be.
Ludovic Courtès [Sun, 1 Jul 2018 21:23:09 +0000 (23:23 +0200)]
Update NEWS.
* NEWS: Update.
Ludovic Courtès [Sun, 1 Jul 2018 16:54:32 +0000 (18:54 +0200)]
Update copyright years in '--version' and the manual.
* module/ice-9/command-line.scm (version-etc): Change #:copyright-year
to 2018.
* doc/ref/guile.texi: Add 2017 and 2018 to the copyright years.
* configure.ac (GUILE_CONFIGURE_COPYRIGHT): Add 2018.
Ludovic Courtès [Sun, 1 Jul 2018 16:37:59 +0000 (18:37 +0200)]
Serialize accesses to submodule hash tables.
Fixes <https://bugs.gnu.org/30602>.
Previously, when compiling files in parallel like Guix does, threads
would be concurrently inserting, rehashing, and reading the submodule
hash table of module (). Thus, some threads would sometimes see an
inconsistent state, leading to errors such as:
Module named (system repl debug) does not exist
* module/ice-9/boot-9.scm (call-with-module-autoload-lock): Move higher
in the file.
(module-name): Use it around call to 'nested-define-module!'.
(resolve-module): Wrap the whole thing in 'call-with-module-autoload-lock'.
Ludovic Courtès [Fri, 29 Jun 2018 20:28:48 +0000 (22:28 +0200)]
vm: Fix stack-marking bug in multi-threaded programs.
Fixes <https://bugs.gnu.org/28211>.
* libguile/vm-engine.c (call, call_label, handle_interrupts): Add
'new_fp' variable; set the dynamic link and return address of the frame
at NEW_FP before setting 'vp->fp'. This fixes a bug whereby, in a
multi-threaded context, the stack-marking code could run after vp->fp
has been set but before its dynamic link has been set, leading the
stack-walking code in 'scm_i_vm_mark_stack' to exit early on.
Ludovic Courtès [Thu, 28 Jun 2018 15:14:08 +0000 (17:14 +0200)]
linker: Don't rely on out-of-range bv-ref exceptions.
* module/system/vm/linker.scm (find-shstrndx): Check whether NAME is
lower than the length of BV; remove 'false-if-exception' around
'string-table-ref' call.
Ludovic Courtès [Sun, 24 Jun 2018 21:40:08 +0000 (23:40 +0200)]
GDB support: Add 'guile-backtrace' command.
* libguile/libguile-2.2-gdb.scm <top level>: Add 'register-command!' call.
Ludovic Courtès [Sun, 24 Jun 2018 21:34:58 +0000 (23:34 +0200)]
GDB support: Add note about (gdb frame-filters).
* libguile/libguile-2.2-gdb.scm <top level>: Add comment.
Ludovic Courtès [Sun, 24 Jun 2018 21:22:52 +0000 (23:22 +0200)]
GDB support: Fix 'display-vm-frames'.
Previously 'vm-frame-older' would fail to traverse the chain of frames.
* libguile/libguile-2.2-gdb.scm (uint-type): New variable
(vm-frame): Fix "saved ip" and "saved fp" computation. The latter had
been broken roughly since commit
72353de77d0a06f158d8af66a2540015658e2574.
(vm-frame-older): Return #f when IP is zero, not when FP is zero.
(vm-frame-function-name): Wrap 'vm-frame-program-debug-info' in
'false-if-exception'
Ludovic Courtès [Sun, 24 Jun 2018 13:31:05 +0000 (15:31 +0200)]
types: Recognize 'scm_t_port_type' and decode port type name.
* module/system/base/types.scm (read-c-string, inferior-port-type): New
procedures.
(inferior-port): Use 'inferior-port-type' to determine the port type.
(cell->object): Rename 'flags+type' to 'flags' in the '%tc7-port' case.
* test-suite/tests/types.test ("opaque objects"): Adjust port testse.
(test-inferior-ports): New macro.
("ports"): New test prefix.
Ludovic Courtès [Sun, 24 Jun 2018 10:32:13 +0000 (12:32 +0200)]
vm: Fix another typo.
Fix typo introduced in
efc33cd1497c00c5ebf961e834efc1d85f3e28ac.
* libguile/vm.c (return_unused_stack_to_os): Remove extra 'while'.
Arun Isaac [Thu, 21 Jun 2018 17:27:18 +0000 (22:57 +0530)]
web: Export http-request.
* module/web/client.scm (request): Rename to http-request, add a
docstring, and export it.
(http-get, http-head, http-post, http-put, http-delete, http-trace,
http-options): Update docstring.
* doc/ref/web.texi (Web Client): Document http-request.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Ludovic Courtès [Tue, 19 Jun 2018 12:52:46 +0000 (14:52 +0200)]
Add 'scm_to_stringn' shortcut when converting to UTF-8.
* libguile/strings.c (scm_to_stringn): Call 'scm_to_utf8_stringn' when
ENCODING == "UTF-8".
Ludovic Courtès [Mon, 18 Jun 2018 15:39:35 +0000 (17:39 +0200)]
Module import obarrays are accessed in a critical section.
Fixes <https://bugs.gnu.org/31879>.
* libguile/modules.c (import_obarray_mutex): New variable.
(resolve_duplicate_binding, module_imported_variable): Acquire it before
accessing an obarray.
Ludovic Courtès [Mon, 18 Jun 2018 15:27:32 +0000 (17:27 +0200)]
tests: Adjust i18n.test to 'fr_FR.utf8' locale in glibc 2.27.
* test-suite/tests/i18n.test (french-number-string=?): New procedure.
("number->locale-string")["French"]("integer", "negative integer")
("fraction", "fraction, 1 digit"): Use it.
("format ~h")["French"]("12345.678"): Likewise.
("monetary-amount->locale-string")["French"]("integer", "fraction"):
Check for both SPACE and NO-BREAK SPACE.
Arun Isaac [Fri, 23 Mar 2018 14:22:04 +0000 (19:52 +0530)]
doc: Document (ice-9 match) macros.
* doc/ref/match.texi: Document match-lambda, match-lambda*, match-let,
match-let* and match-letrec.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>