* module/ice-9/psyntax.scm (resolve-identifier): There is a case where a
syntax object can resolve to itself. Prevent an infinite loop in that
case by continuing to resolve by name.
* module/ice-9/psyntax-pp.scm: Regenerate.
* test-suite/tests/syncase.test ("infinite loop bug"): Add a test.
* libguile/goops.h (SCM_VTABLE_FLAG_GOOPS_STATIC): Reserve the fourth
GOOPS flag to indicate that a class has static slot allocation.
* libguile/goops.c (scm_init_goops_builtins): Define
vtable-flag-goops-static for goops.scm.
* module/oop/goops.scm (class-has-statically-allocated-slots?): New
helper.
(build-slots-list): Instead of the ad-hoc checks for <class> or
<slot>, use the new helper.
(initialize): Accept #:static-slot-allocation? keyword.
* module/system/foreign-object.scm (make-foreign-object-type): Declare
foreign object classes as having static slot allocation.
* test-suite/tests/goops.test ("static slot allocation"): Add tests.
* libguile/goops.c (is_accessor_method, scm_compute_applicable_methods):
Fix regression from 51f66c9120 (2009).
Accessor methods are added on each subclass on which the slot is
present; therefore if a subclass doesn't have a method, then the
methods doesn't apply. Truly fixes#17355, unlike
583a23bf10.
* module/oop/goops.scm (compute-cmethod, compute-getter-method)
(compute-setter-method): Revert earlier changes.
* test-suite/tests/goops.test ("accessor slots"): Update for new
expectations, in agreement with Guile 1.8.
* module/oop/goops/compile.scm: Inline into goops.scm, leaving a
compatible interface stub behind.
* module/oop/goops/dispatch.scm: Don't import (oop goops compile), to
break circularities.
* module/oop/goops.scm: Move (oop goops util) include up to the top, and
import (ice-9 match).
(compute-cmethod): Move here from compile.scm. Add a special case for
accessor methods, so as to fix bug #17355.
(compute-getter-method, compute-setter-method): #:procedure slot is
now generic.
* test-suite/tests/goops.test ("accessor slots"): New test.
Fixes bug #17355.
* module/oop/goops.scm (memoize-effective-method!): Adapt to
compute-effective-method change.
(compute-effective-method, %compute-effective-method): Renamed from
compute-cmethod; now a generic protocol.
(compute-specialized-effective-method)
(%compute-specialized-effective-method): New sub-protocol.
(memoize-generic-function-application!): Adapt to call the hard-wired
compute-applicable-methods based on the concrete arguments types --
the semantics is that %compute-applicable-methods is the
implementation for <generic> functions. Perhaps we should do the same
for sort-applicable-methods and method-more-specific?.
(compute-getter-method, compute-setter-method): The standard
#:procedure is now a generic slot-ref. It wasn't valid to inline
field access here, because subtypes could have different field
layouts.
(compute-applicable-methods): Refactor generic definition to use
lexical scoping.
(compute-specialized-effective-method): New method for
<accessor-method>, which does field access inlining based on the
concrete types being applied.
* test-suite/tests/goops.test ("accessor slots"): New test.
* module/oop/goops.scm (fold-class-slots): Change format to use proper
slot specifications.
(fold-slot-slots): Flesh out with all needed slots.
(<class>): Update cons-layout to deal with new fold-class-slots form.
Don't create slots; we do that later.
(is-a?, get-keyword, *unbound, unbound?, %allocate-instance): Move
definitions up.
(<slot>, slot?): New definitions.
(slot-definition-name, slot-definition-allocation)
(slot-definition-init-keyword, slot-definition-init-form)
(slot-definition-init-value, slot-definition-init-thunk)
(slot-definition-options, slot-definition-getter)
(slot-definition-setter, slot-definition-accessor)
(slot-definition-slot-ref, slot-definition-slot-set!)
(slot-definition-index, slot-definition-size): New definitions as
accessors on <slot> objects.
(class-slot-definition): Adapt to class-slots change.
(direct-slot-definition-class, make-slot): New definitions.
(make): Define a boot version that can allocate <slot> instances.
(compute-direct-slot-definition)
(compute-direct-slot-definition-initargs)
(effective-slot-definition-class, compute-effective-slot-definition):
New definitions.
(build-slots-list): Adapt to slots being <slot> objects.
(compute-get-n-set): New boot definition.
(allocate-slots): New definition. Replaces
compute-getters-n-setters.
(%compute-layout, %prep-layout): Adapt to changes.
(make-standard-class): Make <slot> objects for direct-slots, and
handle the allocate-slots protocol.
(<foreign-slot>): Inherit from <slot>.
(get-slot-value-using-name, set-slot-value-using-name!)
(test-slot-existence): Adapt to using slot definition objects.
(make-class): Allow slot specs or <slot> objects as the `slots'
argument.
(write): New method on <slot>.
(class-slot-ref, class-slot-set!): Reimplement.
(compute-slot-accessors, compute-getter-method)
(compute-setter-method): Adapt to changes.
(compute-getters-n-setters): Remove. Yay!
(compute-get-n-set): Adapt to use effective slot definitions instead
of the getters-n-setters for #:class / #:each-subclass allocation.
(%initialize-object): Adapt.
(initialize): New method for <slot>. Adapt method for <class>.
* module/oop/goops/active-slot.scm (compute-get-n-set):
* module/oop/goops/composite-slot.scm (compute-propagated-get-n-set):
Use slot-definition-options to access options of slot.
* test-suite/tests/goops.test ("bad init-thunk"): Fix to be a "pass-if"
instead of an "expect-fail".
* test-suite/tests/goops.test: Add tests for compute-cpl based on
comments from goops.scm.
* module/oop/goops.scm (compute-std-cpl): Remove comment, and add
docstring.
(compute-cpl): Improve comment.
* test-suite/tests/coverage.test ("several times", "one proc hit, one
proc unused"): Mark as XFAIL until we can fix either the expander or
the compiler to have proper source info.
Allocating an instance of a class with a #:class or #:each-subclass slot
allocation should not re-initialize the class-allocated slot. In Guile
1.8, this worked by effectively doing a slot-bound? within
%initialize-object. In Guile 2.0 we instead initialize the slot when it
is allocated -- in compute-get-n-set.
* module/oop/goops.scm (compute-getters-n-setters): Don't set an
init-thunk for class-allocated slots.
(compute-get-n-set): Initialize class-allocated slots here, if an
init-thunk or init-value are present.
* test-suite/tests/goops.test ("#:each-subclass"): Add test.
Fixes <http://bugs.gnu.org/19621>.
Before that, in 'cbip_fill_input', BUFFERED would be set to 0 when
reading from 'scm_getc' et al, because 'shortbuf' was being used. Thus,
we could eventually execute this line:
/* Copy the data back to the internal buffer. */
memcpy ((char *) c_port->read_pos, SCM_BYTEVECTOR_CONTENTS (bv),
c_octets);
But 'read_pos' would quickly point to the fields beyond 'shortbuf',
thereby leading to a corruption of the 'scm_t_port' itself.
* libguile/r6rs-ports.c (cbip_setvbuf): When READ_SIZE is 0, keep using
BV as the 'read_buf'.
(cbip_fill_input): Adjust assertion to accept 'read_buf_size = 1'.
* test-suite/tests/r6rs-ports.test ("7.2.7 Input Ports")["custom binary
input port unbuffered & 'get-string-all'", "custom binary input port
unbuffered UTF-8 & 'get-string-all'"]: New tests.
Fixes <http://bugs.gnu.org/19027>.
* libguile/bytevectors.c (scm_bytevector_fill_x): Accept fill arguments
between -128 and 255.
* test-suite/tests/bytevectors.test ("2.2 General Operations"): Add
tests.
* module/texinfo.scm (texi-command-specs): The body of @url{} can have
texinfo commands.
* test-suite/tests/texinfo.test ("test-texinfo->stexinfo"): Add tests.
* module/web/uri.scm (validate-uri): Add reference? keyword argument,
for validating references.
(build-uri): Clarify comments to indicate that the result is an
absolute URI.
(build-uri-reference): New interface, to build URI-references.
(string->uri-reference): Rename from string->uri*. Fix fragment
parsing to not include the #.
(string->uri): Adapt to string->uri-reference name change.
* module/web/request.scm (request-absolute-uri): Add default-scheme
optional argument. Use it if the request-uri has no scheme, or
error.
* module/web/http.scm (write-uri): Reflow to use "when". Fix writing of
URI-reference instances.
(declare-uri-reference-header!): Rename from
declare-relative-uri-header!. Use string->uri-reference.
("Location"): Declare as a URI-reference header, as per RFC 7231.
* module/web/client.scm (open-socket-for-uri): Handle the case in which
there is no URI scheme.
* test-suite/tests/web-http.test:
* test-suite/tests/web-uri.test: Add tests.
Suggested by David Kastrup <dak@gnu.org> in <http://bugs.gnu.org/13644>.
* libguile/read.c (scm_read_string_like_syntax): Accept "\(" as
equivalent to "(".
* doc/ref/api-data.texi (String Syntax): Document it.
* test-suite/tests/reader.test ("reading"): Add test.
Fixes <http://bugs.gnu.org/17634>.
Reported by Josep Portella Florit <jpf@primfilat.com>.
* module/language/tree-il/peval.scm (inlined-application): When inlining
an application whose operator is a lambda expression with optional
arguments that rely on default initializers, expand into a series of
nested let expressions, to ensure that previous arguments are in scope
when the default initializers are evaluated.
* test-suite/tests/peval.test ("partial evaluation"): Add tests.
Fixes <http://bugs.gnu.org/18299>.
Reported by Frank Terbeck <ft@bewatermyfriend.org>.
* module/language/tree-il/analyze.scm (format-string-argument-count):
Add case for ~p.
* test-suite/tests/tree-il.test ("warnings")["format"]("~p", "~p, too
few arguments", "~:p", "~:@p, too many arguments", "~:@p, too few
arguments"): New tests.
* test-suite/tests/coding.test (with-temp-file): Instead of
hard-coding "/tmp" as the temporary directory, use $TMPDIR or
$TEMP from the environment, and fall back on "/tmp" if none of
those 2 is defined.
Suggested by Dale P. Smith.
* module/system/base/target.scm (cpu-endianness): Add cases for
"arm.*eb", "^aarch64.*be", and "aarch64". Change "arm" case to
"arm.*".
(triplet-pointer-size): Allow underscore as in 'aarch64_be'.
* test-suite/tests/asm-to-bytecode.test ("cross-compilation")["armeb-unknown-linux-gnu",
"aarch64-linux-gnu", "aarch64_be-linux-gnu"]: New tests.
* libguile/bitvectors.c (scm_bit_count_star): Fix typo introduced in
2005 refactor (!) in which the second arg was erroneously taken from
the first arg.
* test-suite/tests/bitvectors.test: Add test.
* doc/ref/api-compound.texi: Fix doc example for u32vector selector.
Reported by Sylvain Beucler <beuc@beuc.net>.
* configure.ac: Check for 'pthread_cancel'.
* libguile/threads.c (scm_cancel_thread): Conditionalize on
!SCM_USE_PTHREAD_THREADS || defined HAVE_PTHREAD_CANCEL.
* test-suite/tests/threads.test (require-cancel-thread): New procedure.
("timed joining fails if timeout exceeded", "join-thread returns
timeoutval on timeout", "cancel succeeds", "handler result passed to
join", "can cancel self"): Use it.
Reported by Sylvain Beucler <beuc@beuc.net>.
* module/system/base/target.scm (cpu-endianness): Add case where CPU is
"arm".
* test-suite/tests/asm-to-bytecode.test ("cross-compilation")["arm-unknown-linux-androideabi"]:
New test.
* libguile/load.c (scm_i_mirror_backslashes): New function.
(scm_init_load_path): Call it to produce MS-Windows file names
with forward slashes.
(FILE_NAME_SEPARATOR_STRING): Define as "/" on all platforms.
* libguile/load.h (scm_i_mirror_backslashes): Add prototype.
* libguile/init.c (scm_boot_guile): Call scm_i_mirror_backslashes
on argv[0].
* libguile/filesys.c (scm_getcwd): Call scm_i_mirror_backslashes
on the directory name returned by getcwd.
* test-suite/tests/ports.test ("file name separators"): New test.
* test-suite/tests/ports.test ("fdes->port", "seek")
("truncate-file"): Close every file and port we open, to avoid
failure to delete the test file on MS-Windows when the test is
completed.
* libguile/bitvectors.c (scm_bit_count_star): Fix typo introduced in
2005 refactor (!) in which the second arg was erroneously taken from
the first arg.
* test-suite/tests/bitvectors.test: Add test.
* doc/ref/api-compound.texi: Fix doc example for u32vector selector.
* test-suite/tests/i18n.test (mingw?): New variable.
(%french-locale-name, %french-utf8-locale-name,
%turkish-utf8-locale-name, %german-utf8-locale-name,
%greek-utf8-locale-name): Add name of corresponding Windows codepage,
when MINGW? is true.
(under-turkish-utf8-locale-or-unresolved): Add exception for
"mingw32".
Co-authored-by: Eli Zaretskii <eliz@gnu.org>
Reported by Eli Zaretskii <eliz@gnu.org>.
* test-suite/test-suite/lib.scm (%null-device): New variable.
* test-suite/tests/c-api.test (egrep): Use %NULL-DEVICE instead of
/dev/null.
* test-suite/tests/popen.test ("open-input-pipe")["no duplicate"]:
Likewise.