From fa0b55ba5b59ae3b338d0c517fe5fdc0c8926836 Mon Sep 17 00:00:00 2001 From: Vadim Penzin Date: Thu, 5 Jan 2017 13:44:38 +0200 Subject: [PATCH] Prevent CLOS' stream-read-line from signalling end-of-file while reading unterminated lines. --- src/c/read.d | 2 +- src/clos/streams.lsp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/c/read.d b/src/c/read.d index ba92e522c..90a0a5267 100644 --- a/src/c/read.d +++ b/src/c/read.d @@ -1630,7 +1630,7 @@ do_read_delimited_list(int d, cl_object in, bool proper_list) if (!ECL_ANSI_STREAM_P(strm)) { value0 = _ecl_funcall2(@'gray::stream-read-line', strm); value1 = ecl_nth_value(the_env, 1); - if (!Null(value1)) { + if (Null(value0) && !Null(value1)) { if (!Null(eof_errorp)) FEend_of_file(strm); value0 = eof_value; diff --git a/src/clos/streams.lsp b/src/clos/streams.lsp index ec2e79c00..6b359258c 100644 --- a/src/clos/streams.lsp +++ b/src/clos/streams.lsp @@ -512,7 +512,10 @@ (loop (let ((ch (stream-read-char stream))) (cond ((eq ch :eof) - (return (values (si::shrink-vector res index) t))) + (return (values (if (zerop index) + nil + (si::shrink-vector res index)) + t))) (t (when (char= ch #\newline) (return (values (si::shrink-vector res index) nil)))