summaryrefslogtreecommitdiffstats
path: root/gambit.init
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:38 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:38 -0800
commit64f037d91e0c9296dcaef9a0ff3eb33b19a2ed34 (patch)
tree1b23b8e8005328194e2fb4bf653806c85050933f /gambit.init
parent5bea21e81ed516440e34e480f2c33ca41aa8c597 (diff)
downloadslib-d1b3fa5f6a18ff42030126a53a10fb90d876dc1d.tar.gz
slib-d1b3fa5f6a18ff42030126a53a10fb90d876dc1d.zip
Import Upstream version 3a5upstream/3a5
Diffstat (limited to 'gambit.init')
-rw-r--r--gambit.init32
1 files changed, 32 insertions, 0 deletions
diff --git a/gambit.init b/gambit.init
index 07841e6..e431160 100644
--- a/gambit.init
+++ b/gambit.init
@@ -243,6 +243,38 @@
(define (offset-time caltime offset)
(seconds->time (+ (time->seconds caltime) offset)))
+;; procedure: input-port-byte-position port [position [whence]]
+;; procedure: output-port-byte-position port [position [whence]]
+;;
+;; When called with a single argument these procedures return the
+;; byte position where the next I/O operation would take place in the
+;; file attached to the given port (relative to the beginning of the
+;; file). When called with two or three arguments, the byte position
+;; for subsequent I/O operations on the given port is changed to
+;; position, which must be an exact integer. When whence is omitted
+;; or is 0, the position is relative to the beginning of the file.
+;; When whence is 1, the position is relative to the current byte
+;; position of the file. When whence is 2, the position is relative
+;; to the end of the file. The return value is the new byte position.
+;; On most operating systems the byte position for reading and writing
+;; of a given bidirectional port are the same.
+;;
+;; When input-port-byte-position is called to change the byte
+;; position of an input-port, all input buffers will be flushed so
+;; that the next byte read will be the one at the given position.
+;;
+;; When output-port-byte-position is called to change the byte
+;; position of an output-port, there is an implicit call to
+;; force-output before the position is changed.
+
+;;@ (FILE-POSITION <port> . <k>)
+(define (file-position port . k)
+ (apply (if (output-port? port)
+ output-port-byte-position
+ input-port-byte-position)
+ port
+ k))
+
;;; (OUTPUT-PORT-WIDTH <port>)
;; (define (output-port-width . arg) 79)