Files
mercury/tests/general/read_line_as_string.m
Andrew Bromage 586c5e16c6 Implement io__read_line_as_string/{3,4}.
Estimated hours taken: 10

library/io.m:
library/io.nu.nl:
	Implement io__read_line_as_string/{3,4}.

	Also sneaked in here are some trivial whitespace fixes in some
	of the pragma c_code which did not comply with our coding
	standards (to do with type casting).

samples/cat.m:
samples/sort.m:
	Use io__read_line_as_string.

tests/general/Mmakefile:
tests/general/read_line_as_string.exp:
tests/general/read_line_as_string.m:
	Test case for io__read_line_as_string.

NEWS:
	Mention the above change.
1998-09-09 06:05:30 +00:00

32 lines
669 B
Mathematica

:- module read_line_as_string.
:- interface.
:- import_module io.
:- pred main(io__state :: di, io__state :: uo) is det.
:- implementation.
main -->
io__open_input("read_line_as_string.exp", Result),
( { Result = ok(Stream) } ->
io__set_input_stream(Stream, _),
io__read_line_as_string(Result2),
cat(Result2)
;
io__write_string("Error opening file!")
).
:- pred cat(io__result(string)::in, io__state::di, io__state::uo) is det.
cat(Result) -->
( { Result = ok(Line) },
io__write_string(Line),
io__read_line_as_string(NextResult),
cat(NextResult)
; { Result = eof }
; { Result = error(_Error) },
io__write_string("Error reading file!")
).