1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

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.
This commit is contained in:
Andy Wingo 2016-06-08 07:42:29 +02:00
parent d7f39a36b1
commit 4bceba876b
3 changed files with 28 additions and 3 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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))