* doc/ref/api-data.texi (Arrays as arrays of arrays): Clarify
ambiguities, fix examples.
* libguile/arrays.c (make-shared-array): Make error messages specific to
each error case, report relevant arguments.
(array_from_pos): Return NULL on error instead of reporting error
ourselves.
(array_from_get_o): Handle the trivial case.
(scm_array_slice, scm_array_cell_ref, scm_array_cell_set_x): Don't
build error arguments before error happens. Let array_from_get_o
handle the trivial case.
Fixes <https://bugs.gnu.org/67063>.
* doc/ref/api-io.texi (Venerable Port Interfaces): Bring unread-string
procedure documentation in line with other procedures in the section.
* libguile/ports.c (scm_unread_string): Make port argument optional.
* test-suite/tests/ports.test: Test unread-char and unread-string
without ports.
* NEWS: Update.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* libguile/ports.c (scm_seek): Let SEEK_DATA and SEEK_HOLE through.
(scm_init_ice_9_ports): Define ‘SEEK_DATA’ and ‘SEEK_HOLE’.
* module/ice-9/ports.scm: Export ‘SEEK_DATA’ and ‘SEEK_HOLE’ when
defined.
* test-suite/tests/ports.test ("size of sparse file")
("SEEK_DATA while on data", "SEEK_DATA while in hole")
("SEEK_HOLE while in hole"): New tests.
* NEWS: Update.
* doc/ref/api-procedures.texi: remove make-binding, binding:name,
binding:boxed?, binding:index, binding:start, and binding:end since they
no longer exist.
cf. 1a2711a848
On modern file-systems (BTRFS, ZFS) it is possible to copy a file using
copy-on-write method. For large files it has the advantage of being
much faster and saving disk space (since identical extents are not
duplicated). This feature is stable and for example coreutils' `cp'
does use it automatically (see --reflink).
This commit adds support for this feature into our copy-file procedure.
Same as `cp', it defaults to 'auto, meaning the copy-on-write is
attempted, and in case of failure the regular copy is performed.
No tests are provided, because the behavior depends on the system,
underlying file-system and its configuration. That makes it challenging
to write a test for it. Manual testing was performed instead:
$ btrfs filesystem du /tmp/cow*
Total Exclusive Set shared Filename
36.00KiB 36.00KiB 0.00B /tmp/cow
$ cat cow-test.scm
(copy-file "/tmp/cow" "/tmp/cow-unspecified")
(copy-file "/tmp/cow" "/tmp/cow-always" #:copy-on-write 'always)
(copy-file "/tmp/cow" "/tmp/cow-auto" #:copy-on-write 'auto)
(copy-file "/tmp/cow" "/tmp/cow-never" #:copy-on-write 'never)
(copy-file "/tmp/cow" "/dev/shm/cow-unspecified")
(copy-file "/tmp/cow" "/dev/shm/cow-auto" #:copy-on-write 'auto)
(copy-file "/tmp/cow" "/dev/shm/cow-never" #:copy-on-write 'never)
$ ./meta/guile -s cow-test.scm
$ btrfs filesystem du /tmp/cow*
Total Exclusive Set shared Filename
36.00KiB 0.00B 36.00KiB /tmp/cow
36.00KiB 0.00B 36.00KiB /tmp/cow-always
36.00KiB 0.00B 36.00KiB /tmp/cow-auto
36.00KiB 36.00KiB 0.00B /tmp/cow-never
36.00KiB 0.00B 36.00KiB /tmp/cow-unspecified
$ sha1sum /tmp/cow* /dev/shm/cow*
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /tmp/cow
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /tmp/cow-always
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /tmp/cow-auto
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /tmp/cow-never
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /tmp/cow-unspecified
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /dev/shm/cow-auto
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /dev/shm/cow-never
4c665f87b5dc2e7d26279c4b48968d085e1ace32 /dev/shm/cow-unspecified
This commit also adds to new failure modes for (copy-file).
Failure to copy-on-write when 'always was passed in:
scheme@(guile-user)> (copy-file "/tmp/cow" "/dev/shm/cow" #:copy-on-write 'always)
ice-9/boot-9.scm:1676:22: In procedure raise-exception:
In procedure copy-file: copy-on-write failed: Invalid cross-device link
Passing in invalid value for the #:copy-on-write keyword argument:
scheme@(guile-user)> (copy-file "/tmp/cow" "/dev/shm/cow" #:copy-on-write 'nevr)
ice-9/boot-9.scm:1676:22: In procedure raise-exception:
In procedure copy-file: invalid value for #:copy-on-write: nevr
* NEWS: Add note for copy-file supporting copy-on-write.
* configure.ac: Check for linux/fs.h.
* doc/ref/posix.texi (File System)[copy-file]: Document the new
signature.
* libguile/filesys.c (clone_file): New function cloning a file using
FICLONE, if supported.
(k_copy_on_write): New keyword.
(sym_always, sym_auto, sym_never): New symbols.
(scm_copy_file2): Renamed from scm_copy_file. New #:copy-on-write
keyword argument. Attempt copy-on-write copy by default.
(scm_copy_file): Call scm_copy_file2.
* libguile/filesys.h: Add scm_copy_file2 as SCM_INTERNAL.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
While the `.' might be correct from a grammatical point of view (I do
not know), it turns the example into invalid scheme code, which is not
ideal. New users (like me) might try to copy the whole line and wonder
why it does not work (like I did). So delete it.
* doc/ref/srfi-modules.texi (SRFI-171 General Discussion): Delete the
trailing . from the example.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Fixes <https://bugs.gnu.org/63366>.
Suggested by Sebastian Carlos <sebaaa1754@gmail.com>.
* doc/ref/intro.texi (Introduction): Remove reference to Python and
Perl, which no longer have “benevolent dictators”.
Recognize `raise-exception` in the same way we recognize `throw`, though
it is a bit less optimized and the boot story is not as complicated.
* doc/ref/vm.texi (Non-Local Control Flow Instructions):
* libguile/jit.c (compile_unreachable):
(compile_unreachable_slow):
* libguile/vm-engine.c (VM_NAME):
* module/language/cps/compile-bytecode.scm (compile-function):
* module/system/vm/assembler.scm (emit-unreachable): Add new
"unreachable" instruction, inserted after a call to non-continuable
`raise-exception`.
* module/language/tree-il/compile-cps.scm (raise-exception):
* module/language/tree-il/primitives.scm
(*interesting-primitive-names*): Recognize raise-exception, and if it is
called with just one argument, prune that branch of the control-flow
graph.
* doc/ref/api-macros.texi (Syntax Rules): Use archived URL from
Internet Archive for syntax-rules primer.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Custom ports are a kind of port that exposes the C port type interface
directly to Scheme. In this way the full capability of C is available
to Scheme, and also the read and write functions can be tail-called from
Scheme (via port-read / port-write).
* libguile/custom-ports.c:
* libguile/custom-ports.h:
* module/ice-9/custom-ports.scm: New files.
* libguile/init.c:
* libguile/Makefile.am:
* am/bootstrap.am: Add to the build.
* doc/ref/api-io.texi: Update the manual.
* doc/ref/api-binding.texi (Local Bindings): Document multiple-value
returns for let.
* doc/ref/api-control.texi (begin): Document multiple-value returns for
begin.
(Conditionals): Document multiple-value returns and use 'body' in the
syntax description of when, unless, cond, case.
(Multiple values): Document multiple-value returns and use 'body' in
the syntax description of SRFI-8 receive.
(Fluids and Dynamic States): Use 'body' in the syntax description of
'with-fluids'.
This commit adds internal definitions to the following derived
forms: when, unless, cond, case, with-fluids, and and-let*.
* doc/ref/api-control.texi (Conditionals): Update the syntax and docs
of when, unless, cond, and case.
* module/ice-9/and-let-star.scm (and-let*): Changed begins to let.
* module/ice-9/boot-9.scm (cond, case, when, unless, with-fluids):
Changed begins to let.
* doc/ref/api-macros.texi: make the macro expand to the literal
date, not to a call to the date function. The example previously
did not actually need eval-when and did not show the intended
effect.
* module/rnrs/bytevectors/gnu.scm: New file.
* am/bootstrap.am (SOURCES): Add it.
* libguile/bytevectors.c (scm_bytevector_slice): New function.
* libguile/bytevectors.h (scm_bytevector_slice): New declaration.
* test-suite/tests/bytevectors.test ("bytevector-slice"): New tests.
* doc/ref/api-data.texi (Bytevector Slices): New node.
See (1994-11-04) https://groups.google.com/g/gnu.misc.discuss/c/0VtEf1fgEJk/m/IMBs2o-ftrgJ
> If GEL and GUL and GLUE don't work for the name of the scripting
> language, how about:
>
> GUILE - GNU's Universal Interpreted Language Extension
>
> (This also implies Scheme-ing, and means that the GNU's Universal
> Interpreted Language Developers would be part of a ...)
> --
> Lee Thomas
and (1994-11-22) https://groups.google.com/g/gnu.misc.discuss/c/9pD9yVoRYFw/m/0z7SLYbx8loJ
> Why "GUILE"? (GNU's Universal Interpreted Language Extension)
> Two additional reasons:
>
> 1. It does not give deliberate offense to Dr. Ousterhout or his
> supporters, thereby allowing the warring factions to eventually
> make peace (along with some others, perhaps - Gloria's 'Usband Is
> Linguistically Educated) and get back to work.
> 2. By pronunciation it offers appreciation to one of the co-inventors
> of Scheme. (Maybe a library package could be named "Scheme User
> Supported System Macros And Native-code"? OK, that's a stretch ...)
> --
> Lee Thomas,
and https://groups.google.com/g/comp.lang.scheme/c/X5GrLVAvGLU/m/Xk11xCrbzCcJ
> A while back, I started calling the language being built by the GNU Project
> GEL. It turns out that GEL is a trademark of Sybase Inc. Therefore,
> we must choose a new name. Please do not refer to the GNU language
> as GEL.
>
> My favorite proposed name, posted recently to comp.lang.scheme, is GUILE.
> I like the name, because i think programmers should be encouraged to use
> GUILE when writing programs. The name may change yet again; but for now,
> please refer to the GNU language as GUILE.
>
> -t
The spelling mistake is a clear fix, but the Arrays fix might not be as
obvious. Previously, with the "arrays" alias, the @ref macro would
render a superfluous period after the word "arrays", rendering (at least
within Emacs) as:
you may wish to use see arrays. instead.
Signed-off-by: Mikael Djurfeldt <mikael@djurfeldt.com>
* configure.ac: Detect if ‘openat’ is defined.
* libguile/filesys.c
(flags_to_mode): Extract from ...
(scm_mode): ... here.
(scm_open_fdes_at, scm_openat): Define the Scheme bindings.
* libguile/filesys.h (scm_open_fdes_at, scm_openat): Make them part
of the API.
* doc/ref/posix.texi (File System): Document them.
* test-suite/tests/filesys.test ("openat"): Test ‘openat’.
* libguile/syscalls.h (openat_or_openat64): Decide between ‘openat’
and ‘openat64’.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect if ‘fstatat’ is defined.
* libguile/filesys.c (scm_statat): Define a Scheme binding to ‘fstatat’.
* libguile/filesys.h (scm_statat): Make it part of the C API.
* doc/ref/posix.texi (File System): Document it.
* libguile/syscalls.h (fstatat_or_fstatat64): Choose between ‘fstatat’
and ‘fstatat64’.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect whether ‘fchownat’ is available.
* libguile/filesys.c (scm_chownat): Define a Scheme binding to
‘fchownat’ when available.
* libguile/filesys.h (scm_chownat): Make it part of the API.
* doc/ref/posix.texi (File System): Document it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
‘unlinkat’ is used for both unlinking regular files
and removing empty directories.
* configure.ac: Detect if ‘unlinkat’ exists.
* doc/ref/posix.texi (File System): Document why there is no
‘rmdirat’ procedure, and document the ‘delete-file-at’ procedure.
* libguile/filesys.c
(scm_rmdir): Adjust the docstring here as well.
(scm_delete_file_at): Define a Scheme binding to ‘unlinkat’.
* libguile/filesys.h (scm_delete_file_at): Make ‘scm_delete_file_at’
part of the C API.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect if ‘renameat’ is defined.
* libguile/filesys.c (scm_renameat): Define a Scheme binding
to the ‘renameat’ system call.
* doc/ref/posix.texi (File System): Document it.
* libguile/filesys.h (scm_renameat): Make it part of the C API.
* test-suite/tests/filesys.test ("rename-file-at"): New tests.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect whether ‘symlinkat’ exists.
* libguile/filesys.c (scm_symlinkat): Define a Scheme binding
when it exists.
* libguile/filesys.h: Make the binding part of the public C API.
* doc/ref/posix.texi (File System): Document the binding.
* test-suite/tests/filesys.test ("symlinkat"): Test it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Detect whether ‘readlinkat’ is defined.
* libguile/filesys.c (scm_readlink): Support file ports
when ‘readlinkat’ exists.
(scm_init_filesys): Provide ‘chdir-ports’ when it exists.
* doc/ref/posix.texi (File System): Document it.
* test-suite/tests/filesys.test ("readlink"): Test it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
* configure.ac: Check for ‘fchdir’.
* libguile/filesys.c
(scm_chdir): Support file ports.
(scm_init_filesys): Report support of file ports.
* doc/ref/posix.texi (Processes): Update accordingly.
* doc/ref/guile.texi: Add copyright line for new documentation in this
patch and later patches.
* test-suite/tests/filesys.test ("chdir"): Test it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>