From d8488ec48ea9422f182d00779f898f827caf0500 Mon Sep 17 00:00:00 2001 From: vsc Date: Tue, 15 Apr 2008 11:08:10 +0000 Subject: [PATCH] fix CR in read_line_to_codes git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2219 b08c6af1-5177-4d33-ba66-4b1c6b8b522a --- C/readutil.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/C/readutil.c b/C/readutil.c index 9ba116e47..c4c5bbf27 100644 --- a/C/readutil.c +++ b/C/readutil.c @@ -66,7 +66,11 @@ rl_to_codes(Term TEnd, int do_as_binary, int arity) Term end; UNLOCK(Stream[sno].streamlock); if (!(do_as_binary || Stream[sno].status & Eof_Stream_f)) { - buf[sz-1] = '\0'; + /* handle CR before NL */ + if (sz-2 >= 0 && buf[sz-2] == 13) + buf[sz-2] = '\0'; + else + buf[sz-1] = '\0'; } if (arity == 2) end = TermNil;