Does NEWLINE always flush stdio buffer?

Peter da Silva peter at ficc.uu.net
Mon Jul 10 02:24:23 AEST 1989


In article <10490 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
> In article <4861 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
> >>The cost of implementing this can be substantial!
> >No, it is not. In fact, if ... _filbuf(stdin) calls _flsbuf(stdout) ...

> It is not just stdout, but ALL terminal-associated streams that are
> supposed to be flushed.

A little odd, but defensible.

I don't know if this is a mistake or not, but I'd like to ask how many
terminal-associated streams the majority of applications open...

> Also, during output it is necessary to check
> each character against new-line to implement line buffering.

Only if you want to implement line-buffering. Smart buffering (where you
flush output buffers when you go to fill input buffers) almost completely
removes any need for line buffering, and radically reduces the need for
explicit fflush()ing.

> I stand by my assessment that line buffering is a mistake.

I agree. Line buffering is a mistake. But if you have a look at what I wrote
you'll see I didn't advocate line buffering.
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Business: peter at ficc.uu.net, +1 713 274 5180. | "WHAT HAPPENED TO ALL
Personal: peter at sugar.hackercorp.com.   `-_-' |  THE WOMEN IN TEXAS?"
Quote: Have you hugged your wolf today?  'U`  |  -- ACS1W at jane.uh.edu (meesh)



More information about the Comp.lang.c mailing list