[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 02/10: put-char, put-string in (ice-9 ports internals)
From: |
Andy Wingo |
Subject: |
[Guile-commits] 02/10: put-char, put-string in (ice-9 ports internals) |
Date: |
Thu, 9 Jun 2016 09:01:12 +0000 (UTC) |
wingo pushed a commit to branch master
in repository guile.
commit 4bceba876ba10029cff0c6903418b1bdcc9067c0
Author: Andy Wingo <address@hidden>
Date: Wed Jun 8 07:42:29 2016 +0200
put-char, put-string in (ice-9 ports internals)
* libguile/ports.h (scm_put_char):
* libguile/ports.c (scm_put_char): New function.
(scm_put_string): Add docstrings, and expose to the internal ports
module.
* module/ice-9/ports.scm (put-char, put-string): Expose these bindings
only through the internals module.
---
libguile/ports.c | 22 +++++++++++++++++++++-
libguile/ports.h | 1 +
module/ice-9/ports.scm | 8 ++++++--
3 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/libguile/ports.c b/libguile/ports.c
index 0020bf6..a464aaf 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -3361,9 +3361,29 @@ scm_c_put_string (SCM port, SCM string, size_t start,
size_t count)
}
}
+SCM_DEFINE (scm_put_char, "put-char", 2, 0, 0, (SCM port, SCM ch),
+ "Encode @var{ch} to bytes, and send those bytes to @var{port}.")
+#define FUNC_NAME s_scm_put_char
+{
+ SCM_VALIDATE_OPOUTPORT (1, port);
+ SCM_VALIDATE_CHAR (2, ch);
+
+ scm_c_put_char (port, SCM_CHAR (ch));
+
+ return SCM_UNSPECIFIED;
+}
+#undef FUNC_NAME
+
SCM_DEFINE (scm_put_string, "put-string", 2, 2, 0,
(SCM port, SCM string, SCM start, SCM count),
- "")
+ "Display the @var{count} characters from @var{string} to\n"
+ "@var{port}, starting with the character at index @var{start}.\n"
+ "@var{start} defaults to 0, and @var{count} defaults to\n"
+ "displaying all characters until the end of the string.\n\n"
+ "Calling @code{put-string} is equivalent in all respects to\n"
+ "calling @code{put-char} on the relevant sequence of characters,\n"
+ "except that it will attempt to write multiple characters to\n"
+ "the port at a time, even if the port is unbuffered.")
#define FUNC_NAME s_scm_put_string
{
size_t c_start, c_count, c_len;
diff --git a/libguile/ports.h b/libguile/ports.h
index f8d62c1..66b2471 100644
--- a/libguile/ports.h
+++ b/libguile/ports.h
@@ -220,6 +220,7 @@ SCM_API void scm_c_put_utf32_chars (SCM port, const
scm_t_uint32 *buf,
SCM_API void scm_c_put_string (SCM port, SCM str, size_t start, size_t count);
SCM_API SCM scm_put_string (SCM port, SCM str, SCM start, SCM count);
SCM_API void scm_c_put_char (SCM port, scm_t_wchar ch);
+SCM_API SCM scm_put_char (SCM port, SCM ch);
SCM_INTERNAL void scm_c_put_escaped_char (SCM port, scm_t_wchar ch);
SCM_INTERNAL int scm_c_can_put_char (SCM port, scm_t_wchar ch);
SCM_API void scm_putc (char c, SCM port);
diff --git a/module/ice-9/ports.scm b/module/ice-9/ports.scm
index 68afed1..43a029b 100644
--- a/module/ice-9/ports.scm
+++ b/module/ice-9/ports.scm
@@ -191,7 +191,9 @@ interpret its input and output."
port-read-buffering
port-poll
port-read-wait-fd
- port-write-wait-fd))
+ port-write-wait-fd
+ put-char
+ put-string))
(define-syntax-rule (port-buffer-bytevector buf) (vector-ref buf 0))
(define-syntax-rule (port-buffer-cur buf) (vector-ref buf 1))
@@ -238,7 +240,9 @@ interpret its input and output."
port-read-buffering
port-poll
port-read-wait-fd
- port-write-wait-fd)
+ port-write-wait-fd
+ put-char
+ put-string)
;; And we're back.
(define-module (ice-9 ports))
- [Guile-commits] branch master updated (9454068 -> 6788fab), Andy Wingo, 2016/06/09
- [Guile-commits] 01/10: socket: TCP_CORK, TCP_NODELAY, Andy Wingo, 2016/06/09
- [Guile-commits] 07/10: put-char in Scheme, Andy Wingo, 2016/06/09
- [Guile-commits] 04/10: Undocument (ice-9 rw), Andy Wingo, 2016/06/09
- [Guile-commits] 09/10: Support `connect' on nonblocking sockets, Andy Wingo, 2016/06/09
- [Guile-commits] 10/10: Non-blocking accept/connect Scheme support, Andy Wingo, 2016/06/09
- [Guile-commits] 08/10: `accept' on nonblocking socket can return #f, Andy Wingo, 2016/06/09
- [Guile-commits] 02/10: put-char, put-string in (ice-9 ports internals),
Andy Wingo <=
- [Guile-commits] 03/10: Add (ice-9 textual-ports), Andy Wingo, 2016/06/09
- [Guile-commits] 06/10: Update port documentation, rename sports to suspendable ports, Andy Wingo, 2016/06/09
- [Guile-commits] 05/10: Big ports documentation update, Andy Wingo, 2016/06/09