Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [day] [month] [year] [list]
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

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.