1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
Commit graph

19988 commits

Author SHA1 Message Date
Andy Wingo
909c0077cc Correctly handle overflow when emitting literal pools 2019-05-27 11:34:13 +02:00
Andy Wingo
d1c2d7de2f Switch to use atomic_compare_exchange_strong
* libguile/atomics-internal.h (scm_atomic_compare_and_swap_scm): Change
  to use same API as atomic-box-compare-and-swap!.
* libguile/intrinsics.c (atomic_compare_and_swap_scm): Remove loop, as
  we're using the strong variant now.
* libguile/async.c (scm_i_async_pop, scm_i_async_push): Adapt to new API
  of scm_atomic_compare_and_swap_scm.
2019-05-25 17:17:49 +02:00
Andy Wingo
8b8ce79e83 Bump version to 2.9.2
* GUILE-VERSION (GUILE_MICRO_VERSION): Bump.
2019-05-23 21:05:21 +02:00
Andy Wingo
6880ced4c2 Reference Lightening instead of GNU Lightning
* doc/ref/vm.texi (Just-In-Time Native Code): Update with link to
  Lightening.
2019-05-23 21:00:20 +02:00
Andy Wingo
ee28c0680d Merge until 65d98d8fd from 'stable-2.2'
This marks stable-2.2 as merged up to 65d98d8fd, though the merge was
done via cherry-picks.
2019-05-23 20:47:01 +02:00
Mark H Weaver
b94c5f8e05 Update iconv.m4 from gnulib.
* m4/iconv.m4: Update from gnulib-v0.1-2176-ga79f2a287.
2019-05-23 17:51:52 +02:00
Mark H Weaver
bd50407d1f 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.
2019-05-23 17:51:36 +02:00
Mark H Weaver
2bfa4f73f1 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'.
2019-05-23 17:49:10 +02:00
Mark H Weaver
a3a726c868 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.
2019-05-23 17:48:55 +02:00
Mark H Weaver
c6692a4825 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.
2019-05-23 17:48:55 +02:00
Mark H Weaver
66ffd93dcf Fix indentation in scm_sum. 2019-05-23 17:48:55 +02:00
Mark H Weaver
506c70e72b Fix typo in comment. 2019-05-23 17:48:55 +02:00
Mark H Weaver
d5c420a888 Add 'scm_c_make_char' and use it where appropriate.
This reverts the change to SCM_MAKE_CHAR made in the previous commit
63818453ad, 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),
2019-05-23 17:48:46 +02:00
Mark H Weaver
7e208c8f25 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.
2019-05-23 17:41:48 +02:00
Andrea Azzarone
fd4ba18bca 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.
2019-05-23 17:41:10 +02:00
Mark H Weaver
cca381ce17 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.
2019-05-23 17:40:59 +02:00
Mark H Weaver
980d8265c2 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.
2019-05-23 17:40:08 +02:00
Mark H Weaver
b38d9a1527 Fix typo in comment.
* module/ice-9/boot-9.scm: Fix typo.
2019-05-23 17:32:20 +02:00
Michael Gran
d4fd9adcac Disable test for current value of setitimer on Cygwin
* test-suite/tests/signals.test ("current itimers are 0"): throws unresolved
    for cygwin
2019-05-23 17:32:17 +02:00
Michael Gran
42bc255224 Make locale monetary conversion tests be less strict on terminal whitespace
* test-suite/tests/i18n.test (monetary-amount->locale-string): modified
2019-05-23 17:32:15 +02:00
Michael Gran
69bc964d7b 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
2019-05-23 17:32:08 +02:00
Michael Gran
f169f64004 Add a fallback value for the locale-monetary-decimal-point
* module/ice-9/i18n.scm (locale-monetary-decimal-point): use "." as fallback
2019-05-23 17:31:23 +02:00
Mike Gran
a5df94e78c 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
2019-05-23 17:30:33 +02:00
Mike Gran
08926cdcd0 Avoid leaking a file descriptor in test-unwind
* test-suite/standalone/test-unwind.c (check_ports): explicitly close temp file
2019-05-23 17:29:52 +02:00
Mike Gran
99dd8c9020 Fix strftime compile with null threads
* libguile/stime.c (scm_strftime): use correct pthread lock function
2019-05-23 17:16:54 +02:00
Mike Gran
8f254172ad Remove redefinition of when & unless in snarf-check-and-output-texi
* module/scripts/snarf-check-and-output-texi.scm (when, unless): removed
2019-05-23 17:16:30 +02:00
Mike Gran
9a7e66eceb Don't mutate read-only string in ports test
* test-suite/tests/ports.test ("valid wide mode string"): modified
2019-05-23 17:16:08 +02:00
Ludovic Courtès
abeeec74b2 Do not warn the user when 'madvise' returns ENOSYS.
* libguile/vm.c (return_unused_stack_to_os): Avoid 'perror' calls when
'madvise' returns ENOSYS.
2019-05-23 17:16:02 +02:00
Daniel Llorens
1b0fcddba5 Fix tests for SRFI-19 date->string ~N 2019-05-23 17:14:29 +02:00
Daniel Llorens
347ec3f088 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.
2019-05-23 17:14:27 +02:00
Mark H Weaver
4f3aa81617 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.
2019-05-23 17:14:26 +02:00
Mark H Weaver
ba6e31e75f 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.
2019-05-23 17:14:24 +02:00
Mikael Djurfeldt
a83de07e35 Documentation fixes
* doc/ref/api-control:
* doc/ref/compiler.texi: Language fixes
* doc/ref/compiler ($kfun): Renamed argument clauses -> clause.
2019-05-23 17:14:21 +02:00
Mikael Djurfeldt
af1d55bcca 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.
2019-05-23 17:13:19 +02:00
Mikael Djurfeldt
9c10b423a8 Add texinfo dependency to README
* README: Add texinfo dependency.
2019-05-23 17:13:15 +02:00
Mark H Weaver
f13e2cb8ad 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.
2019-05-23 17:13:14 +02:00
Mark H Weaver
f9df551574 SRFI-19: time-utc->date: Support non-integer nanoseconds values.
* module/srfi/srfi-19.scm (time-utc->date): Use 'floor-remainder'
instead of 'modulo'.
2019-05-23 17:13:12 +02:00
Mark H Weaver
8e0dfaca19 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.
2019-05-23 17:13:11 +02:00
Mark H Weaver
0389c59bd4 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.
2019-05-23 17:13:09 +02:00
Mark H Weaver
8361d59d1c SRFI-19: Add a few more tests.
This is a followup to commit a58c7abd72.

* test-suite/tests/srfi-19.test: Add tests for large positive years.
2019-05-23 17:13:07 +02:00
Mark H Weaver
db78033cc1 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.
2019-05-23 17:13:05 +02:00
Mark H Weaver
e00563492a 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.
2019-05-23 17:13:03 +02:00
Mark H Weaver
4e24cca595 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'.
2019-05-23 17:11:40 +02:00
Mark H Weaver
dcf8389a5a Fix typo in strings.h.
* libguile/strings.h: In a comment, add the missing "i_" in
"scm_i_is_narrow_string".
2019-05-23 17:11:31 +02:00
Mark H Weaver
0e750990dd Add tests for type inferencing for 'nil?' and 'null?' predicates.
These tests come from a fix for <https://bugs.gnu.org/33036>, which was
fixed already in the 2.9.x branch.

* test-suite/tests/compiler.test: Add tests.
2019-05-23 16:59:54 +02:00
Mark H Weaver
3ae69f3063 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.
2019-05-23 16:41:53 +02:00
Mark H Weaver
a47a5e6828 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.
2019-05-23 16:09:53 +02:00
Mark H Weaver
d61da427e1 Update SRFI-19 leap second table.
* module/srfi/srfi-19.scm (leap-second-table): Update to include the
leap second on 1 January 2017.
2019-05-23 16:09:51 +02:00
Chris Marusich
3c87313628 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.
2019-05-23 16:09:49 +02:00
Mark H Weaver
00973cbd2e 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.
2019-05-23 16:09:45 +02:00