Skip Menu |

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

Report information
The Basics
Id: 5151
Status: resolved
Priority: 0/
Queue: XML-Twig

People
Owner: MIROD [...] cpan.org
Requestors: ed [...] membled.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 3.12
Fixed in: 3.13



Subject: Test failure in t_additional
I installed expat-1.95.7 with --prefix=$HOME. (I did not run the expat test suite.) Then I built XML::Parser-2.34 with EXPATINCDIR=$HOME/include and EXPATLIBDIR=$HOME/lib, ran the XML::Parser test suite successfully, and installed it with PREFIX=$HOME. I did make a small change to Expat.pm to fix a bug in xml_encoding caused by a perl regexp bug - I have sent Michael R. mail separately about this. Having installed expat and XML::Parser I built XML::Twig-3.12 and ran the test suite. Some of the tests printed warnings about malformed UTF-8 characters but nonetheless passed, some of the tests were skipped, but test_additional failed tests 326 and 327. A transcript of the 'make test' command is attached. I would like this bug report to stand for both the test failures, and the worrying-looking UTF-8 warnings while running other tests. (Perhaps there should be a test to make sure such warnings don't occur...)
Download test_log
application/octet-stream 139.6k

Message body not shown because it is not plain text.

(Forgot to log in when first entering this bug.)
This turns out to be a bug in s/// in perl-5.8.0. This patch works around it: diff -ru XML-Twig-3.12/Twig.pm XML-Twig-3.12-new/Twig.pm --- XML-Twig-3.12/Twig.pm Thu Jan 29 16:50:14 2004 +++ XML-Twig-3.12-new/Twig.pm Sun Feb 1 11:16:28 2004 @@ -3243,15 +3243,31 @@ sub safe_encode { my $str= shift; - $str =~ s{([\xC0-\xDF].|[\xE0-\xEF]..|[\xF0-\xFF]...)} + if ($] == 5.008) + { # Bug in perl stops s///g working properly. + 0 while + $str =~ s{([\xC0-\xDF].|[\xE0-\xEF]..|[\xF0-\xFF]...)} + {XmlUtf8Decode($1)}es; + } + else + { $str =~ s{([\xC0-\xDF].|[\xE0-\xEF]..|[\xF0-\xFF]...)} {XmlUtf8Decode($1)}egs; + } return $str; } sub safe_encode_hex { my $str= shift; - $str =~ s{([\xC0-\xDF].|[\xE0-\xEF]..|[\xF0-\xFF]...)} + if ($] == 5.008) + { # Bug in perl stops s///g working properly. + 0 while + $str =~ s{([\xC0-\xDF].|[\xE0-\xEF]..|[\xF0-\xFF]...)} + {XmlUtf8Decode($1, 1)}es; + } + else + { $str =~ s{([\xC0-\xDF].|[\xE0-\xEF]..|[\xF0-\xFF]...)} {XmlUtf8Decode($1, 1)}egs; + } return $str; } diff -ru XML-Twig-3.12/Twig.pm.slow XML-Twig-3.12-new/Twig.pm.slow --- XML-Twig-3.12/Twig.pm.slow Thu Jan 29 15:28:52 2004 +++ XML-Twig-3.12-new/Twig.pm.slow Sun Feb 1 11:16:24 2004 @@ -3243,15 +3243,31 @@ sub safe_encode { my $str= shift; - $str =~ s{([\xC0-\xDF].|[\xE0-\xEF]..|[\xF0-\xFF]...)} + if ($] == 5.008) + { # Bug in perl stops s///g working properly. + 0 while + $str =~ s{([\xC0-\xDF].|[\xE0-\xEF]..|[\xF0-\xFF]...)} + {XmlUtf8Decode($1)}es; + } + else + { $str =~ s{([\xC0-\xDF].|[\xE0-\xEF]..|[\xF0-\xFF]...)} {XmlUtf8Decode($1)}egs; + } return $str; } sub safe_encode_hex { my $str= shift; - $str =~ s{([\xC0-\xDF].|[\xE0-\xEF]..|[\xF0-\xFF]...)} + if ($] == 5.008) + { # Bug in perl stops s///g working properly. + 0 while + $str =~ s{([\xC0-\xDF].|[\xE0-\xEF]..|[\xF0-\xFF]...)} + {XmlUtf8Decode($1, 1)}es; + } + else + { $str =~ s{([\xC0-\xDF].|[\xE0-\xEF]..|[\xF0-\xFF]...)} {XmlUtf8Decode($1, 1)}egs; + } return $str; } The patch is against both Twig.pm.slow and Twig.pm since both files are included in the source distribution. If you don't want to apply this patch, please add a check to Makefile.PL to make sure 5.8.0 is not being used (eg require at least 5.8.1).