|
From: <P...@dr...> - 2007-12-11 10:43:03
|
I tried to get a gnuplot script to read
from stdin like a normal linux filter using plot '-'
However gnuplot doesn't support this because it
clears it's stdin on startup, as the following
code from plot.c shows:
#ifdef X11
/* This call used to be in x11.trm, with the following comment:
* Multi-character inputs like escape sequences but also mouse-past=
ed
* text got buffered and therefore didn't trigger the select() func=
tion
* in X11_waitforinput(). Switching to unbuffered input solved this=
.
* 23 Jan 2002 (joze)
* But switching to unbuffered mode causes all characters in the inpu=
t
* buffer to be lost. So the only safe time to do it is on program en=
try.
* The #ifdef X11 is probably unnecessary, but makes the change minim=
al.
* Do any non-X platforms suffer from the same problem?
* EAM - Jan 2004.
*/
setvbuf(stdin, (char *) NULL, _IONBF, 0);
#endif
As you can see it's hardcoded, so even if one selects
a different terminal, stdin is still cleared.
I know how to work around this but it's a horrible hack.
I.E. rather than:
gen_data | ./plot.gp > file.png
one needs to do:
(cat plot.gp; gen_data) | gnuplot > file.png
Perhaps FAQ 1.4 could be updated with this info.
Also, can we determine if we're using X11 are runtime,
so that this issue can be worked around using GNUTERM environment
variable for example?
What's the X issue exactly. Does it really need to read from stdin?
thanks,
P=C3=A1draig.
|