Skip Menu |

This queue is for tickets about the PDL-Graphics-Gnuplot CPAN distribution.

Report information
The Basics
Id: 80300
Status: resolved
Priority: 0/
Queue: PDL-Graphics-Gnuplot

People
Owner: Nobody in particular
Requestors: sisyphus [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.2-2
Fixed in: (no value)



Subject: 1.2-2 won't build on perl-5.8.x
Hi, perl-5.8.x doesn't understand the // operator (which is to be found in a few places in PDL/Graphics/Gnuplot.pm). If we don't want to make this module available for 5.8.x, then we should probably 'use 5.10;' in the Makefile.PL (and perhaps do the same in Gnuplot.pm). This would signal our intention quite clearly that pre-5.10 versions of perl are not supported. Otherwise, I guess we should replace the instances of the // operator in Gnuplot.pm with code that 5.8.x *does* understand. AFAIK PDL itself still supports 5.8.1 and later - some may regard that as sufficient reason that PDL::Graphics::Gnuplot ought to build on perls back to 5.8.1. I personally have no vested interest regarding which (if any) path is chosen. (If a patch is required here, just let me know and and I will create it.) Cheers, Rob
On Sat Oct 20 04:54:15 2012, SISYPHUS wrote: Show quoted text
> If we don't want to make this module available for 5.8.x, then we should > probably 'use 5.10;' in the Makefile.PL (and perhaps do the same in > Gnuplot.pm).
Except, of course, that should be 'use 5.01;' (or even 'use 5.010;'). Cheers, Rob
CC: Craig DeForest <craig [...] deforest.org>
Subject: Re: [rt.cpan.org #80300] 1.2-2 won't build on perl-5.8.x
Date: Sun, 21 Oct 2012 00:22:04 -0600
To: bug-PDL-Graphics-Gnuplot [...] rt.cpan.org
From: Craig DeForest <craig [...] deforest.org>
Yup. I'm all for putting in a "use 5.010" - if someone can't be bothered to upgrade perl in 5 years, they just don't care. On Oct 21, 2012, at 12:13 AM, Sisyphus via RT wrote: Show quoted text
> Queue: PDL-Graphics-Gnuplot > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=80300 > > > On Sat Oct 20 04:54:15 2012, SISYPHUS wrote: >
>> If we don't want to make this module available for 5.8.x, then we should >> probably 'use 5.10;' in the Makefile.PL (and perhaps do the same in >> Gnuplot.pm).
> > Except, of course, that should be 'use 5.01;' (or even 'use 5.010;'). > > Cheers, > Rob
Okay, this is fixed in git -- I just added "use 5.010". Will push up to CPAN as 1.2.3 when the current round is dealt with.
On Sat Oct 20 04:54:15 2012, SISYPHUS wrote: Show quoted text
> Otherwise, I guess we should replace the instances of the // operator in > Gnuplot.pm with code that 5.8.x *does* understand.
If you wish to go down this path, you might like to check that the attached patch to Gnuplot.pm is satisfactory. It worked ok for me on 5.8.9 on MS Windows. Cheers, Rob
Subject: defined_op.diff
--- Gnuplot.pm_orig 2012-10-21 17:41:23 +1100 +++ Gnuplot.pm 2012-10-21 18:00:29 +1100 @@ -2122,7 +2122,7 @@ for my $i(0..$#$chunks) { # Allow global binary/ASCII flag to be overridden by per-curve binary/ASCII flag - $chunks->[$i]->{binaryCurveFlag} = $chunks->[$i]->{binaryWith} // $binary_mode; + $chunks->[$i]->{binaryCurveFlag} = _defined_eq($chunks->[$i]->{binaryWith}, $binary_mode); # Everything else is an image fix next if( $chunks->[$i]->{cdims} != 2 ); @@ -2232,7 +2232,7 @@ # If we're working with time data, and timefmt isn't set, then default it to '%s'. $this->{options}->{timefmt} = '%s' if ( !defined($this->{options}->{timefmt}) and - grep { ($this->{options}->{$_."data"} // "") =~ m/^time/i } qw/x x2 y y2 z cb/ ); + grep { _defined_eq($this->{options}->{$_."data"}, "") =~ m/^time/i } qw/x x2 y y2 z cb/ ); ########## # Merge in any temporary options that have been set by the argument parsing. @@ -2601,7 +2601,7 @@ # Make sure we know our "with" style... unless($chunk{options}{with}) { - $chunk{options}{with} = $this->{options}->{'globalwith'} // ["lines"]; + $chunk{options}{with} = _defined_eq($this->{options}->{'globalwith'}, ["lines"]); } # validate "with" and get imgFlag and tupleSizes. @@ -3301,7 +3301,7 @@ my $mouse_serial = 0; sub read_mouse { my $this = shift; - my $message = shift // "Click mouse in plot to continue..."; + my $message = _defined_eq(shift, "Click mouse in plot to continue..."); barf "read_mouse: This plot uses the '$this->{terminal}' terminal, which doesn't support mousing\n" unless($this->{mouse}); @@ -3324,7 +3324,7 @@ $string =~ m/Key: (\-?\d+)( +at xy:([^\s\,]+),([^\s\,]+)? button:(\d+)? shift:(\d+) alt:(\d+) ctrl:(\d+))?/ || barf "read_mouse: string $string doesn't look right - doesn't match parse regexp.\n"; - my($ch,$x,$y,$b,$sft,$alt,$ctl) = map { $_ // "" } ($1,$3,$4,$5,$6,$7,$8); + my($ch,$x,$y,$b,$sft,$alt,$ctl) = map { _defined_eq($_, "") } ($1,$3,$4,$5,$6,$7,$8); if(wantarray) { return ($x,$y, ($ch>=32)?chr($ch):undef, @@ -4056,8 +4056,8 @@ my @numbers = (); my @v = @$v; - while( @v && (($v[0]//"") =~ m/^(\s*\-?((\d+\.?\d*)|(\d*\.\d+))([eE][\+\-]\d*)?\s*)?$/ )) { - push(@numbers, (shift(@v)//"")); + while( @v && (_defined_eq($v[0], "") =~ m/^(\s*\-?((\d+\.?\d*)|(\d*\.\d+))([eE][\+\-]\d*)?\s*)?$/ )) { + push(@numbers, _defined_eq(shift(@v), "")); } my $s = ""; $s .= "set view ".join(",",@numbers)."\n" if(@numbers); @@ -4243,7 +4243,7 @@ # data is here so that it gets sorted properly into each chunk -- but it doesn't get specified this way. # the output string just specifies STDIN. The magic output string gets replaced post facto with the test and # real output format specifiers. - 'cdims' => [sub { my $s = $_[1] // 0; # Number of dimensions in a column + 'cdims' => [sub { my $s = _defined_eq($_[1], 0); # Number of dimensions in a column if($s==0 or $s==1 or $s==2) { return $s; } else { @@ -4716,7 +4716,7 @@ push(@list, "(", join(", ", map { barf "<foo>tics: labels list elements must be duals or triples as list refs" unless(ref $_ eq 'ARRAY'); - sprintf('"%s" %s %s', $_->[0]//"", $_->[1]//0, $_->[2]//""); + sprintf('"%s" %s %s', _defined_eq($_->[0], ""), _defined_eq($_->[1], 0), _defined_eq($_->[2], "")); } @{$new->{labels}} ), @@ -4983,7 +4983,7 @@ #### A boolean or 'time' (for <foo>data plot options) 'bt' => sub { my($k,$v,$h) = @_; - return "set $k\n" unless ($v // "" and $v=~m/^t/i); + return "set $k\n" unless (_defined_eq($v, "") and $v=~m/^t/i); return "set $k $v\n";rxt hel }, @@ -5214,17 +5214,17 @@ #looks like 'set <foo>range restore' (only way 'r' can be the first char) - return "set $k ".join(" ",@$v)."\n" if(($v->[0] // '') =~ m/^\s*r/i); + return "set $k ".join(" ",@$v)."\n" if(_defined_eq($v->[0], '') =~ m/^\s*r/i); # first element is an empty range specifier - emit. - return "set $k ".join(" ",@$v)."\n" if(($v->[0] // '') =~ m/\s*\[\s*\]/); + return "set $k ".join(" ",@$v)."\n" if(_defined_eq($v->[0], '') =~ m/\s*\[\s*\]/); my $c = substr($k,0,1); - my $tfmt = ( $h->{$c."data"} // "" ) =~ m/time/; + my $tfmt = _defined_eq( $h->{$c."data"}, "" ) =~ m/time/; # first element has a nonempty range specifier (naked or not). - if(($v->[0] // '') =~ m/\:/) { + if(_defined_eq($v->[0], '') =~ m/\:/) { $v->[0]=~ s/^\s*((.*[^\s])?)\s*$/$1/; # trim leading and trailing whitespace if present unless($v->[0] =~ m/^\[/) { @@ -5247,7 +5247,7 @@ # specifier out of 'em, then emit. # Here's a little fillip: gnuplot requires quotes around time ranges # if the corresponding axes are time data. Handle that bizarre case. - if( ($h->{$c."data"} // "" ) =~ m/time/ ) { + if( _defined_eq($h->{$c."data"}, "" ) =~ m/time/ ) { return sprintf("set %s [%s:%s]\n",$k, ((defined $v->[0])?"\"$v->[0]\"":"*"), ((defined $v->[1])?"\"$v->[1]\"":"*")); } @@ -5262,7 +5262,7 @@ # if the corresponding axes are time data. Handle that bizarre case. my $c = substr($k,0,1); - if( (($this and $this->{options} and $this->{options}->{$c."data"}) // "" ) =~ m/time/ ) { + if( _defined_eq(($this and $this->{options} and $this->{options}->{$c."data"}), "" ) =~ m/time/ ) { print STDERR "WARNING: gnuplot-4.6.1 date range bug triggered. Check the date scale.\n"; return sprintf(" [%s:%s] ",((defined $v->[0])?"\"$v->[0]\"":""), ((defined $v->[1])?"\"$v->[1]\"":"")); } @@ -5607,8 +5607,8 @@ $terminalOpt->{"wait"} = [ 's' , sub { return "" }, undef, $i++, "wait time before throwing an error (default 5s)" ]; $termTab->{$k} = { desc => $termTabSource->{$k}->{desc}, unit => $termTabSource->{$k}->{unit}, - mouse => $termTabSource->{$k}->{mouse} // 0, - int => $termTabSource->{$k}->{int} // 0, + mouse => _defined_eq($termTabSource->{$k}->{mouse}, 0), + int => _defined_eq($termTabSource->{$k}->{int}, 0), opt => [ $terminalOpt, undef, # This gets filled in on first use in the constructor. "$k terminal options" @@ -5920,9 +5920,9 @@ sub _checkpoint { my $this = shift; my $suffix = shift || "main"; - my $opt = shift // {}; - my $notimeout = $opt->{notimeout} // 0; - my $printwarnings = (($opt->{printwarnings} // 0) and !($this->{options}->{silent} // 0)); + my $opt = _defined_eq(shift, {}); + my $notimeout = _defined_eq($opt->{notimeout}, 0); + my $printwarnings = (_defined_eq($opt->{printwarnings}, 0) and !_defined_eq($this->{options}->{silent}, 0)); my $pipeerr = $this->{"err-$suffix"}; @@ -5950,7 +5950,7 @@ _logEvent($this, "Trying to read from gnuplot (suffix $suffix)") if $this->{options}{tee}; my $terminal =$this->{options}->{terminal}; - my $delay = (($this->{'wait'}//0) + 0) || 5; + my $delay = (_defined_eq($this->{'wait'}, 0) + 0) || 5; if($this->{"echobuffer-$suffix"}) { $fromerr = $this->{"echobuffer-$suffix"}; @@ -6172,7 +6172,7 @@ splice @$with, $i,1; # remove 'resample' from list $resample_flag = 1; if( ($with->[$i]) =~ m/(\d+)(\,(\d+))?/ ) { - @resample_dims = ($1, $3 // $1); + @resample_dims = ($1, _defined_eq($3, $1)); splice @$with, $i, 1; } $i--; @@ -6294,6 +6294,11 @@ } +# The // operator works only with 5.10 and later. This sub does the same, +# and works with perl-5.8 as well. +sub _defined_eq { + defined($_[0]) ? $_[0] : $_[1]; +} =head1 COMPATIBILITY
1.3 is marked "use 5.010".