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

Second argument of ‘unread-string’ is optional.

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>
This commit is contained in:
Juliana Sims 2023-11-10 23:25:56 -05:00 committed by Ludovic Courtès
parent 80d4055e42
commit a222503a89
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
4 changed files with 7 additions and 5 deletions

2
NEWS
View file

@ -59,6 +59,8 @@ files. See "Random Access" in the manual for details.
(<https://bugs.gnu.org/55356>) (<https://bugs.gnu.org/55356>)
** 'read-u8' in (scheme base) now defaults to (current-input-port) ** 'read-u8' in (scheme base) now defaults to (current-input-port)
(<https://bugs.gnu.org/62690>) (<https://bugs.gnu.org/62690>)
** Second argument of 'unread-string' is now optional, as previously documented
(<https://bugs.gnu.org/67063>)
** 'ftw' now correctly deals with directory permissions ** 'ftw' now correctly deals with directory permissions
(<https://bugs.gnu.org/55344>) (<https://bugs.gnu.org/55344>)
** 'make-custom-port' now honors its #:conversion-strategy argument ** 'make-custom-port' now honors its #:conversion-strategy argument

View file

@ -2000,7 +2000,7 @@ The same as @code{unget-char}, except that @var{port} defaults to the
current input port, and the arguments are swapped. @xref{Textual I/O}. current input port, and the arguments are swapped. @xref{Textual I/O}.
@end deffn @end deffn
@deffn {Scheme Procedure} unread-string str port @deffn {Scheme Procedure} unread-string str [port]
@deffnx {C Function} scm_unread_string (str, port) @deffnx {C Function} scm_unread_string (str, port)
The same as @code{unget-string}, except that @var{port} defaults to the The same as @code{unget-string}, except that @var{port} defaults to the
current input port, and the arguments are swapped. @xref{Textual I/O}. current input port, and the arguments are swapped. @xref{Textual I/O}.

View file

@ -2228,7 +2228,7 @@ SCM_DEFINE (scm_unread_char, "unread-char", 1, 1, 0,
} }
#undef FUNC_NAME #undef FUNC_NAME
SCM_DEFINE (scm_unread_string, "unread-string", 2, 0, 0, SCM_DEFINE (scm_unread_string, "unread-string", 1, 1, 0,
(SCM str, SCM port), (SCM str, SCM port),
"Place the string @var{str} in @var{port} so that its characters will be\n" "Place the string @var{str} in @var{port} so that its characters will be\n"
"read in subsequent read operations. If called multiple times, the\n" "read in subsequent read operations. If called multiple times, the\n"

View file

@ -636,13 +636,13 @@
(with-input-from-string "walk on the moon\nmoon" (with-input-from-string "walk on the moon\nmoon"
(lambda () (lambda ()
(read-char) (read-char)
(unread-char #\a (current-input-port)) (unread-char #\a)
(pass-if "unread-char" (pass-if "unread-char"
(char=? (read-char) #\a)) (char=? (read-char) #\a))
(read-line) (read-line)
(let ((replacenoid "chicken enchilada")) (let ((replacenoid "chicken enchilada"))
(unread-char #\newline (current-input-port)) (unread-char #\newline)
(unread-string replacenoid (current-input-port)) (unread-string replacenoid)
(pass-if "unread-string" (pass-if "unread-string"
(string=? (read-line) replacenoid))) (string=? (read-line) replacenoid)))
(pass-if "unread residue" (pass-if "unread residue"