GNU bug report logs - #67063
unread-string does not match documented functionality

Previous Next

Package: guile;

Reported by: Juliana Sims <juli <at> incana.org>

Date: Sat, 11 Nov 2023 04:23:01 UTC

Severity: normal

Done: Ludovic Courtès <ludo <at> gnu.org>

To reply to this bug, email your comments to 67063 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#67063; Package guile. (Sat, 11 Nov 2023 04:23:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Juliana Sims <juli <at> incana.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Sat, 11 Nov 2023 04:23:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Juliana Sims <juli <at> incana.org>
To: bug-guile <at> gnu.org
Subject: unread-string does not match documented functionality
Date: Fri, 10 Nov 2023 23:21:09 -0500
Hello,

The procedure unread-string is documented to only optionally accept a 
port argument, but the implementation in fact requries it.

I've written a patch to resolve this and will be sending it along 
shortly.

Thanks,
Juli






Information forwarded to bug-guile <at> gnu.org:
bug#67063; Package guile. (Sat, 11 Nov 2023 04:29:02 GMT) Full text and rfc822 format available.

Message #8 received at 67063 <at> debbugs.gnu.org (full text, mbox):

From: Juliana Sims <juli <at> incana.org>
To: bug-guile <at> gnu.org
Cc: 67063 <at> debbugs.gnu.org, Juliana Sims <juli <at> incana.org>
Subject: [PATCH] Fix unread-string
Date: Fri, 10 Nov 2023 23:25:56 -0500
Hello,

This patch simply fixes bug 67063.

Thanks,
Juli

* 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.
---
 doc/ref/api-io.texi         | 3 +--
 libguile/ports.c            | 2 +-
 test-suite/tests/ports.test | 6 +++---
 3 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi
index e263e2985..90411fbdf 100644
--- a/doc/ref/api-io.texi
+++ b/doc/ref/api-io.texi
@@ -1981,8 +1981,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}.
 @end deffn
 
-@deffn {Scheme Procedure} unread-string str port
-@deffnx {C Function} scm_unread_string (str, port)
+@deffn {Scheme Procedure} unread-string str [port]
 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}.
 @end deffn
diff --git a/libguile/ports.c b/libguile/ports.c
index c25c20709..eb4a59bd5 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -2228,7 +2228,7 @@ SCM_DEFINE (scm_unread_char, "unread-char", 1, 1, 0,
 }
 #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),
 	    "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"
diff --git a/test-suite/tests/ports.test b/test-suite/tests/ports.test
index 1b30e1a68..040bb02f0 100644
--- a/test-suite/tests/ports.test
+++ b/test-suite/tests/ports.test
@@ -590,13 +590,13 @@
 (with-input-from-string "walk on the moon\nmoon"
                         (lambda ()
                           (read-char)
-                          (unread-char #\a (current-input-port))
+                          (unread-char #\a)
                           (pass-if "unread-char"
                                    (char=? (read-char) #\a))
                           (read-line)
                           (let ((replacenoid "chicken enchilada"))
-                            (unread-char #\newline (current-input-port))
-                            (unread-string replacenoid (current-input-port))
+                            (unread-char #\newline)
+                            (unread-string replacenoid)
                             (pass-if "unread-string"
                                      (string=? (read-line) replacenoid)))
                           (pass-if "unread residue"
-- 
2.41.0





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Mon, 06 May 2024 09:51:02 GMT) Full text and rfc822 format available.

Notification sent to Juliana Sims <juli <at> incana.org>:
bug acknowledged by developer. (Mon, 06 May 2024 09:51:02 GMT) Full text and rfc822 format available.

Message #13 received at 67063-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Juliana Sims <juli <at> incana.org>
Cc: 67063-done <at> debbugs.gnu.org
Subject: Re: bug#67063: unread-string does not match documented functionality
Date: Mon, 06 May 2024 11:49:34 +0200
[Message part 1 (text/plain, inline)]
Hi Juliana,

Juliana Sims <juli <at> incana.org> skribis:

> This patch simply fixes bug 67063.
>
> Thanks,
> Juli
>
> * 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.

Finally applied with these changes:

[Message part 2 (text/x-patch, inline)]
diff --git a/NEWS b/NEWS
index 8a61bf65d..3c4854ca9 100644
--- a/NEWS
+++ b/NEWS
@@ -59,6 +59,8 @@ files.  See "Random Access" in the manual for details.
    (<https://bugs.gnu.org/55356>)
 ** 'read-u8' in (scheme base) now defaults to (current-input-port)
    (<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
    (<https://bugs.gnu.org/55344>)
 ** 'make-custom-port' now honors its #:conversion-strategy argument
diff --git a/doc/ref/api-io.texi b/doc/ref/api-io.texi
index 3a0f7a9a1..79bc9e9d6 100644
--- a/doc/ref/api-io.texi
+++ b/doc/ref/api-io.texi
@@ -2001,6 +2001,7 @@ current input port, and the arguments are swapped.  @xref{Textual I/O}.
 @end deffn
 
 @deffn {Scheme Procedure} 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
 current input port, and the arguments are swapped.  @xref{Textual I/O}.
 @end deffn
[Message part 3 (text/plain, inline)]
Not sure why the C functions aren’t documented for the other ones.

Thanks,
Ludo’.

This bug report was last modified today.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.