summaryrefslogtreecommitdiffstats
path: root/txr.1
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2013-11-26 22:45:42 -0800
committerKaz Kylheku <kaz@kylheku.com>2013-11-26 22:45:42 -0800
commit6fedaccfe790e33bb7a71d8a5f776e4cfa7e6c62 (patch)
treeb74c6fde22e41c0b15e0b51060bc979a19efc97c /txr.1
parenta56501891dcf01d4f68ab560eb24fa3406afe0e1 (diff)
downloadtxr-6fedaccfe790e33bb7a71d8a5f776e4cfa7e6c62.tar.gz
txr-6fedaccfe790e33bb7a71d8a5f776e4cfa7e6c62.tar.bz2
txr-6fedaccfe790e33bb7a71d8a5f776e4cfa7e6c62.zip
Stream-seeking functionality.
Bugfix in stdio_flush: check FILE * handle for null. Minor cleanups. * eval.c (eval_init): Register seek_stream as intrinsic. * stream.c (from_start_k, from_current_k, from_end_k): New symbol variables. (strm_whence): New enum. (strm_ops): New member, seek. (stdio_maybe_write_error): Renamed to stdio_maybe_error; takes new string argument to describe action. (stdio_put_string, stdio_put_char, stdio_put_byte): Updated call to stdio_maybe_error. (stdio_flush): Updated call to stdio_maybe_error. Check handle for null. (stdio_seek): New static function. (stdio_ops): Added stdio_seek. (pipe_ops, string_in_ops, byte_in_ops, string_out_ops, strlist_out_ops, dir_ops): Added explicit zero entries and comments for unimplemented functions. (seek_stream): New function. (stream_init): New keyword symbols interned. * stream.h (from_start_k, from_current_k, from_end_k): New variables declared. (dev_k, ino_k, mode_k, nlink_k, uid_k, gid_k, rdev_k, size_k, blksize_k, blocks_k, atime_k, mtime_k, ctime_k, s_ifmt, s_iflnk, s_ifreg, s_ifblk, s_ifdir, s_ifchr, s_ififo, s_isuid, s_isgid, s_isvtx, s_irwxu, s_irusr, s_iwusr, s_ixusr, s_irwxg, s_irgrp, s_iwgrp): Existing extern variables declared. (seek_stream): New function declared. * txr.1: Documented seek-stream.
Diffstat (limited to 'txr.1')
-rw-r--r--txr.134
1 files changed, 34 insertions, 0 deletions
diff --git a/txr.1 b/txr.1
index 571e2271..6d98aab7 100644
--- a/txr.1
+++ b/txr.1
@@ -10241,6 +10241,40 @@ Calling this function causes all accumulated data inside <stream> to be passed
to the operating system. If called on streams for which this function is not
meaningful, it does nothing.
+.SS Function seek-stream
+
+.TP
+Syntax:
+
+ (seek-stream <stream> <offset> <whence>)
+
+.TP
+Description:
+
+The seek-stream function is meaningful for file streams. It changes the
+current read/write position within <stream>. It can also be used
+to determine the current position: see the notes about the
+return value below.
+
+The <offset> argument is a positive or negative integer which gives a
+displacement that is measured from the point identified by the <whence>
+argument.
+
+Note that for text files, there isn't necessarily a 1:1 correspondence between
+characters and positions due to line-ending conversions and conversions
+to and from UTF-8.
+
+The <whence> argument is one of three keywords: :from-start, :from-current
+and :from-end. These denote the start of the file, the current position
+and the end of the file.
+
+If <offset> is zero, and <whence> is :from-current, then
+seek-stream returns the current absolute position within the
+stream, if it can successfully obtain it. Otherwise, it
+returns t if it is successful.
+
+On failure, it throws an exception of type stream-error.
+
.SH FILESYSTEM ACCESS
.SS Function stat