* libguile/load.c (load_thunk_from_path, try_load_thunk_from_file): New
functions.
(search_path): Simplify.
(scm_primitive_load_path, scm_init_eval_in_scheme): Use the new
functions to load compiled files.
* module/ice-9/boot-9.scm (load-in-vicinity): Skip invalid .go files.
Inspired by a patch from Jan Nieuwenhuizen <janneke@gnu.org>.
* libguile/load.c (compiled_is_fresh): Write warnings to warning port.
Move up in the file.
(search_path): Add ability to skip over matching files in the path
that are stale, relative to some other corresponding file.
(scm_search_path, scm_sys_search_load_path): Adapt to search_path
changes.
(do_try_auto_compile): Write status to warning port.
(scm_primitive_load_path): Use new search_path ability to skip over
stale files. Allows updates to source files to use freshly-compiled
bootstrap files, when building Guile itself. Also allows
simplification of fallback logic.
(scm_init_eval_in_scheme): Skip stale eval.go files in the path.
* libguile/load.c (stringbuf_free): Remove.
(stringbuf_grow): Use 'scm_gc_malloc_pointerless' instead of 'scm_realloc'.
(search_path): Use stack-allocated INITIAL_BUFFER instead of
'scm_malloc'. Remove use of 'stringbuf_free'.
* libguile/load.c (scm_c_string_has_an_ext): Rename to...
(string_has_an_ext): ... this. Add docstring. Change
'str' to be an SCM, and remove 'len' parameter. Change loop body to
use 'scm_string_suffix_p'.
(search_path): Update accordingly.
* 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.
* libguile/load.c (is_file_name_separator, is_drive_letter):
(is_absolute_file_name): New helpers, like the ones in boot-9.
Perhaps we should just define them in C.
(search_path, scm_try_auto_compile, canonical_suffix): Rewrite using
the new helpers.
* libguile/ports.h:
* libguile/ports.c (scm_consume_byte_order_mark): New procedure.
* libguile/fports.c (scm_open_file): Call consume-byte-order-mark if we
are opening a file in "r" mode.
* libguile/read.c (scm_i_scan_for_encoding): Don't do anything about
byte-order marks.
* libguile/load.c (scm_primitive_load): Add a note about the duplicate
encoding scan.
* test-suite/tests/filesys.test: Add tests for UTF-8, UTF-16BE, and
UTF-16LE BOM handling.
* libguile/load.c (scm_primitive_load_path): If the second argument is a
procedure, call it like a thunk.
* doc/ref/api-evaluation.texi (Load Paths): Update docs.
* module/ice-9/boot-9.scm (resolve-interface): Use `unless'.
(try-module-autoload): Use the new primitive-load-path to detect
failure to find an appropriate file. Fixes a bug reported by Diogo
F. S. Ramos. Thanks to Noah Lavine for tracking it down.
* libguile/load.c (scm_ellipsis): New Variable.
(scm_parse_path_with_ellipsis): New procedure.
(scm_init_load): Initialize 'scm_ellipsis'.
(scm_init_load_path): Use 'scm_parse_path_with_ellipsis' to
handle GUILE_LOAD_PATH and GUILE_LOAD_COMPILED_PATH.
* libguile/load.h (scm_parse_path_with_ellipsis): Add prototype.
* doc/ref/guile-invoke.texi (Environment Variables):
doc/ref/api-evaluation.texi (Load Paths): Add documentation.
Correct description of default load path to reflect reality.
Remove 'GUILE_LOAD_PATH' from the concept index; it is already
in the variable index. Add cross references between these two
sections of the manual.
* libguile/load.c (search_path): When the provided 'filename' is an
absolute pathname, perform a 'stat' on that pathname to fill the
'stat_buf'. Previously, 'stat_buf' was left uninitialized in this
case, even though 'scm_primitive_load_path' assumes that 'stat_buf'
will be filled. Update the header comment to explicitly specify that
'stat_buf' will be filled. Also 'goto end' in a few failure cases
instead of replicating its code.
* libguile/load.c (scm_primitive_load): Return the values yielded from
evaluating the last expression in the file.
* test-suite/tests/load.test ("return value of `load'"): Add tests.
* libguile/ports.c (scm_putc, scm_puts):
* libguile/ports.h (scm_putc_unlocked, scm_puts_unlocked): Separate into
_unlocked and locked variants. Change all callers to use the
_unlocked versions.
* libguile/tags.h (SCM_UNPACK_POINTER, SCM_PACK_POINTER): New macros.
The old SCM2PTR and PTR2SCM were defined in such a way that
round-tripping through a pointer could lose precision, even in the
case in which you weren't interested in actually dereferencing the
pointer, it was simply that you needed to plumb a SCM through APIs
that take pointers. These new macros are more like SCM_PACK and
SCM_UNPACK, but for pointer types. The bit representation of the
pointer should be the same as the scm_t_bits representation.
* libguile/gc.h (PTR2SCM, SCM2PTR): Remove support for (old) UNICOS
pointers. We are going to try tagging the SCM object itself in the
future, and I don't think that keeping this support is worth its
cost. It probably doesn't work anyway.
* libguile/backtrace.c:
* libguile/bytevectors.c:
* libguile/continuations.c:
* libguile/fluids.c:
* libguile/foreign.c:
* libguile/gc.h:
* libguile/guardians.c:
* libguile/hashtab.c:
* libguile/load.c:
* libguile/numbers.c:
* libguile/ports.c:
* libguile/smob.c:
* libguile/strings.c:
* libguile/symbols.c:
* libguile/vm.c:
* libguile/weak-set.c:
* libguile/weak-table.c:
* libguile/weak-vector.c: Update many sites to use the new macros.
* libguile/load.c (search_path): Extract from scm_search_path, to
give the caller the stat buffer of the found path.
(scm_search_path, scm_sys_search_load_path): Adapt accordingly.
(compiled_is_fresh): Take the stat buffers directly.
(scm_primitive_load_path, scm_init_eval_in_scheme): Adapt to
search_path / compiled_is_fresh changes to avoid duplicate states in
search-path.
* libguile/load.c (scm_primitive_load_path): Don't canonicalize the
filename unless we need to look in the fallback path. Fixes a stat
explosion; see http://savannah.gnu.org/bugs/?33815.
* libguile/Makefile.am (libpath.h): Define SCM_SITE_CCACHE_DIR. Defined
as site-ccache/ instead of site/ccache/ to indicate that we don't expect
further subdirectories, and also to avoid confusion about whether
extensions/ is a site-specific or not.
* libguile/load.c (scm_init_load_path): Add SCM_SITE_CCACHE_DIR to the
default load-compiled path.
* libguile/load.c (canonical_to_suffix, scm_primitive_load_path):
* module/ice-9/boot-9.scm (load-in-vicinity):
* module/system/base/compile.scm (compiled-file-name): If the canonical
path of a file is a DOS-style path with a drive letter, turn it into a
path suffix it by removing the colon and prefixing a "/".
Inspired by a patch from Jan Nieuwenhuizen.
* doc/ref/api-evaluation.texi (Compilation): Add discussion of
--fresh-auto-compile.
* doc/ref/scheme-scripts.texi (Invoking Guile): Add --fresh-auto-compile
option.
* NEWS: Add entry.
* libguile/load.c: Define %fresh-auto-compile.
(scm_primitive_load_path): Use it here.
(scm_init_load_should_auto_compile): Init from GUILE_AUTO_COMPILE env
var, with a value of "fresh".
* module/ice-9/boot-9.scm (load-in-vicinity): Auto-compilation cache is
stale if %fresh-auto-compile is true.
* module/ice-9/command-line.scm (compile-shell-switches): Parse out
--fresh-auto-compile.