New operations on input-buffer for saving and restoring the contents
authorChris Hanson <org/chris-hanson/cph>
Wed, 14 Nov 1990 13:26:46 +0000 (13:26 +0000)
committerChris Hanson <org/chris-hanson/cph>
Wed, 14 Nov 1990 13:26:46 +0000 (13:26 +0000)
of the buffer.  These are used by the console input port to preserve
the buffer's contents through a disk-restore.

v7/src/runtime/io.scm
v7/src/runtime/runtime.pkg
v8/src/runtime/runtime.pkg

index 1ff9c81548121a0cb62862ae99cae8eba75d2cb8..e2a21f1871f0d980dd6f3e4aef05b01c651bb89a 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/io.scm,v 14.15 1990/11/12 04:00:05 cph Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/io.scm,v 14.16 1990/11/14 13:25:29 cph Rel $
 
 Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -692,4 +692,21 @@ MIT in each case. |#
                      (begin
                        (set-input-buffer/start-index! buffer end-index)
                        (if (input-buffer/fill* buffer)
-                           (loop))))))))))))
\ No newline at end of file
+                           (loop))))))))))))
+
+(define (input-buffer/buffer-contents buffer)
+  (and (fix:< (input-buffer/start-index buffer)
+             (input-buffer/end-index buffer))
+       (substring (input-buffer/string buffer)
+                 (input-buffer/start-index buffer)
+                 (input-buffer/end-index buffer))))
+
+(define (input-buffer/set-buffer-contents buffer contents)
+  (let ((string (input-buffer/string buffer)))
+    (let ((current-size (string-length string))
+         (contents-size (string-length contents)))
+      (if (fix:> contents-size current-size)
+         (input-buffer/set-size buffer contents-size))
+      (substring-move-left! contents 0 contents-size string 0)
+      (set-input-buffer/start-index! buffer 0)
+      (set-input-buffer/end-index! buffer contents-size))))
\ No newline at end of file
index 46c03dc557ea772eaa7fa3575fa905bc04f1f5a8..8d845f72b575aadb2a112598ef88537ccf7afbe9 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/runtime.pkg,v 14.84 1990/11/13 19:21:46 arthur Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/runtime.pkg,v 14.85 1990/11/14 13:26:46 cph Exp $
 
 Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -1452,12 +1452,14 @@ MIT in each case. |#
          make-output-buffer)
   (export (runtime console-input)
          channel-type=file?
+         input-buffer/buffer-contents
          input-buffer/buffered-chars
          input-buffer/channel
          input-buffer/char-ready?
          input-buffer/eof?
          input-buffer/peek-char
          input-buffer/read-char
+         input-buffer/set-buffer-contents
          input-buffer/set-size
          input-buffer/size
          make-input-buffer
index e7858c1e49e6f2cf31dd1ee299a7044ce16247ff..c456efd8cfde6b24c3218271351b78021f5d1e1b 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/runtime.pkg,v 14.84 1990/11/13 19:21:46 arthur Exp $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/runtime.pkg,v 14.85 1990/11/14 13:26:46 cph Exp $
 
 Copyright (c) 1988, 1989, 1990 Massachusetts Institute of Technology
 
@@ -1452,12 +1452,14 @@ MIT in each case. |#
          make-output-buffer)
   (export (runtime console-input)
          channel-type=file?
+         input-buffer/buffer-contents
          input-buffer/buffered-chars
          input-buffer/channel
          input-buffer/char-ready?
          input-buffer/eof?
          input-buffer/peek-char
          input-buffer/read-char
+         input-buffer/set-buffer-contents
          input-buffer/set-size
          input-buffer/size
          make-input-buffer