Implement procedures READ-STRING! and READ-LINE.
#| -*-Scheme-*-
-$Id: cpress.scm,v 1.7 1995/09/29 19:57:46 cph Exp $
+$Id: cpress.scm,v 1.8 1997/02/21 06:12:33 cph Exp $
-Copyright (c) 1992-95 Massachusetts Institute of Technology
+Copyright (c) 1992-97 Massachusetts Institute of Technology
This material was developed by the Scheme project at the Massachusetts
Institute of Technology, Department of Electrical Engineering and
(write-literal literal-max)
(loop (fix:- nb literal-max)))))))
(compress-continuation unspecific))
-
-(define (input-port/read-substring port string start end)
- ;; This should be in the runtime system.
- (let ((operation (port/operation port 'READ-SUBSTRING)))
- (if operation
- (operation port string start end)
- (let loop ((index start))
- (if (fix:< index end)
- (let ((char (input-port/read-char port)))
- (cond ((not char)
- (and (fix:> index start)
- (fix:- index start)))
- ((eof-object? char)
- (fix:- index start))
- (else
- (string-set! string index char)
- (loop (fix:+ index 1)))))
- (fix:- index start))))))
\f
(define (guarantee-buffer-space nb)
;; Make sure that the byte buffer has enough space to hold NB bytes.
#| -*-Scheme-*-
-$Id: input.scm,v 14.17 1997/02/21 05:42:32 cph Exp $
+$Id: input.scm,v 14.18 1997/02/21 06:08:15 cph Exp $
Copyright (c) 1988-97 Massachusetts Institute of Technology
(guarantee-input-port port))))
(define (read-string! string #!optional start end port)
- (input-port/read-substring! string
+ (input-port/read-substring! (if (default-object? port)
+ (current-input-port)
+ (guarantee-input-port port))
+ string
(if (default-object? start)
0
start)
(if (default-object? end)
(string-length string)
- end)
- (if (default-object? port)
- (current-input-port)
- (guarantee-input-port port))))
\ No newline at end of file
+ end)))
\ No newline at end of file
#| -*-Scheme-*-
-$Id: port.scm,v 1.9 1997/02/21 05:42:40 cph Exp $
+$Id: port.scm,v 1.10 1997/02/21 06:05:20 cph Exp $
Copyright (c) 1991-97 Massachusetts Institute of Technology
((DISCARD-CHAR) (input-port/operation/discard-char port))
((READ-STRING) (input-port/operation/read-string port))
((DISCARD-CHARS) (input-port/operation/discard-chars port))
+ ((READ-SUBSTRING) (input-port/operation/read-substring port))
((WRITE-CHAR) (output-port/operation/write-char port))
((WRITE-STRING) (output-port/operation/write-string port))
((WRITE-SUBSTRING) (output-port/operation/write-substring port))