Skip to content

Commit 3d7f16f

Browse files
committed
PGPLOT use pgplot API to get devices, as the prophecy foretold
1 parent d674bea commit 3d7f16f

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

Changes

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
- P{GPLOT,Lplot} to read devices using proper API not subprocesses
2+
13
1.010 2024-03-24
24
- fix PGPLOT to read devices correctly
35

lib/PDL/Graphics/Simple/PGPLOT.pm

+8-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ use strict;
1717
use warnings;
1818
use File::Temp qw/tempfile/;
1919
use PDL::Options q/iparse/;
20-
use IPC::Open2;
2120

2221
use PDL;
2322

@@ -47,18 +46,20 @@ sub check {
4746
return 0;
4847
}
4948
# Module loaded OK, now try to extract valid devices from it
50-
my @lines = eval {
51-
open2(my $chld_out, my $chld_in, $^X, qw(-MPGPLOT -e pgopen(q[?])));
52-
print $chld_in "?\n";
53-
close $chld_in;
54-
grep /^\s+\//, <$chld_out>;
49+
eval {
50+
my %devs;
51+
PGPLOT::pgqndt(my $n);
52+
for my $count (1..$n) {
53+
PGPLOT::pgqdt($count,my ($type,$v1,$descr,$v2,$v3));
54+
$devs{substr $type, 1} = 1; # chop off "/"
55+
}
56+
$mod->{devices} = \%devs;
5557
};
5658
if ($@) {
5759
$mod->{ok} = 0;
5860
$mod->{msg} = $@;
5961
return 0;
6062
}
61-
$mod->{devices} = { map { chomp; s/^\s*\///; s/\s.*//; ($_,1) } @lines };
6263
delete $mod->{disp_dev};
6364
TRY:for my $try(qw/XWINDOW XSERVE CGW GW/){
6465
if($mod->{devices}->{$try}) {

0 commit comments

Comments
 (0)