[feedgnuplot] 01/15: Data can now come from STDIN or files on the cmdline
Dima Kogan
dima at secretsauce.net
Tue Jun 20 23:46:30 UTC 2017
This is an automated email from the git hooks/post-receive script.
dkogan-guest pushed a commit to branch debian
in repository feedgnuplot.
commit 5740e55a6f2d8b212fa77dcfb1cd59926a5d26a5
Author: Dima Kogan <dima at secretsauce.net>
Date: Sun Mar 19 19:50:34 2017 -0700
Data can now come from STDIN or files on the cmdline
This emulates the while(<>) syntax in perl, and makes self-plotting data files
work again. These have been broken since that syntax was taken away in
4cfcf0fc35f5835a2ebd7a5e7dd9458da263995f
---
bin/feedgnuplot | 70 +++++++++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 58 insertions(+), 12 deletions(-)
diff --git a/bin/feedgnuplot b/bin/feedgnuplot
index 6d4c5f5..e91777a 100755
--- a/bin/feedgnuplot
+++ b/bin/feedgnuplot
@@ -41,17 +41,10 @@ my $last_replot_time = [gettimeofday];
# whether the previous replot was timer based
my $last_replot_is_from_timer = 1;
-
-
-my $prev_timed_replot_time = [gettimeofday];
my $this_replot_is_from_timer;
-my $stdin = IO::Handle->new();
-die "Couldn't open STDIN" unless $stdin->fdopen(fileno(STDIN),"r");
-my $selector = IO::Select->new( $stdin );
-mainThread();
@@ -122,7 +115,6 @@ sub interpretCommandline
'help', 'dump', 'exit', 'version',
'geometry=s') or exit 1;
-
# handle various cmdline-option errors
if ( $options{help} )
{
@@ -479,16 +471,66 @@ sub makeDomainNumeric
}
+my $prev_timed_replot_time = [gettimeofday];
+my $pipe_in;
+my $selector;
+my $line_number = 0;
+my $is_stdin = !@ARGV; # read stdin only if no data files given on the cmdline
+sub openNextFile
+{
+ my $fd;
+ if($is_stdin)
+ {
+ $fd = IO::Handle->new();
+ $fd->fdopen(fileno(STDIN), "r") or die "Couldn't open STDIN";
+ }
+ else
+ {
+ my $filename = shift @ARGV;
+ $fd = IO::File->new($filename, "r") or die "Couldn't open file '$filename'";
+ }
+
+ my $selector = IO::Select->new( $fd );
+ return ($fd, $selector);
+}
sub getNextLine
{
+ sub getline_internal
+ {
+ while(1)
+ {
+ my $line = $pipe_in->getline();
+ if( !$is_stdin && !defined $line && $pipe_in->eof() && @ARGV)
+ {
+ # I got to the end of one file, so open the next one (which I'm
+ # sure exists)
+ ($pipe_in, $selector) = openNextFile();
+ next;
+ }
+ return $line;
+ }
+ }
+
+
+
+
+
+ if( !defined $pipe_in )
+ {
+ ($pipe_in, $selector) = openNextFile();
+ }
+
while(1)
{
$this_replot_is_from_timer = undef;
# if we're not streaming, or we're doing triggered-only replotting, simply
# do a blocking read
- return $stdin->getline()
- if (! $options{stream} || $options{stream} < 0);
+ if (! $options{stream} || $options{stream} < 0)
+ {
+ $line_number++;
+ return getline_internal();
+ }
my $now = [gettimeofday];
@@ -503,7 +545,8 @@ sub getNextLine
if ($selector->can_read($time_remaining))
{
- return $stdin->getline();
+ $line_number++;
+ return getline_internal();
}
}
}
@@ -773,7 +816,7 @@ sub mainThread
}
else
{
- $domain[0] = $.;
+ $domain[0] = $line_number;
$domain0_numeric = makeDomainNumeric( $domain[0] );
}
@@ -1082,6 +1125,9 @@ sub pushPoint
}
+mainThread();
+
+
=head1 NAME
feedgnuplot - General purpose pipe-oriented plotting tool
--
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