From 64f037d91e0c9296dcaef9a0ff3eb33b19a2ed34 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 Feb 2017 00:05:38 -0800 Subject: Import Upstream version 3a5 --- gambit.init | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'gambit.init') 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 . ) +(define (file-position port . k) + (apply (if (output-port? port) + output-port-byte-position + input-port-byte-position) + port + k)) + ;;; (OUTPUT-PORT-WIDTH ) ;; (define (output-port-width . arg) 79) -- cgit v1.2.3