|
Message-ID: <20120812002450.GA17066@brightrain.aerifal.cx>
Date: Sat, 11 Aug 2012 20:24:50 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: portable fgetln
Hi all,
Based on a discussion on #musl about the merits of fgetln as an
efficient (probably optimal) way to do line-based stdio processing if
the implementation is good, I got to wondering if it's viable to use
the interface in programs intended to be portable, i.e. if it could be
written portably for use on any stdio implementation or at least any
POSIX one. Here's the result -- a sample portable implementation that
keeps a separate buffer for each fd, or for each FILE* when the stream
lacks an associated fd. It has some limitations, but it seems to meet
the interface contract and avoids using a single static buffer that
would render if non-thread-safe.
Rich
View attachment "portable_fgetln.c" of type "text/plain" (932 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.