* genio.c (scm_do_read_line): Count lines correctly when the file
authorJim Blandy <jimb@red-bean.com>
Sun, 11 Oct 1998 18:42:17 +0000 (18:42 +0000)
committerJim Blandy <jimb@red-bean.com>
Sun, 11 Oct 1998 18:42:17 +0000 (18:42 +0000)
doesn't end in a newline.

libguile/genio.c

index 1e5598d..6072aa4 100644 (file)
@@ -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;