unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Juliana Sims <juli@incana.org>
To: 67064@debbugs.gnu.org
Cc: 67063@debbugs.gnu.org, Juliana Sims <juli@incana.org>
Subject: bug#67064: [PATCH] Fix unread-string
Date: Fri, 10 Nov 2023 23:25:56 -0500	[thread overview]
Message-ID: <20231111042639.11663-1-juli@incana.org> (raw)
In-Reply-To: <handler.67063.B.169967654110222.ack@debbugs.gnu.org>

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	other threads:[~2023-11-11  4:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <handler.67063.B.169967654110222.ack@debbugs.gnu.org>
2023-11-11  4:25 ` Juliana Sims [this message]
2024-05-06  9:49   ` bug#67063: unread-string does not match documented functionality Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231111042639.11663-1-juli@incana.org \
    --to=juli@incana.org \
    --cc=67063@debbugs.gnu.org \
    --cc=67064@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).