diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-01-13 22:19:03 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-01-13 22:19:03 -0800 |
commit | 48c8cec1c83d70e23dc1359b85cfd9e36fdaa60f (patch) | |
tree | 99586c035526f35154fa916e018c7dcffb80f4c5 /stream.h | |
parent | e7dd81f7280612a65b7a466e6d870b808272b34f (diff) | |
download | txr-48c8cec1c83d70e23dc1359b85cfd9e36fdaa60f.tar.gz txr-48c8cec1c83d70e23dc1359b85cfd9e36fdaa60f.tar.bz2 txr-48c8cec1c83d70e23dc1359b85cfd9e36fdaa60f.zip |
Support for pushing back bytes and characters into streams.
* stream.c (null_ops, stdio_ops, tail_ops, pipe_ops,
string_in_ops, byte_in_ops, string_out_ops, strlist_out_ops,
dir_ops, cat_stream_ops): Structure definition updated
with new initializers for two new virtuals.
(stdio_handle): New member, unget_c.
(snarf_line, stdio_get_char): Handle pushed-back character in
h->unget_c.
(stdio_unget_char, stdio_unget_byte, string_in_unget_char,
byte_in_unget_byte): New static functions.
(make_stdio_stream_common): Initialize unget_c member.
(unget_char, unget_byte): New functions.
* stream.h (struct strm_ops): New virtuals: unget_char and unget_byte.
(unget_char, unget_byte): New functions declared.
* syslog.c (syslog_strm_ops): Two new initializers.
* eval.c (eval_init): Registered unget_char and unget_byte as
intrinsics.
* txr.1: Documented.
Diffstat (limited to 'stream.h')
-rw-r--r-- | stream.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -38,6 +38,8 @@ struct strm_ops { val (*get_line)(val); val (*get_char)(val); val (*get_byte)(val); + val (*unget_char)(val, val); + val (*unget_byte)(val, int); val (*close)(val, val); val (*flush)(val); val (*seek)(val, cnum, enum strm_whence); @@ -78,6 +80,8 @@ val close_stream(val stream, val throw_on_error); val get_line(val); val get_char(val); val get_byte(val); +val unget_char(val ch, val stream); +val unget_byte(val byte, val stream); val vformat(val stream, val string, va_list); val vformat_to_string(val string, va_list); val format(val stream, val string, ...); |