summaryrefslogtreecommitdiff
path: root/lib/linebuffer.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-11-04 23:12:42 +0000
committerJim Meyering <jim@meyering.net>1999-11-04 23:12:42 +0000
commit4b47f20e6a9eab15b70ee638454931ab9dd3c208 (patch)
treeca616dcc826aff3c717b47df1510070a2fdf7b11 /lib/linebuffer.c
parent53d2086432c6652a5757a7134edc381b4942cb14 (diff)
downloadcoreutils-4b47f20e6a9eab15b70ee638454931ab9dd3c208.tar.xz
(readline): Do not leave room for an extra
byte after the newline; it's no longer needed.
Diffstat (limited to 'lib/linebuffer.c')
-rw-r--r--lib/linebuffer.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/linebuffer.c b/lib/linebuffer.c
index cb0b6ba00..3b15d1fb3 100644
--- a/lib/linebuffer.c
+++ b/lib/linebuffer.c
@@ -41,8 +41,7 @@ initbuffer (struct linebuffer *linebuffer)
/* Read an arbitrarily long line of text from STREAM into LINEBUFFER.
Keep the newline; append a newline if it's the last line of a file
- that ends in a non-newline character. Do not null terminate,
- but leave room for an extra byte after the newline.
+ that ends in a non-newline character. Do not null terminate.
Return LINEBUFFER, except at end of file return 0. */
struct linebuffer *
@@ -51,7 +50,7 @@ readline (struct linebuffer *linebuffer, FILE *stream)
int c;
char *buffer = linebuffer->buffer;
char *p = linebuffer->buffer;
- char *end = buffer + linebuffer->size - 1; /* Sentinel. */
+ char *end = buffer + linebuffer->size; /* Sentinel. */
if (feof (stream) || ferror (stream))
return 0;
@@ -73,7 +72,7 @@ readline (struct linebuffer *linebuffer, FILE *stream)
buffer = (char *) xrealloc (buffer, linebuffer->size);
p = p - linebuffer->buffer + buffer;
linebuffer->buffer = buffer;
- end = buffer + linebuffer->size - 1;
+ end = buffer + linebuffer->size;
}
*p++ = c;
}