Re: Bug in external editor code
- From: Peter Bloomfield <PeterBloomfield MindSpring com>
- To: balsa-list gnome org
- Subject: Re: Bug in external editor code
- Date: Sat, 26 Jan 2002 07:44:59 -0500
Well, this was educational for me! From glibc-2.2.4/stdio/fgets.c:
/* Reads characters from STREAM into S, until either a newline character
is read, N - 1 characters have been read, or EOF is seen. Returns
the newline, unlike gets. Finishes by appending a null character
and
returning S. If EOF is seen before any characters have been written
to S, the function returns NULL without appending the null
character.
If there is a file error, always return NULL. */
char *
fgets (s, n, stream)
So it's documented...in the source! The man page reads:
fgets() reads in at most one less than size characters
from stream and stores them into the buffer pointed to by
s. Reading stops after an EOF or a newline. If a newline
is read, it is stored into the buffer. A '\0' is stored
after the last character in the buffer.
Does `last character' imply that there is at least one character in the
buffer? If so, the man page is consistent with what fgets really does,
but it's easily misread as meaning `A '\0' is stored after any
characters'.
Anyway, the code is clear!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]