On Sat, Aug 11, 2012 at 04:51:28PM -0400, Rich Felker wrote: > > I'm sending fgetln.c (+my diff), but please check it... > > btw. it based on /usr.bin/make/util.c from OpenBSD: > > If we add fgetln, I'd like a much higher quality of implementation. > It's not clear from the past documentation I've read for this function > that it's allowed to use a shared static buffer for all FILEs, and > even if it were, I find that really ugly. Instead, simply returning a > pointer into the FILE's buffer when the whole line is already present > in the buffer, and otherwise allocating a FILE-local buffer for it, > would be a lot nicer. fclose could then check the FILE-local pointer > and free if it it was allocated. See attached. Does it work okay? Rich