From 6d3eaac64ccfdc806ae4ab76eed4f815415557c6 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Wed, 14 Nov 1990 13:26:46 +0000 Subject: [PATCH] New operations on input-buffer for saving and restoring the contents 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 | 21 +++++++++++++++++++-- v7/src/runtime/runtime.pkg | 4 +++- v8/src/runtime/runtime.pkg | 4 +++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/v7/src/runtime/io.scm b/v7/src/runtime/io.scm index 1ff9c8154..e2a21f187 100644 --- a/v7/src/runtime/io.scm +++ b/v7/src/runtime/io.scm @@ -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 diff --git a/v7/src/runtime/runtime.pkg b/v7/src/runtime/runtime.pkg index 46c03dc55..8d845f72b 100644 --- a/v7/src/runtime/runtime.pkg +++ b/v7/src/runtime/runtime.pkg @@ -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 diff --git a/v8/src/runtime/runtime.pkg b/v8/src/runtime/runtime.pkg index e7858c1e4..c456efd8c 100644 --- a/v8/src/runtime/runtime.pkg +++ b/v8/src/runtime/runtime.pkg @@ -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 -- 2.25.1