From 5ead5a91d024ad4bad8f6108b26e2eb68a696b0c Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Sun, 11 Oct 1998 18:42:17 +0000 Subject: [PATCH] * genio.c (scm_do_read_line): Count lines correctly when the file doesn't end in a newline. --- libguile/genio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libguile/genio.c b/libguile/genio.c index 1e5598dde..6072aa4cb 100644 --- a/libguile/genio.c +++ b/libguile/genio.c @@ -182,7 +182,10 @@ scm_do_read_line (port, len) i = SCM_PTOBNUM (port); SCM_SYSCALL (s = (scm_ptobs[i].fgets) (port, len)); - if (s) + + /* If we're not at EOF, and there was a newline at the end of the + string, increment the line counter. */ + if (s && *len > 0 && s[*len - 1] == '\n') SCM_INCLINE(port); return s;