Ethan Merritt wrote:
> On Monday 10 January 2005 10:46 pm, Ethan Merritt wrote:
>>> diff -u -r1.72 plot.c
>>> --- plot.c 25 Aug 2004 22:33:16 -0000 1.72
>>> +++ plot.c 11 Jan 2005 05:26:21 -0000
>>> @@ -422,7 +422,9 @@
>>> * Do any non-X platforms suffer from the same problem?
>>> * EAM - Jan 2004.
>>> */
>>> - setvbuf(stdin, (char *) NULL, _IONBF, 0);
>>> + if (isatty(fileno(stdin))) {
>>> + setvbuf(stdin, (char *) NULL, _IONBF, 0);
>>> + }
>>> #endif
>>
>> I see why you want this. But speed is no good if the program
>> does not function properly, and previous experience showed that
>> unbuffering the input stream was needed for at least some
>> implementations of piped input.
>
> I have changed my mind. The behavior is not likely to differ
> from user to user, only from one platform to another. So it should
> be a configuration option for building on that platform, not a
> run-time option on the command line.
>
> How about we wrap the code as follows:
>
> #ifndef UNBUFFERED_STDIN
> setvbuf(stdin, (char *) NULL, _IONBF, 0);
> #endif
>
> and you can provide a brief set of instructions for how to set
> this conditional compilation flag during the cygwin configuration setup.
> I have not used cygwin, so I don't know exactly how that is done.
>
> It would be nice if you also checked that this doesn't interfere
> with correct execution of "pause" commands, however, since as I
> recall that was one of the original problems this was supposed to fix.
> For instance, please check that "mousevariables.dem" works properly with
> buffered input under cygwin.
>
The attached patch achieves the speedup and works
properly with mousevariables.dem.
The use of __CYGWIN__ makes it specific to that platform.
I suspect this would also help other platforms.
Please consider for upstream inclusion.
Thanks - Jim
|