From: Mark Date: Wed, 19 Jul 2023 23:13:47 +0000 (-0600) Subject: check for unexpected EOF in get_to_eof (#1897) X-Git-Tag: v0.9.2~38 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=4fd247f881d7c6cd8dfc3e060f2a7cca74a24e5d;p=scryer-prolog.git check for unexpected EOF in get_to_eof (#1897) --- diff --git a/src/lib/charsio.pl b/src/lib/charsio.pl index 618416f1..d47d3642 100644 --- a/src/lib/charsio.pl +++ b/src/lib/charsio.pl @@ -323,8 +323,13 @@ get_n_chars(Stream, N, Cs) :- '$get_n_chars'(Stream, N, Cs) ). +get_n_chars_wrapper(Stream, N, Cs) :- + '$get_n_chars'(Stream, N, Cs). + get_to_eof(Stream, Cs) :- - '$get_n_chars'(Stream, 512, Cs0), + catch(get_n_chars_wrapper(Stream, 512, Cs0), + error(syntax_error(unexpected_end_of_file), _), + Cs0 = []), ( Cs0 == [] -> Cs = [] ; partial_string(Cs0, Cs, Rest), get_to_eof(Stream, Rest)