[Toybox] [PATCH] grep: add --line-buffered and fix regular buffering.

Rob Landley rob at landley.net
Tue Apr 16 15:21:06 PDT 2019


On 4/11/19 7:35 PM, enh wrote:
> On Thu, Apr 11, 2019 at 4:44 PM Rob Landley <rob at landley.net> wrote:
>> commit 8f882370be150d80969a1910c20b5d223d084b76
>> Author: Rob Landley <rob at landley.net>
>> Date:   Tue Apr 2 15:03:32 2019 -0500
>>
>>     Have xflush() only flush stdout (that's all it checks errors on),
>>     and tweak a couple comments.
>>
>> but removing even that much flushing unless explicitly called is probably fine.
> 
> cool... i've attached a new patch that applies cleanly on ToT.

I meant removing it from libc, which I've just done.

I can add the --line-buffered command line option, but I'm reluctant to add
micromanagement knobs rather than have consistent sane behavior. I _think_ I
want stdout to always be line buffered, and should just call that in main.c? (A
command that really wants something different can set it again, but that seems
like a fairly minor optimization? He says having implemented cat -u way back
when, which ubuntu ignores now...)

Line buffered is the behavior I've been assuming, but I see glibc defaults to
"unbuffered"... in which case what is FILE * _for_ again? A strrchr() on each
buffer with a flush to that point isn't that expensive, and most of the stuff
that cares about micromanaging buffers is already using filehandles instead of
FILE * anyway...

Rob



More information about the Toybox mailing list