Skip Menu |
 

This queue is for tickets about the XML-XPath CPAN distribution.

Report information
The Basics
Id: 112584
Status: resolved
Priority: 0/
Queue: XML-XPath

People
Owner: MANWAR [...] cpan.org
Requestors: me [...] eboxr.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.32
Fixed in: 1.33



Subject: Useless use of /d modifier in transliteration operator from XML::XPath::Function::translate
Download (untitled) / with headers
text/plain 742b
Warning noticed when running the tests with perl522 Show quoted text
> prove -Ilib -vw t/48translate.t
t/48translate.t .. ok 1 ok 2 ok 3 Useless use of /d modifier in transliteration operator at (eval 10) line 1. ok 4 1..4 ok All tests successful. Files=1, Tests=4, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.07 cusr 0.00 csys = 0.11 CPU) Result: PASS This is coming from here in the eval sub translate { my $self = shift; my ($node, @params) = @_; die "translate: Wrong number of params\n" if @params != 3; local $_ = $params[0]->string_value; my $find = $params[1]->string_value; my $repl = $params[2]->string_value; eval "tr/\Q$find\E/\Q$repl\E/d"; die $@ if $@; return XML::XPath::Literal->new($_); }
Download (untitled) / with headers
text/plain 1.4k
suggested patch diff --git a/modules/XML-XPath/XML-XPath/lib/XML/XPath/Function.pm b/modules/XML-XPath/XML-XPath/lib/XML/XPath/Function.pm index 4aaa0ee..4fca61b 100644 --- a/modules/XML-XPath/XML-XPath/lib/XML/XPath/Function.pm +++ b/modules/XML-XPath/XML-XPath/lib/XML/XPath/Function.pm @@ -348,7 +348,10 @@ sub translate { local $_ = $params[0]->string_value; my $find = $params[1]->string_value; my $repl = $params[2]->string_value; - eval "tr/\Q$find\E/\Q$repl\E/d"; + { + no warnings; + eval "tr/\Q$find\E/\Q$repl\E/d"; + } die $@ if $@; return XML::XPath::Literal->new($_); } On Mon Feb 29 16:31:41 2016, atoomic wrote: Show quoted text
> Warning noticed when running the tests with perl522 > >
> > prove -Ilib -vw t/48translate.t
> t/48translate.t .. > ok 1 > ok 2 > ok 3 > Useless use of /d modifier in transliteration operator at (eval 10) > line 1. > ok 4 > 1..4 > ok > All tests successful. > Files=1, Tests=4, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.07 cusr > 0.00 csys = 0.11 CPU) > Result: PASS > > > This is coming from here in the eval > > sub translate { > my $self = shift; > my ($node, @params) = @_; > die "translate: Wrong number of params\n" if @params != 3; > local $_ = $params[0]->string_value; > my $find = $params[1]->string_value; > my $repl = $params[2]->string_value; > eval "tr/\Q$find\E/\Q$repl\E/d"; > die $@ if $@; > return XML::XPath::Literal->new($_); > }
Hi, Thanks for reporting the issue. I will get it patched asap. Best Regards, Mohammad S Anwar
Download (untitled) / with headers
text/plain 504b
Hi, Patched the distribution as below: https://github.com/manwar/XML-XPath https://metacpan.org/release/MANWAR/XML-XPath-1.33 Just a note, the proposed patch broke some of the unit tests, so I had to tweak little bit. Release note for Perl 5.22 was very handy to get to the bottom of the issue as below: Show quoted text
>>>
Useless use of /d modifier in transliteration operator (W misc) You have used the /d modifier where the searchlist has the same length as the replacelist. <<< Best Regards, Mohammad S Anwar
Resolved.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.