From 755f703dcb3110e1920e42078edc6d9c88cc8b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 18 Jun 2025 11:29:22 +0200 Subject: [PATCH] =?UTF-8?q?Document=20=E2=80=98in-vicinity=E2=80=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * module/ice-9/boot-9.scm (in-vicinity): Rename ‘vicinity’ to ‘directory’. Add docstring. * doc/ref/posix.texi (File System): Document it. Suggested-by: Maxim Cournoyer --- doc/ref/posix.texi | 5 +++++ module/ice-9/boot-9.scm | 13 ++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/doc/ref/posix.texi b/doc/ref/posix.texi index 08d939b9f..5990322a4 100644 --- a/doc/ref/posix.texi +++ b/doc/ref/posix.texi @@ -1223,6 +1223,11 @@ valid separators. Thus, programs should not assume that separator---e.g., when extracting the components of a file name. @end defvr +@deffn {Scheme Procedure} in-vicinity @var{directory} @var{file} +Concatenate @var{directory} and @var{file}, adding +@code{file-name-separator-string} (by default slash) in between if it is +not already present. This helps create file names. +@end deffn @node User Information @subsection User Information diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm index 04f84215c..aaa998702 100644 --- a/module/ice-9/boot-9.scm +++ b/module/ice-9/boot-9.scm @@ -1,6 +1,6 @@ ;;; -*- mode: scheme; coding: utf-8; -*- -;;;; Copyright (C) 1995-2014, 2016-2024 Free Software Foundation, Inc. +;;;; Copyright (C) 1995-2014, 2016-2025 Free Software Foundation, Inc. ;;;; ;;;; This library is free software; you can redistribute it and/or ;;;; modify it under the terms of the GNU Lesser General Public @@ -2144,12 +2144,15 @@ non-locally, that exit determines the continuation." (file-name-separator-at-index? 2) (file-name-separator-at-index? 0))))))) -(define (in-vicinity vicinity file) - (let ((tail (let ((len (string-length vicinity))) +(define (in-vicinity directory file) + "Concatenate @var{directory} and @var{file}, adding +@code{file-name-separator-string} (by default slash) in between if it is +not already present. This helps create file names." + (let ((tail (let ((len (string-length directory))) (if (zero? len) #f - (string-ref vicinity (- len 1)))))) - (string-append vicinity + (string-ref directory (- len 1)))))) + (string-append directory (if (or (not tail) (file-name-separator? tail)) "" file-name-separator-string)