Next Previous Up Top Contents Index

5.11 The STREAMS module

read-line-into!

Open generic function

Summary

Reads a stream up to the next newline into a string.

Signature

read-line-into! input-stream string 
#key start on-end-of-stream grow?
=> string-or-eof newline?

Arguments

input-stream
An instance of <stream>.

string
An instance of <string>.

start
An instance of <integer>. Default value: 0.

on-end-of-stream
An instance of <object>.

grow?
An instance of <boolean>. Default value: #f.

Values

string-or-eof
An instance of <string>, or an instance of <object> if the end of the stream is reached.

newline?
An instance of <boolean>.

Library

io

Module

streams

Description

Fills string with all the input from input-stream up to the next newline sequence. The string must be a general instance of <string> that can hold elements of the stream's element type.

The input is written into string starting at the position start. By default, start is the start of the stream.

The second return value is #t if the read terminated with a newline, or #f if the read completed by getting to the end of the input stream.

If grow? is #t, and string is not large enough to hold all of the input, read-line-into! creates a new string which it writes to and returns instead. The resulting string holds all the original elements of string, except where read-line-into! overwrites them with input from input-stream.

In a manner consistent with the intended semantics of grow?, when grow? is #t and start is greater than or equal to string.size, read-line-into! grows string to accommodate the start index and the new input.

If grow? is #f and string is not large enough to hold the input, the function signals an error.

The end-of-stream behavior and the interpretation of on-end-of-stream is the same as that of read-line.

See also

read-line, page 86


System and I/O Reference - 31 MAR 2000

Next Previous Up Top Contents Index