[feedgnuplot] 28/42: --hardcopy now handles piped output
Dima Kogan
dkogan-guest at alioth.debian.org
Sun Oct 20 08:04:08 UTC 2013
This is an automated email from the git hooks/post-receive script.
dkogan-guest pushed a commit to tag v1.25
in repository feedgnuplot.
commit ffd19b9b873af6c9a55dcea8e32593fca1a7e68a
Author: Dima Kogan <dima at secretsauce.net>
Date: Sat Oct 19 19:24:57 2013 -0700
--hardcopy now handles piped output
If we tell gnuplot to plot to a file whose name starts with '|', gnuplot writes
to a a process, not to a file. This is now supported by feedgnuplot
---
bin/feedgnuplot | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/bin/feedgnuplot b/bin/feedgnuplot
index 3ac770a..a08da26 100755
--- a/bin/feedgnuplot
+++ b/bin/feedgnuplot
@@ -406,11 +406,15 @@ sub mainThread
my $outputfile;
my $outputfileType;
- if( $options{hardcopy})
+ if( defined $options{hardcopy})
{
$outputfile = $options{hardcopy};
- $outputfile =~ /\.(eps|ps|pdf|png|svg)$/i;
- $outputfileType = $1 ? lc $1 : '';
+ if( $outputfile =~ /^[^|] # starts with anything other than |
+ .* # stuff in the middle
+ \.(eps|ps|pdf|png|svg)$/ix) # ends with a known extension
+ {
+ $outputfileType = lc $1;
+ }
my %terminalOpts =
( eps => 'postscript solid color enhanced eps',
@@ -419,8 +423,12 @@ sub mainThread
png => 'png size 1280,1024',
svg => 'svg');
- $options{terminal} ||= $terminalOpts{$outputfileType}
- if $terminalOpts{$outputfileType};
+ if( !defined $options{terminal} &&
+ defined $outputfileType &&
+ $terminalOpts{$outputfileType} )
+ {
+ $options{terminal} = $terminalOpts{$outputfileType};
+ }
die "Asked to plot to file '$outputfile', but I don't know which terminal to use, and no --terminal given"
unless $options{terminal};
@@ -658,13 +666,20 @@ sub mainThread
# finished reading in all. Plot what we have
plotStoredData();
- if ( $options{hardcopy})
+ if ( defined $options{hardcopy})
{
print PIPE "set output\n";
- # sleep until the plot file exists, and it is closed. Sometimes the output is
- # still being written at this point
- usleep(100_000) until -e $outputfile;
- usleep(100_000) until(system("fuser -s \"$outputfile\""));
+
+ # sleep until the plot file exists, and it is closed. Sometimes the output
+ # is still being written at this point. If the output filename starts with
+ # '|', gnuplot pipes the output to that process, instead of writing to a
+ # file. In that case I don't make sure the file exists, since there IS not
+ # file
+ if( $options{hardcopy} !~ /^\|/ )
+ {
+ usleep(100_000) until -e $outputfile;
+ usleep(100_000) until(system("fuser -s \"$outputfile\""));
+ }
print "Wrote output to $outputfile\n";
return;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/feedgnuplot.git
More information about the debian-science-commits
mailing list