[prev in list] [next in list] [prev in thread] [next in thread]
List: gnuplot-info-beta
Subject: Re: Command line way to prevent unbuffered?
From: Jim Kleckner <jek-gp () kleckner ! net>
Date: 2008-06-30 20:01:13
Message-ID: 48693B89.8020901 () kleckner ! net
[Download RAW message or body]
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
["gnuplot-setvbuf.patch" (text/plain)]
diff -urN -x CYGWIN-PATCHES -x 'aclocal.m4*' -x autom4te.cache -x config.cache -x \
config.log -x config.status -x config.h -x config.h.in -x ABOUT-NLS -x Makefile.in.in \
-x Makevars.template -x '*SlackBuild*' -x '*.egg-info' -x '*.class' -x '*.pyc' -x \
'*.mo' -x '*.gmo' -x '*.orig' -x '*.rej' -x '*.spec' -x '*.temp' -x '*~' -x \
'*.stackdump' -x COPYING -x INSTALL -x compile -x config-ml.in -x config.guess -x \
config.sub -x depcomp -x elisp-comp -x install-sh -x ltmain.sh -x mdate-sh -x missing \
-x mkinstalldirs -x py-compile -x symlink-tree -x texinfo.tex -x ylwrap -x \
config.rpath -x Makefile.in -x makefile.in -x configure -x omf.make -x xmldocs.make \
-x gnome-doc-utils.make -x gnome-doc-utils.m4 -x intltool.m4 -x intltool-extract -x \
intltool-extract.in -x intltool-merge -x intltool-merge.in -x intltool-update -x \
intltool-update.in -x gnuplot.texi origsrc/gnuplot-4.2.3/src/plot.c \
src/gnuplot-4.2.3/src/plot.c
--- origsrc/gnuplot-4.2.3/src/plot.c 2007-06-07 09:26:32.000000000 -0700
+++ src/gnuplot-4.2.3/src/plot.c 2008-06-27 17:45:33.974729600 -0700
@@ -433,8 +433,15 @@
* Failing this, I propose we just make the call and
* ignore the return : its probably not a big deal
*/
+#ifdef __CYGWIN__
+ if (isatty(fileno(stdin))) {
+ if (setvbuf(stdout, (char *) NULL, _IOLBF, (size_t) 1024) != 0)
+ (void) fputs("Could not linebuffer stdout\n", stderr);
+ }
+#else
if (setvbuf(stdout, (char *) NULL, _IOLBF, (size_t) 1024) != 0)
(void) fputs("Could not linebuffer stdout\n", stderr);
+#endif
#ifdef X11
/* This call used to be in x11.trm, with the following comment:
@@ -448,8 +455,14 @@
* Do any non-X platforms suffer from the same problem?
* EAM - Jan 2004.
*/
+#ifdef __CYGWIN__
+ if (isatty(fileno(stdin))) {
+ setvbuf(stdin, (char *) NULL, _IONBF, 0);
+ }
+#else
setvbuf(stdin, (char *) NULL, _IONBF, 0);
#endif
+#endif
#endif
diff -urN -x CYGWIN-PATCHES -x 'aclocal.m4*' -x autom4te.cache -x config.cache -x \
config.log -x config.status -x config.h -x config.h.in -x ABOUT-NLS -x Makefile.in.in \
-x Makevars.template -x '*SlackBuild*' -x '*.egg-info' -x '*.class' -x '*.pyc' -x \
'*.mo' -x '*.gmo' -x '*.orig' -x '*.rej' -x '*.spec' -x '*.temp' -x '*~' -x \
'*.stackdump' -x COPYING -x INSTALL -x compile -x config-ml.in -x config.guess -x \
config.sub -x depcomp -x elisp-comp -x install-sh -x ltmain.sh -x mdate-sh -x missing \
-x mkinstalldirs -x py-compile -x symlink-tree -x texinfo.tex -x ylwrap -x \
config.rpath -x Makefile.in -x makefile.in -x configure -x omf.make -x xmldocs.make \
-x gnome-doc-utils.make -x gnome-doc-utils.m4 -x intltool.m4 -x intltool-extract -x \
intltool-extract.in -x intltool-merge -x intltool-merge.in -x intltool-update -x \
intltool-update.in -x gnuplot.texi origsrc/gnuplot-4.2.3/src/readline.c \
src/gnuplot-4.2.3/src/readline.c
--- origsrc/gnuplot-4.2.3/src/readline.c 2006-04-28 09:54:03.000000000 -0700
+++ src/gnuplot-4.2.3/src/readline.c 2008-06-27 17:45:35.476889600 -0700
@@ -1014,7 +1014,13 @@
# endif /* TERMIOS */
# endif /* not SGTTY */
# else /* OSK */
+#ifdef __CYGWIN__
+ if (isatty(fileno(stdin))) {
+ setbuf(stdin, (char *) 0); /* Make stdin and stdout unbuffered */
+ }
+#else
setbuf(stdin, (char *) 0); /* Make stdin and stdout unbuffered */
+#endif
setbuf(stderr, (char *) 0);
_gs_opt(STDIN, &new_settings);
# endif /* OSK */
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
gnuplot-beta mailing list
gnuplot-beta@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic