The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 118
Expat/Expat.pm 48
Expat/Expat.xs 810
MANIFEST 6567
META.json 047
META.yml 2121
Makefile.PL 201201
Parser/LWPExternEnt.pl 11
Parser/Style/Objects.pm 22
Parser/Style/Subs.pm 22
Parser/Style/Tree.pm 11
Parser.pm 44
README 36
inc/Devel/CheckLib.pm 1854
t/astress.t 01
t/decl.t 8795
t/file.t 74
t/file_open_scalar.t 025
t/parament.t 7857
19 files changed (This is a version diff) 503624
@@ -1,6 +1,23 @@
 Revision history for Perl extension XML::Parser.
 
-2.41 2011-06-01 (by Todd Rinaldo
+2.44 2015-01-12 (by Todd Rinaldo)
+    - RT 99098 - Revert "Add more useful error message on parse to Expat". It breaks
+      XML::Twig. Calling code will need to do this if it's needed.
+    - RT 100959 - Add use FileHandle to t/astress.t - Make perl 5.10.0 happy.
+
+2.43 2014-12-11 (by Todd Rinaldo)
+    - POD patch to man from Debian via Nicholas Bamber
+    - POD patch from Debian via gregor herrmann.
+    - Add more useful error message on parse to Expat
+    - Fix LWP dependency to be LWP::Useragent
+    - Bump to 2.43 for overdue release to CPAN.
+
+2.42_01 2013-07-12 (by Todd Rinaldo)
+    - Added instructions to README for OSX
+    - XS changes: stop using SvPV(string, PL_na)
+    - Fix documentation typos
+
+2.41 2011-06-01 (by Todd Rinaldo)
     - Tests are cleaned. promoting to stable. No changes since 2.40_02
 
 2.40_02 2011-05-31 (by Todd Rinaldo)
@@ -10,7 +10,7 @@ use Carp;
 require DynaLoader;
 
 @ISA = qw(DynaLoader);
-$VERSION = "2.41";
+$VERSION = "2.44";
 
 $have_File_Spec = $INC{'File/Spec.pm'} || do 'File/Spec.pm';
 
@@ -455,6 +455,10 @@ sub parse {
         no strict 'refs';
         $ioref = *{$arg}{IO} if defined *{$arg};
       };
+      if (ref($ioref) eq 'FileHandle') {
+        #for perl 5.10.x and possibly earlier, see t/file_open_scalar.t
+        require FileHandle;
+      }
     }
   }
   
@@ -922,7 +926,7 @@ including any internal or external DTD declarations.
 
 =item * XMLDecl           (Parser, Version, Encoding, Standalone)
 
-This handler is called for XML declarations. Version is a string containg
+This handler is called for XML declarations. Version is a string containing
 the version. Encoding is either undefined or contains an encoding string.
 Standalone is either undefined, or true or false. Undefined indicates
 that no standalone parameter was given in the XML declaration. True or
@@ -954,7 +958,7 @@ a prefix.
 =item new_ns_prefixes
 
 When called from a start tag handler, returns namespace prefixes declared
-with this start tag. If called elsewere (or if there were no namespace
+with this start tag. If called elsewhere (or if there were no namespace
 prefixes declared), it returns an empty list. Setting of the default
 namespace is indicated with '#default' as a prefix.
 
@@ -974,7 +978,7 @@ currently bound, '#default' appears in the list.
 
 Returns the string from the document that was recognized in order to call
 the current handler. For instance, when called from a start handler, it
-will give us the the start-tag string. The string is encoded in UTF-8.
+will give us the start-tag string. The string is encoded in UTF-8.
 This method doesn't return a meaningful string inside declaration handlers.
 
 =item original_string
@@ -212,13 +212,15 @@ append_error(XML_Parser parser, char * err)
     if (! err)
       err = (char *) XML_ErrorString(XML_GetErrorCode(parser));
 
-    sv_catpvf(*errstr, "\n%s at line %d, column %d, byte %d%s",
+    sv_catpvf(*errstr, "\n%s at line %ld, column %ld, byte %ld%s",
 	      err,
-	      XML_GetCurrentLineNumber(parser),
-	      XML_GetCurrentColumnNumber(parser),
-	      XML_GetCurrentByteIndex(parser),
+	      (long)XML_GetCurrentLineNumber(parser),
+	      (long)XML_GetCurrentColumnNumber(parser),
+	      (long)XML_GetCurrentByteIndex(parser),
 	      dopos ? ":\n" : "");
-
+	      // See https://rt.cpan.org/Ticket/Display.html?id=92030
+	      // It explains why type conversion is used.
+	      
     if (dopos)
       {
 	int count;
@@ -1052,7 +1054,7 @@ externalEntityRef(XML_Parser parser,
 	}
 
 	if (SvTRUE(ERRSV))
-	  append_error(parser, SvPV(ERRSV, PL_na));
+	  append_error(parser, SvPV_nolen(ERRSV));
       }
     }
   }
@@ -1278,7 +1280,7 @@ XML_ParserCreate(self_sv, enc_sv, namespaces)
 	{
 	  CallbackVector *cbv;
 	  enum XML_ParamEntityParsing pep = XML_PARAM_ENTITY_PARSING_NEVER;
-	  char *enc = (char *) (SvTRUE(enc_sv) ? SvPV(enc_sv,PL_na) : 0);
+	  char *enc = (char *) (SvTRUE(enc_sv) ? SvPV_nolen(enc_sv) : 0);
 	  SV ** spp;
 
 	  Newz(320, cbv, 1, CallbackVector);
@@ -1797,7 +1799,7 @@ XML_SetBase(parser, base)
 	    b = (char *) 0;
 	  }
 	  else {
-	    b = SvPV(base, PL_na);
+	    b = SvPV_nolen(base);
 	  }
 
 	  XML_SetBase(parser, b);
@@ -1,65 +1,67 @@
-inc/Devel/CheckLib.pm
-Changes                         Change log
-Expat/Expat.pm                  XML::Parser::Expat module
-Expat/Expat.xs                  Extension library
-Expat/Makefile.PL               perl MakeMaker script for XML::Parser::Expat
-Expat/encoding.h                Header file; describes *.enc structure
-Expat/typemap                   XS typemap
-MANIFEST                        This file
-Makefile.PL                     perl MakeMaker script for XML::Parser
-Parser.pm                       XML::Parser module
-Parser/LWPExternEnt.pl          LWP based external entity handler
-Parser/Encodings/Japanese_Encodings.msg        Message about Japanese encodings.
-Parser/Encodings/README         Info about encoding maps
-Parser/Encodings/big5.enc       Big5 binary encoding map
-Parser/Encodings/euc-kr.enc     EUC-KR binary encoding map
-Parser/Encodings/iso-8859-2.enc ISO-8859-2 binary encoding map
-Parser/Encodings/iso-8859-3.enc ISO-8859-3 binary encoding map
-Parser/Encodings/iso-8859-4.enc ISO-8859-4 binary encoding map
-Parser/Encodings/iso-8859-5.enc ISO-8859-5 binary encoding map
-Parser/Encodings/iso-8859-7.enc ISO-8859-7 binary encoding map
-Parser/Encodings/iso-8859-8.enc ISO-8859-8 binary encoding map
-Parser/Encodings/iso-8859-9.enc ISO-8859-9 binary encoding map
-Parser/Encodings/windows-1250.enc cp1250-WinLatin2 binary encoding map
-Parser/Encodings/windows-1251.enc cp1251-Russian binary encoding map
-Parser/Encodings/windows-1252.enc cp1252-WinLatin1 binary encoding map
-Parser/Encodings/windows-1255.enc hebrew
-Parser/Encodings/x-euc-jp-jisx0221.enc   X-euc-jp-jisx0221 encoding map
-Parser/Encodings/x-euc-jp-unicode.enc    X-euc-jp-unicde encoding map
-Parser/Encodings/x-sjis-cp932.enc        x-sjis-cp932 encoding map
-Parser/Encodings/x-sjis-jdk117.enc       x-sjis-jdk117 encoding map
-Parser/Encodings/x-sjis-jisx0221.enc     x-sjis-jisx0221 encoding map
-Parser/Encodings/x-sjis-unicode.enc      x-sjis-unicode encoding map
-Parser/Encodings/ibm866.enc
-Parser/Encodings/koi8-r.enc
-Parser/Style/Debug.pm           Debug style parser
-Parser/Style/Objects.pm         Objects style parser
-Parser/Style/Stream.pm          Stream style parser
-Parser/Style/Subs.pm            Subs style parser
-Parser/Style/Tree.pm            Tree style parser
-README                          Short explanation
-samples/canonical               A utility to generate canonical XML
-samples/canontst.xml            An xml document to demonstrate canonical
-samples/ctest.dtd               An external DTD used by canontst.xml
-samples/REC-xml-19980210.xml    The XML spec in xml form
-samples/xmlcomments             A utility to extract comments
-samples/xmlfilter               A utility to filter elements
-samples/xmlstats                A utility to report on element statistics
-t/astress.t                     Test script
-t/cdata.t                       Test script
-t/decl.t                        Test script
-t/defaulted.t                   Test script
-t/encoding.t                    Test script
-t/external_ent.t                Test script
-t/file.t                        Test script
-t/finish.t                      Test script
-t/ext.ent                       External entity for parament.t test
-t/ext2.ent                      External entity for parament.t test
-t/foo.dtd                       External DTD for parament.t test
-t/namespaces.t                  Test script
-t/parament.t                    Test script
-t/partial.t                     Test script
-t/skip.t                        Test script
-t/stream.t                      Test script
-t/styles.t                      Test script
-META.yml                                 Module meta-data (added by MakeMaker)
+inc/Devel/CheckLib.pm
+Changes                         Change log
+Expat/Expat.pm                  XML::Parser::Expat module
+Expat/Expat.xs                  Extension library
+Expat/Makefile.PL               perl MakeMaker script for XML::Parser::Expat
+Expat/encoding.h                Header file; describes *.enc structure
+Expat/typemap                   XS typemap
+MANIFEST                        This file
+Makefile.PL                     perl MakeMaker script for XML::Parser
+Parser.pm                       XML::Parser module
+Parser/LWPExternEnt.pl          LWP based external entity handler
+Parser/Encodings/Japanese_Encodings.msg        Message about Japanese encodings.
+Parser/Encodings/README         Info about encoding maps
+Parser/Encodings/big5.enc       Big5 binary encoding map
+Parser/Encodings/euc-kr.enc     EUC-KR binary encoding map
+Parser/Encodings/iso-8859-2.enc ISO-8859-2 binary encoding map
+Parser/Encodings/iso-8859-3.enc ISO-8859-3 binary encoding map
+Parser/Encodings/iso-8859-4.enc ISO-8859-4 binary encoding map
+Parser/Encodings/iso-8859-5.enc ISO-8859-5 binary encoding map
+Parser/Encodings/iso-8859-7.enc ISO-8859-7 binary encoding map
+Parser/Encodings/iso-8859-8.enc ISO-8859-8 binary encoding map
+Parser/Encodings/iso-8859-9.enc ISO-8859-9 binary encoding map
+Parser/Encodings/windows-1250.enc cp1250-WinLatin2 binary encoding map
+Parser/Encodings/windows-1251.enc cp1251-Russian binary encoding map
+Parser/Encodings/windows-1252.enc cp1252-WinLatin1 binary encoding map
+Parser/Encodings/windows-1255.enc hebrew
+Parser/Encodings/x-euc-jp-jisx0221.enc   X-euc-jp-jisx0221 encoding map
+Parser/Encodings/x-euc-jp-unicode.enc    X-euc-jp-unicde encoding map
+Parser/Encodings/x-sjis-cp932.enc        x-sjis-cp932 encoding map
+Parser/Encodings/x-sjis-jdk117.enc       x-sjis-jdk117 encoding map
+Parser/Encodings/x-sjis-jisx0221.enc     x-sjis-jisx0221 encoding map
+Parser/Encodings/x-sjis-unicode.enc      x-sjis-unicode encoding map
+Parser/Encodings/ibm866.enc
+Parser/Encodings/koi8-r.enc
+Parser/Style/Debug.pm           Debug style parser
+Parser/Style/Objects.pm         Objects style parser
+Parser/Style/Stream.pm          Stream style parser
+Parser/Style/Subs.pm            Subs style parser
+Parser/Style/Tree.pm            Tree style parser
+README                          Short explanation
+samples/canonical               A utility to generate canonical XML
+samples/canontst.xml            An xml document to demonstrate canonical
+samples/ctest.dtd               An external DTD used by canontst.xml
+samples/REC-xml-19980210.xml    The XML spec in xml form
+samples/xmlcomments             A utility to extract comments
+samples/xmlfilter               A utility to filter elements
+samples/xmlstats                A utility to report on element statistics
+t/astress.t                     Test script
+t/cdata.t                       Test script
+t/decl.t                        Test script
+t/defaulted.t                   Test script
+t/encoding.t                    Test script
+t/external_ent.t                Test script
+t/file.t                        Test script
+t/file_open_scalar.t            Test script
+t/finish.t                      Test script
+t/ext.ent                       External entity for parament.t test
+t/ext2.ent                      External entity for parament.t test
+t/foo.dtd                       External DTD for parament.t test
+t/namespaces.t                  Test script
+t/parament.t                    Test script
+t/partial.t                     Test script
+t/skip.t                        Test script
+t/stream.t                      Test script
+t/styles.t                      Test script
+META.yml                                 Module YAML meta-data (added by MakeMaker)
+META.json                                Module JSON meta-data (added by MakeMaker)
@@ -0,0 +1,47 @@
+{
+   "abstract" : "A perl module for parsing XML documents",
+   "author" : [
+      "Clark Cooper (coopercc@netheaven.com)"
+   ],
+   "dynamic_config" : 1,
+   "generated_by" : "ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240",
+   "license" : [
+      "perl_5"
+   ],
+   "meta-spec" : {
+      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
+      "version" : "2"
+   },
+   "name" : "XML-Parser",
+   "no_index" : {
+      "directory" : [
+         "t",
+         "inc"
+      ]
+   },
+   "prereqs" : {
+      "build" : {
+         "requires" : {
+            "Test::More" : "0"
+         }
+      },
+      "configure" : {
+         "requires" : {
+            "ExtUtils::MakeMaker" : "0"
+         }
+      },
+      "runtime" : {
+         "requires" : {
+            "LWP::UserAgent" : "0",
+            "perl" : "5.00405"
+         }
+      }
+   },
+   "release_status" : "stable",
+   "resources" : {
+      "repository" : {
+         "url" : "http://github.com/toddr/XML-Parser"
+      }
+   },
+   "version" : "2.44"
+}
@@ -1,25 +1,25 @@
---- #YAML:1.0
-name:               XML-Parser
-version:            2.41
-abstract:           A perl module for parsing XML documents
+---
+abstract: 'A perl module for parsing XML documents'
 author:
-    - Clark Cooper (coopercc@netheaven.com)
-license:            perl
-distribution_type:  module
-configure_requires:
-    ExtUtils::MakeMaker:  0
+  - 'Clark Cooper (coopercc@netheaven.com)'
 build_requires:
-    ExtUtils::MakeMaker:  0
+  Test::More: '0'
+configure_requires:
+  ExtUtils::MakeMaker: '0'
+dynamic_config: 1
+generated_by: 'ExtUtils::MakeMaker version 7.04, CPAN::Meta::Converter version 2.143240'
+license: perl
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: '1.4'
+name: XML-Parser
+no_index:
+  directory:
+    - t
+    - inc
 requires:
-    LWP:   0
-    perl:  5.00405
+  LWP::UserAgent: '0'
+  perl: '5.00405'
 resources:
-    repository:  http://github.com/chorny/XML-Parser
-no_index:
-    directory:
-        - t
-        - inc
-generated_by:       ExtUtils::MakeMaker version 6.56
-meta-spec:
-    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
-    version:  1.4
+  repository: http://github.com/toddr/XML-Parser
+version: '2.44'
@@ -1,201 +1,201 @@
-
-use 5.004005; #Devel::CheckLib
-use ExtUtils::MakeMaker;
-use lib qw(inc);
-use Devel::CheckLib;
-
-use Config;
-
-$expat_libpath = '';
-$expat_incpath = '';
-
-my @replacement_args;
-
-foreach (@ARGV) {
-  if (/^EXPAT(LIB|INC)PATH=(.+)/) {
-    if ($1 eq 'LIB') {
-      $expat_libpath = $2;
-    }
-    else {
-      $expat_incpath = $2;
-    }
-    #push(@replacement_args, "$1=$2");
-  }
-  else {
-    push(@replacement_args, $_);
-  }
-}
-
-@ARGV = @replacement_args;
-
-unless (
-  check_lib(     # fill in what you prompted the user for here
-    lib => [qw(expat)],
-    header => ['expat.h'],
-    incpath => $expat_incpath,
-    ($expat_libpath?
-    (libpath => $expat_libpath):()),
-  )) {
-    warn <<'Expat_Not_Installed;';
-
-Expat must be installed prior to building XML::Parser and I can't find
-it in the standard library directories. Install 'expat-devel' package with your
-OS package manager. See 'README'.
-
-Or you can download expat from:
-
-http://sourceforge.net/projects/expat/
-
-If expat is installed, but in a non-standard directory, then use the
-following options to Makefile.PL:
-
-    EXPATLIBPATH=...  To set the directory in which to find libexpat
-
-    EXPATINCPATH=...  To set the directory in which to find expat.h
-
-For example:
-
-    perl Makefile.PL EXPATLIBPATH=/home/me/lib EXPATINCPATH=/home/me/include
-
-Note that if you build against a shareable library in a non-standard location
-you may (on some platforms) also have to set your LD_LIBRARY_PATH environment
-variable at run time for perl to find the library.
-
-Expat_Not_Installed;
-    #exit;
-}
-
-if (not $expat_libpath and $] >= 5.006001 and $^O ne 'MSWin32') {
-  require ExtUtils::Liblist;		# Buggy before this
-  ($expat_libpath) = ExtUtils::Liblist->ext('-lexpat');
-}
-
-=for cmt
-
-unless ($expat_libpath) {
-  # Test for existence of libexpat
-  my $found = 0;
-  foreach (split(/\s+/, $Config{libpth})) {
-    if (-f "$_/libexpat." . $Config{so}) {
-      $expat_libpath=$_;
-      $found = 1;
-      last;
-    }
-  }
-
-  if (!$found and $^O eq 'MSWin32') {
-    if (-f 'C:/lib/Expat-2.0.0/Libs/libexpat.dll') {
-      $expat_libpath = 'C:/lib/Expat-2.0.0/Libs';
-      $expat_incpath = 'C:/lib/Expat-2.0.0/Source/lib';
-      $found = 1;
-    }
-
-  }
-  if ($found) {
-    print "libexpat found in $expat_libpath\n";
-  }
-
-  unless ($found) {
-    warn <<'Expat_Not_Installed;';
-
-Expat must be installed prior to building XML::Parser and I can't find
-it in the standard library directories. Install 'expat-devel' package with your
-OS package manager.
-
-Or you can download expat from:
-
-http://sourceforge.net/projects/expat/
-
-If expat is installed, but in a non-standard directory, then use the
-following options to Makefile.PL:
-
-    EXPATLIBPATH=...  To set the directory in which to find libexpat
-
-    EXPATINCPATH=...  To set the directory in which to find expat.h
-
-For example:
-
-    perl Makefile.PL EXPATLIBPATH=/home/me/lib EXPATINCPATH=/home/me/include
-
-Note that if you build against a shareable library in a non-standard location
-you may (on some platforms) also have to set your LD_LIBRARY_PATH environment
-variable at run time for perl to find the library.
-
-Expat_Not_Installed;
-    exit 0;
-  }
-}
-=cut
-
-# Don't try to descend into Expat directory for testing
-
-sub MY::test
-{
-  my $self = shift;
-
-  my $hold = delete $self->{DIR};
-  my $ret = $self->MM::test(@_);
-  $self->{DIR} = $hold if defined($hold);
-  $ret;
-}
-
-my @extras = ();
-
-push(@extras,
-     CAPI => 'TRUE')
-    if ($PERL_VERSION >= 5.005 and $OSNAME eq 'MSWin32'
-	and $Config{archname} =~ /-object\b/i);
-
-WriteMakefile1(
-  ABSTRACT_FROM => 'Parser.pm',
-  AUTHOR        => 'Clark Cooper (coopercc@netheaven.com)',
-  LICENSE => 'perl',
-  MIN_PERL_VERSION => '5.00405',
-  META_MERGE => {
-    resources => {
-      repository => 'http://github.com/chorny/XML-Parser',
-    },
-  },
-  #BUILD_REQUIRES => {
-  #},
-
-  NAME	=> 'XML::Parser',
-  DIR	=> [qw(Expat)],
-  dist      => {COMPRESS => 'gzip', SUFFIX => '.gz'},
-  VERSION_FROM => 'Parser.pm',
-  PREREQ_PM    => {
-    LWP => 0, #for tests
-  },
-    $^O =~/win/i ? (
-        dist => {
-            TAR      => 'ptar',
-            TARFLAGS => '-c -C -f',
-        },
-    ) : (),
-  @extras
-);
-
-
-sub WriteMakefile1 {  #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
-  my %params=@_;
-  my $eumm_version=$ExtUtils::MakeMaker::VERSION;
-  $eumm_version=eval $eumm_version;
-  die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
-  die "License not specified" if not exists $params{LICENSE};
-  if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
-    #EUMM 6.5502 has problems with BUILD_REQUIRES
-    $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
-    delete $params{BUILD_REQUIRES};
-  }
-  delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
-  delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
-  delete $params{META_MERGE} if $eumm_version < 6.46;
-  delete $params{META_ADD} if $eumm_version < 6.46;
-  delete $params{LICENSE} if $eumm_version < 6.31;
-  delete $params{AUTHOR} if $] < 5.005;
-  delete $params{ABSTRACT_FROM} if $] < 5.005;
-  delete $params{BINARY_LOCATION} if $] < 5.005;
-
-  WriteMakefile(%params);
-}
-
+use 5.004005; #Devel::CheckLib
+use ExtUtils::MakeMaker;
+use lib qw(inc);
+use Devel::CheckLib;
+
+use Config;
+
+$expat_libpath = '';
+$expat_incpath = '';
+
+my @replacement_args;
+
+foreach (@ARGV) {
+  if (/^EXPAT(LIB|INC)PATH=(.+)/) {
+    if ($1 eq 'LIB') {
+      $expat_libpath = $2;
+    }
+    else {
+      $expat_incpath = $2;
+    }
+    #push(@replacement_args, "$1=$2");
+  }
+  else {
+    push(@replacement_args, $_);
+  }
+}
+
+@ARGV = @replacement_args;
+
+unless (
+  check_lib(     # fill in what you prompted the user for here
+    lib => [qw(expat)],
+    header => ['expat.h'],
+    incpath => $expat_incpath,
+    ($expat_libpath?
+    (libpath => $expat_libpath):()),
+  )) {
+    warn <<'Expat_Not_Installed;';
+
+Expat must be installed prior to building XML::Parser and I can't find
+it in the standard library directories. Install 'expat-devel' (or
+'libexpat1-dev') package with your OS package manager. See 'README'.
+
+Or you can download expat from:
+
+http://sourceforge.net/projects/expat/
+
+If expat is installed, but in a non-standard directory, then use the
+following options to Makefile.PL:
+
+    EXPATLIBPATH=...  To set the directory in which to find libexpat
+
+    EXPATINCPATH=...  To set the directory in which to find expat.h
+
+For example:
+
+    perl Makefile.PL EXPATLIBPATH=/home/me/lib EXPATINCPATH=/home/me/include
+
+Note that if you build against a shareable library in a non-standard location
+you may (on some platforms) also have to set your LD_LIBRARY_PATH environment
+variable at run time for perl to find the library.
+
+Expat_Not_Installed;
+    #exit;
+}
+
+if (not $expat_libpath and $] >= 5.006001 and $^O ne 'MSWin32') {
+  require ExtUtils::Liblist;		# Buggy before this
+  ($expat_libpath) = ExtUtils::Liblist->ext('-lexpat');
+}
+
+=for cmt
+
+unless ($expat_libpath) {
+  # Test for existence of libexpat
+  my $found = 0;
+  foreach (split(/\s+/, $Config{libpth})) {
+    if (-f "$_/libexpat." . $Config{so}) {
+      $expat_libpath=$_;
+      $found = 1;
+      last;
+    }
+  }
+
+  if (!$found and $^O eq 'MSWin32') {
+    if (-f 'C:/lib/Expat-2.0.0/Libs/libexpat.dll') {
+      $expat_libpath = 'C:/lib/Expat-2.0.0/Libs';
+      $expat_incpath = 'C:/lib/Expat-2.0.0/Source/lib';
+      $found = 1;
+    }
+
+  }
+  if ($found) {
+    print "libexpat found in $expat_libpath\n";
+  }
+
+  unless ($found) {
+    warn <<'Expat_Not_Installed;';
+
+Expat must be installed prior to building XML::Parser and I can't find
+it in the standard library directories. Install 'expat-devel' (or
+'libexpat1-dev') package with your OS package manager.
+
+Or you can download expat from:
+
+http://sourceforge.net/projects/expat/
+
+If expat is installed, but in a non-standard directory, then use the
+following options to Makefile.PL:
+
+    EXPATLIBPATH=...  To set the directory in which to find libexpat
+
+    EXPATINCPATH=...  To set the directory in which to find expat.h
+
+For example:
+
+    perl Makefile.PL EXPATLIBPATH=/home/me/lib EXPATINCPATH=/home/me/include
+
+Note that if you build against a shareable library in a non-standard location
+you may (on some platforms) also have to set your LD_LIBRARY_PATH environment
+variable at run time for perl to find the library.
+
+Expat_Not_Installed;
+    exit 0;
+  }
+}
+=cut
+
+# Don't try to descend into Expat directory for testing
+
+sub MY::test
+{
+  my $self = shift;
+
+  my $hold = delete $self->{DIR};
+  my $ret = $self->MM::test(@_);
+  $self->{DIR} = $hold if defined($hold);
+  $ret;
+}
+
+my @extras = ();
+
+push(@extras,
+     CAPI => 'TRUE')
+    if ($PERL_VERSION >= 5.005 and $OSNAME eq 'MSWin32'
+	and $Config{archname} =~ /-object\b/i);
+
+WriteMakefile1(
+  ABSTRACT_FROM => 'Parser.pm',
+  AUTHOR        => 'Clark Cooper (coopercc@netheaven.com)',
+  LICENSE => 'perl',
+  MIN_PERL_VERSION => '5.00405',
+  META_MERGE => {
+    resources => {
+      repository => 'http://github.com/toddr/XML-Parser',
+    },
+  },
+  BUILD_REQUIRES => {
+    'Test::More' => 0,
+  },
+
+  NAME	=> 'XML::Parser',
+  DIR	=> [qw(Expat)],
+  dist      => {COMPRESS => 'gzip', SUFFIX => '.gz'},
+  VERSION_FROM => 'Parser.pm',
+  PREREQ_PM    => {
+    'LWP::UserAgent' => 0, #for tests
+  },
+    $^O =~/win/i ? (
+        dist => {
+            TAR      => 'ptar',
+            TARFLAGS => '-c -C -f',
+        },
+    ) : (),
+  @extras
+);
+
+
+sub WriteMakefile1 {  #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
+  my %params=@_;
+  my $eumm_version=$ExtUtils::MakeMaker::VERSION;
+  $eumm_version=eval $eumm_version;
+  die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
+  die "License not specified" if not exists $params{LICENSE};
+  if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
+    #EUMM 6.5502 has problems with BUILD_REQUIRES
+    $params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
+    delete $params{BUILD_REQUIRES};
+  }
+  delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
+  delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
+  delete $params{META_MERGE} if $eumm_version < 6.46;
+  delete $params{META_ADD} if $eumm_version < 6.46;
+  delete $params{LICENSE} if $eumm_version < 6.31;
+  delete $params{AUTHOR} if $] < 5.005;
+  delete $params{ABSTRACT_FROM} if $] < 5.005;
+  delete $params{BINARY_LOCATION} if $] < 5.005;
+
+  WriteMakefile(%params);
+}
+
@@ -10,7 +10,7 @@ package XML::Parser;
 
 use URI;
 use URI::file;
-use LWP;
+use LWP::UserAgent;
 
 ##
 ## Note that this external entity handler reads the entire entity into
@@ -52,7 +52,7 @@ __END__
 
 =head1 NAME
 
-XML::Parser::Style::Objects
+XML::Parser::Style::Objects - Objects styler parser
 
 =head1 SYNOPSIS
 
@@ -75,4 +75,4 @@ is the value of the Kids property for that object.
 
 L<XML::Parser::Style::Tree>
 
-=cut
\ No newline at end of file
+=cut
@@ -23,7 +23,7 @@ __END__
 
 =head1 NAME
 
-XML::Parser::Style::Subs
+XML::Parser::Style::Subs - glue for handling element callbacks
 
 =head1 SYNOPSIS
 
@@ -55,4 +55,4 @@ with.
 
 Nothing special is returned by parse.
 
-=cut
\ No newline at end of file
+=cut
@@ -49,7 +49,7 @@ __END__
 
 =head1 NAME
 
-XML::Parser::Style::Tree
+XML::Parser::Style::Tree - Tree style parser
 
 =head1 SYNOPSIS
 
@@ -16,7 +16,7 @@ use Carp;
 
 BEGIN {
   require XML::Parser::Expat;
-  $VERSION = '2.41';
+  $VERSION = '2.44';
   die "Parser.pm and Expat.pm versions don't match"
     unless $VERSION eq $XML::Parser::Expat::VERSION;
 }
@@ -63,7 +63,7 @@ sub new {
     
     my $htype;
     foreach $htype (keys %{$args{_HNDL_TYPES}}) {
-      # Handlers explicity given override
+      # Handlers explicitly given override
       # handlers from the Style package
       unless (defined($handlers->{$htype})) {
         
@@ -360,7 +360,7 @@ XML::Parser - A perl module for parsing XML documents
   $p3->parsefile('junk.xml', ErrorContext => 3);
 
 =begin man
-.ds PI PI
+.ds PI
 
 =end man
 
@@ -701,7 +701,7 @@ including any internal or external DTD declarations.
 
 =head2 XMLDecl                (Expat, Version, Encoding, Standalone)
 
-This handler is called for xml declarations. Version is a string containg
+This handler is called for xml declarations. Version is a string containing
 the version. Encoding is either undefined or contains an encoding string.
 Standalone will be either true, false, or undefined if the standalone attribute
 is yes, no, or not made respectively.
@@ -10,14 +10,17 @@ It requires at least version 5.004 of perl and it requires that you have
 release 1.95.0 or greater of expat installed. You can download expat
 from http://sourceforge.net/projects/expat/
 
-Best way is to install 'expat-devel' package with your OS package manager.
-Debian: expat-dev
-Xubuntu 6.06: libexpat1-dev
+Best way is to install expat development package with your OS package manager.
+Debian/Ubuntu/similar: libexpat1-dev (old versions: expat-dev)
 
 After that run `cpan XML::Parser`.
 
 You can install this module from OS package too, but CPAN has most fresh version.
 CentOS/RHEL/Fedora: perl-XML-Parser
+Debian/Ubuntu/similar: should be already installed
+
+XML::Parser installation requires gcc, so on MacOS X you need to download and run
+Xcode from Mac app store (~1.5 GB)
 
 
 The documentation for this extension can be found in pod format at the end
@@ -5,7 +5,7 @@ package Devel::CheckLib;
 use 5.00405; #postfix foreach
 use strict;
 use vars qw($VERSION @ISA @EXPORT);
-$VERSION = '0.93';
+$VERSION = '0.99';
 use Config qw(%Config);
 use Text::ParseWords 'quotewords';
 
@@ -114,6 +114,11 @@ libraries (each preceded by '-l') and directories (preceded by '-L').
 
 This can also be supplied on the command-line.
 
+=item debug
+
+If true - emit information during processing that can be used for
+debugging.
+
 =back
 
 And libraries are no use without header files, so ...
@@ -202,7 +207,7 @@ sub assert_lib {
     # using special form of split to trim whitespace
     if(defined($args{LIBS})) {
         foreach my $arg (split(' ', $args{LIBS})) {
-            die("LIBS argument badly-formed: $arg\n") unless($arg =~ /^-l/i);
+            die("LIBS argument badly-formed: $arg\n") unless($arg =~ /^-[lLR]/);
             push @{$arg =~ /^-l/ ? \@libs : \@libpaths}, substr($arg, 2);
         }
     }
@@ -213,7 +218,7 @@ sub assert_lib {
         }
     }
 
-    my @cc = _findcc();
+    my ($cc, $ld) = _findcc();
     my @missing;
     my @wrongresult;
     my @use_headers;
@@ -224,6 +229,8 @@ sub assert_lib {
         my($ch, $cfile) = File::Temp::tempfile(
             'assertlibXXXXXXXX', SUFFIX => '.c'
         );
+        my $ofile = $cfile;
+        $ofile =~ s/\.c$/$Config{_o}/;
         print $ch qq{#include <$_>\n} for @use_headers;
         print $ch qq{int main(void) { return 0; }\n};
         close($ch);
@@ -233,21 +240,25 @@ sub assert_lib {
         if ( $Config{cc} eq 'cl' ) {                 # Microsoft compiler
             require Win32;
             @sys_cmd = (
-                @cc,
+                @$cc,
                 $cfile,
                 "/Fe$exefile",
-                (map { '/I'.Win32::GetShortPathName($_) } @incpaths)
+                (map { '/I'.Win32::GetShortPathName($_) } @incpaths),
+		"/link",
+		@$ld
             );
         } elsif($Config{cc} =~ /bcc32(\.exe)?/) {    # Borland
             @sys_cmd = (
-                @cc,
+                @$cc,
+                @$ld,
                 (map { "-I$_" } @incpaths),
                 "-o$exefile",
                 $cfile
             );
         } else { # Unix-ish: gcc, Sun, AIX (gcc, cc), ...
             @sys_cmd = (
-                @cc,
+                @$cc,
+                @$ld,
                 $cfile,
                 (map { "-I$_" } @incpaths),
                 "-o", "$exefile"
@@ -257,6 +268,7 @@ sub assert_lib {
         my $rv = $args{debug} ? system(@sys_cmd) : _quiet_system(@sys_cmd);
         push @missing, $header if $rv != 0 || ! -x $exefile;
         _cleanup_exe($exefile);
+        unlink $ofile if -e $ofile;
         unlink $cfile;
     } 
 
@@ -264,6 +276,8 @@ sub assert_lib {
     my($ch, $cfile) = File::Temp::tempfile(
         'assertlibXXXXXXXX', SUFFIX => '.c'
     );
+    my $ofile = $cfile;
+    $ofile =~ s/\.c$/$Config{_o}/;
     print $ch qq{#include <$_>\n} foreach (@headers);
     print $ch "int main(void) { ".($args{function} || 'return 0;')." }\n";
     close($ch);
@@ -277,32 +291,35 @@ sub assert_lib {
             } @libpaths; 
             # this is horribly sensitive to the order of arguments
             @sys_cmd = (
-                @cc,
+                @$cc,
                 $cfile,
                 "${lib}.lib",
                 "/Fe$exefile", 
                 (map { '/I'.Win32::GetShortPathName($_) } @incpaths),
                 "/link",
+                @$ld,
                 (map {'/libpath:'.Win32::GetShortPathName($_)} @libpaths),
             );
         } elsif($Config{cc} eq 'CC/DECC') {          # VMS
         } elsif($Config{cc} =~ /bcc32(\.exe)?/) {    # Borland
             @sys_cmd = (
-                @cc,
+                @$cc,
+                @$ld,
                 "-o$exefile",
-                "-l$lib",
                 (map { "-I$_" } @incpaths),
                 (map { "-L$_" } @libpaths),
+                "-l$lib",
                 $cfile);
         } else {                                     # Unix-ish
                                                      # gcc, Sun, AIX (gcc, cc)
             @sys_cmd = (
-                @cc,
+                @$cc,
+                @$ld,
                 $cfile,
                 "-o", "$exefile",
-                "-l$lib",
                 (map { "-I$_" } @incpaths),
-                (map { "-L$_" } @libpaths)
+                (map { "-L$_" } @libpaths),
+                "-l$lib",
             );
         }
         warn "# @sys_cmd\n" if $args{debug};
@@ -311,12 +328,13 @@ sub assert_lib {
         my $absexefile = File::Spec->rel2abs($exefile);
         $absexefile = '"'.$absexefile.'"' if $absexefile =~ m/\s/;
         push @wrongresult, $lib if $rv == 0 && -x $exefile && system($absexefile) != 0;
+        unlink $ofile if -e $ofile;
         _cleanup_exe($exefile);
     } 
     unlink $cfile;
 
     my $miss_string = join( q{, }, map { qq{'$_'} } @missing );
-    die("Can't link/include $miss_string\n") if @missing;
+    die("Can't link/include C library $miss_string, aborting.\n") if @missing;
     my $wrong_string = join( q{, }, map { qq{'$_'} } @wrongresult);
     die("wrong result: $wrong_string\n") if @wrongresult;
 }
@@ -328,19 +346,37 @@ sub _cleanup_exe {
     unlink $exefile if -f $exefile;
     unlink $ofile if -f $ofile;
     unlink "$exefile\.manifest" if -f "$exefile\.manifest";
+    if ( $Config{cc} eq 'cl' ) {
+        # MSVC also creates foo.ilk and foo.pdb
+        my $ilkfile = $exefile;
+        $ilkfile =~ s/$Config{_exe}$/.ilk/;
+        my $pdbfile = $exefile;
+        $pdbfile =~ s/$Config{_exe}$/.pdb/;
+        unlink $ilkfile if -f $ilkfile;
+        unlink $pdbfile if -f $pdbfile;
+    }
     return
 }
     
+# return ($cc, $ld)
+# where $cc is an array ref of compiler name, compiler flags
+# where $ld is an array ref of linker flags
 sub _findcc {
     # Need to use $keep=1 to work with MSWin32 backslashes and quotes
-    my @Config_ccflags_ldflags =  @Config{qw(ccflags ldflags)};  # use copy so ASPerl will compile
-    my @flags = grep { length } map { quotewords('\s+', 1, $_ || ()) } @Config_ccflags_ldflags;
+    my $Config_ccflags =  $Config{ccflags};  # use copy so ASPerl will compile
+    my @Config_ldflags = ();
+    for my $config_val ( @Config{qw(ldflags perllibs)} ){
+        push @Config_ldflags, $config_val if ( $config_val =~ /\S/ );
+    }
+    my @ccflags = grep { length } quotewords('\s+', 1, $Config_ccflags||'');
+    my @ldflags = grep { length } quotewords('\s+', 1, @Config_ldflags);
     my @paths = split(/$Config{path_sep}/, $ENV{PATH});
     my @cc = split(/\s+/, $Config{cc});
-    return (@cc, @flags) if -x $cc[0];
+    return ( [ @cc, @ccflags ], \@ldflags ) if -x $cc[0];
     foreach my $path (@paths) {
         my $compiler = File::Spec->catfile($path, $cc[0]) . $Config{_exe};
-        return ($compiler, @cc[1 .. $#cc], @flags) if -x $compiler;
+        return ([ $compiler, @cc[1 .. $#cc], @ccflags ], \@ldflags)
+            if -x $compiler;
     }
     die("Couldn't find your C compiler\n");
 }
@@ -9,6 +9,7 @@
 BEGIN {print "1..27\n";}
 END {print "not ok 1\n" unless $loaded;}
 use XML::Parser;
+use FileHandle; # Make 5.10.0 happy.
 $loaded = 1;
 print "ok 1\n";
 
@@ -1,10 +1,14 @@
-BEGIN {print "1..30\n";}
-END {print "not ok 1\n" unless $loaded;}
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 40;
 use XML::Parser;
-$loaded = 1;
-print "ok 1\n";
 
-my $bigval =<<'End_of_bigval;';
+ok("loaded");
+
+my $bigval = <<'End_of_bigval;';
 This is a large string value to test whether the declaration parser still
 works when the entity or attribute default value may be broken into multiple
 calls to the default handler.
@@ -25,7 +29,7 @@ End_of_bigval;
 
 $bigval =~ s/\n/ /g;
 
-my $docstr =<<"End_of_Doc;";
+my $docstr = <<"End_of_Doc;";
 <?xml version="1.0" encoding="ISO-8859-1" ?>
 <!DOCTYPE foo SYSTEM 't/foo.dtd'
   [
@@ -52,121 +56,125 @@ End_of_Doc;
 
 my $entcnt = 0;
 my %ents;
-my @tests;
 
 sub enth1 {
-    my ($p, $name, $val, $sys, $pub, $notation) = @_;
-
-    $tests[2]++ if ($name eq 'alpha' and $val eq 'a');
-    $tests[3]++ if ($name eq 'skunk' and $val eq 'stinky animal');
-    $tests[4]++ if ($name eq 'logo' and !defined($val) and
-		    $sys eq 'logo.gif' and $pub eq '//Widgets Corp/Logo'
-		    and $notation eq 'gif');
+    my ( $p, $name, $val, $sys, $pub, $notation ) = @_;
+
+    is( $val, 'a' )             if ( $name eq 'alpha' );
+    is( $val, 'stinky animal' ) if ( $name eq 'skunk' );
+    if ( $name eq 'logo' ) {
+        ok( !defined($val) );
+        is( $sys,      'logo.gif' );
+        is( $pub,      '//Widgets Corp/Logo' );
+        is( $notation, 'gif' );
+    }
 }
 
-my $parser = new XML::Parser(ErrorContext  => 2,
-			     NoLWP         => 1,
-			     ParseParamEnt => 1,
-			     Handlers => {Entity => \&enth1});
+my $parser = new XML::Parser(
+    ErrorContext  => 2,
+    NoLWP         => 1,
+    ParseParamEnt => 1,
+    Handlers      => { Entity => \&enth1 }
+);
 
 eval { $parser->parse($docstr) };
-if($@ && $^O =~ m/freebsd/i) {
-    for(2..30) {
-        print "not ok $_ - Cannot test due to Free BSD PR 157469 # TODO: Waiting for Free BSD fix in expat\n";
-    }
-    exit;
-}
 
 sub eleh {
-    my ($p, $name, $model) = @_;
-
-    if ($name eq 'junk') {
-	$tests[5]++ if $model eq '((bar|foo|xyz+),zebra*)';
-	$tests[6]++ if $model->isseq;
-	my @parts = $model->children;
-	$tests[7]++ if $parts[0]->ischoice;
-	my @cparts = $parts[0]->children;
-	$tests[8]++ if $cparts[0] eq 'bar';
-	$tests[9]++ if $cparts[1] eq 'foo';
-	$tests[10]++ if $cparts[2] eq 'xyz+';
-	$tests[11]++ if $cparts[2]->name eq 'xyz';
-	$tests[12]++ if $parts[1]->name eq 'zebra';
-	$tests[13]++ if $parts[1]->quant eq '*';
+    my ( $p, $name, $model ) = @_;
+
+    if ( $name eq 'junk' ) {
+        is( $model, '((bar|foo|xyz+),zebra*)' );
+        ok $model->isseq;
+        my @parts = $model->children;
+        ok( $parts[0]->ischoice );
+        my @cparts = $parts[0]->children;
+        is( $cparts[0],       'bar' );
+        is( $cparts[1],       'foo' );
+        is( $cparts[2],       'xyz+' );
+        is( $cparts[2]->name, 'xyz' );
+        is( $parts[1]->name,  'zebra' );
+        is( $parts[1]->quant, '*' );
     }
 
-    if ($name eq 'xyz') {
-      $tests[14]++ if ($model->ismixed and ! defined($model->children));
+    if ( $name eq 'xyz' ) {
+        ok( $model->ismixed );
+        ok( !defined( $model->children ) );
     }
 
-    if ($name eq 'zebra') {
-      $tests[15]++ if ($model->ismixed and ($model->children)[1] eq 'strong');
+    if ( $name eq 'zebra' ) {
+        ok( $model->ismixed );
+        is( ( $model->children )[1], 'strong' );
     }
 
-    if ($name eq 'bar') {
-      $tests[16]++ if $model->isany;
+    if ( $name eq 'bar' ) {
+        ok( $model->isany );
     }
 }
 
 sub enth2 {
-    my ($p, $name, $val, $sys, $pub, $notation) = @_;
-
-    $tests[17]++ if ($name eq 'alpha' and $val eq 'a');
-    $tests[18]++ if ($name eq 'skunk' and $val eq 'stinky animal');
-    $tests[19]++ if ($name eq 'big' and $val eq $bigval);
-    $tests[20]++ if ($name eq 'logo' and !defined($val) and
-		    $sys eq 'logo.gif' and $pub eq '//Widgets Corp/Logo'
-		    and $notation eq 'gif');
+    my ( $p, $name, $val, $sys, $pub, $notation ) = @_;
+
+    is( $val, 'a' )             if ( $name eq 'alpha' );
+    is( $val, 'stinky animal' ) if ( $name eq 'skunk' );
+    is( $val, $bigval )         if ( $name eq 'big' );
+    ok( !defined($val) and $sys eq 'logo.gif' and $pub eq '//Widgets Corp/Logo' and $notation eq 'gif' )
+      if ( $name eq 'logo' );
 }
 
 sub doc {
-    my ($p, $name, $sys, $pub, $intdecl) = @_;
+    my ( $p, $name, $sys, $pub, $intdecl ) = @_;
 
-    $tests[21]++ if $name eq 'foo';
-    $tests[22]++ if $sys eq 't/foo.dtd';
-    $tests[23]++ if $intdecl
+    is( $name, 'foo' );
+    is( $sys,  't/foo.dtd' );
+    ok($intdecl);
 }
 
 sub att {
-    my ($p, $elname, $attname, $type, $default, $fixed) = @_;
-
-    $tests[24]++ if ($elname eq 'junk' and $attname eq 'id'
-		     and $type eq 'ID' and $default eq '#REQUIRED'
-		     and not $fixed);
-    $tests[25]++ if ($elname eq 'junk' and $attname eq 'version'
-		     and $type eq 'CDATA' and $default eq "'1.0'" and $fixed);
-    $tests[26]++ if ($elname eq 'junk' and $attname eq 'color'
-		     and $type eq '(red|green|blue)'
-		     and $default eq "'green'");
-    $tests[27]++ if ($elname eq 'bar' and $attname eq 'big' and $default eq
-		     "'$bigval'");
-    $tests[28]++ if ($elname eq 'junk' and $attname eq 'foo'
-                     and $type eq 'NOTATION(x|y|z)' and $default eq '#IMPLIED');
-
+    my ( $p, $elname, $attname, $type, $default, $fixed ) = @_;
+
+    if ( $elname eq 'junk' ) {
+        if ( $attname eq 'id' and $type eq 'ID' ) {
+            is( $default, '#REQUIRED' );
+            ok( !$fixed );
+        }
+        elsif ( $attname eq 'version' and $type eq 'CDATA' ) {
+            is( $default, "'1.0'" );
+            ok($fixed);
+        }
+        elsif ( $attname eq 'color' and $type eq '(red|green|blue)' ) {
+            is( $default, "'green'" );
+        }
+        elsif ( $attname eq 'foo' and $type eq 'NOTATION(x|y|z)' ) {
+            is( $default, '#IMPLIED' );
+        }
+    }
+    elsif ( $elname eq 'bar' ) {
+        is( $attname, 'big' );
+        is( $default, "'$bigval'" );
+    }
 }
-    
+
 sub xd {
-    my ($p, $version, $enc, $stand) = @_;
+    my ( $p, $version, $enc, $stand ) = @_;
 
-    if (defined($version)) {
-      if ($version eq '1.0' and $enc eq 'ISO-8859-1' and not defined($stand)) {
-	$tests[29]++;
-      }
+    if ( defined($version) ) {
+        is( $version, '1.0' );
+        is( $enc,     'ISO-8859-1' );
+        ok( !defined($stand) );
     }
     else {
-      $tests[30]++ if $enc eq 'x-sjis-unicode';
+        is( $enc, 'x-sjis-unicode' );
     }
 }
 
-$parser->setHandlers(Entity  => \&enth2,
-		     Element => \&eleh,
-		     Attlist => \&att,
-		     Doctype => \&doc,
-		     XMLDecl => \&xd);
+$parser->setHandlers(
+    Entity  => \&enth2,
+    Element => \&eleh,
+    Attlist => \&att,
+    Doctype => \&doc,
+    XMLDecl => \&xd
+);
 
 $| = 1;
 $parser->parse($docstr);
 
-for (2 .. 30) {
-    print "not " unless $tests[$_];
-    print "ok $_\n";
-}
@@ -1,15 +1,12 @@
-BEGIN {print "1..2\n";}
-END {print "not ok 1\n" unless $loaded;}
+
+use Test::More tests => 1;
 use XML::Parser;
-$loaded = 1;
-print "ok 1\n";
 
 my $count = 0;
 
-$parser = new XML::Parser(ErrorContext => 2);
+$parser = XML::Parser->new(ErrorContext => 2);
 $parser->setHandlers(Comment => sub {$count++;});
 
 $parser->parsefile('samples/REC-xml-19980210.xml');
 
-print "not " unless $count == 37;
-print "ok 2\n";
+is($count, 37);
@@ -0,0 +1,25 @@
+
+use if $] < 5.006, Test::More => skip_all => 'syntax requires perl 5.6';
+
+#tests behaviour on perls 5.10? .. 5.10.1
+package Some::Fake::Packege;
+sub fake_sub {
+  require FileHandle;
+}
+package main;
+
+use Test::More tests => 1;
+use XML::Parser;
+use strict;
+
+my $count = 0;
+
+my $parser = XML::Parser->new(ErrorContext => 2);
+$parser->setHandlers(Comment => sub {$count++;});
+
+open my $fh,'<','samples/REC-xml-19980210.xml' or die;
+#on 5.10 $fh would be a FileHandle object without a real FileHandle class
+
+$parser->parse($fh);
+
+is($count, 37);
@@ -1,10 +1,12 @@
-BEGIN {print "1..12\n";}
-END {print "not ok 1\n" unless $loaded;}
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 13;
 use XML::Parser;
-$loaded = 1;
-print "ok 1\n";
 
-my $internal_subset =<<'End_of_internal;';
+my $internal_subset = <<'End_of_internal;';
 [
   <!ENTITY % foo "IGNORE">
   <!ENTITY % bar "INCLUDE">
@@ -12,7 +14,7 @@ my $internal_subset =<<'End_of_internal;';
 ]
 End_of_internal;
 
-my $doc =<<"End_of_doc;";
+my $doc = <<"End_of_doc;";
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <!DOCTYPE foo SYSTEM "t/foo.dtd"
 $internal_subset>
@@ -23,101 +25,78 @@ $internal_subset>
 </foo>
 End_of_doc;
 
-my $gotinclude = 0;
-my $gotignore = 0;
-my $doctype_called = 0;
+my $bartxt          = '';
 my $internal_exists = 0;
-my $gotmore = 0;
-
-my $bartxt = '';
 
 sub start {
-  my ($xp, $el, %atts) = @_;
-
-  if ($el eq 'foo') {
-    print "not " if defined($atts{top});
-    print "ok 2\n";
-    print "not " unless defined($atts{zz});
-    print "ok 3\n";
-  }
-  elsif ($el eq 'bar') {
-    print "not " unless (defined $atts{xyz} and $atts{xyz} eq 'b');
-    print "ok 4\n";
-  }
-  elsif ($el eq 'ext') {
-    print "not " unless (defined $atts{type} and $atts{type} eq 'flag');
-    print "ok 5\n";
-  }
-  elsif ($el eq 'more') {
-    $gotmore = 1;
-  }
+    my ( $xp, $el, %atts ) = @_;
+
+    if ( $el eq 'foo' ) {
+        ok( !defined $atts{top} );
+        ok( defined $atts{zz} );
+    }
+    elsif ( $el eq 'bar' ) {
+        is( $atts{xyz}, 'b' );
+    }
+    elsif ( $el eq 'ext' ) {
+        is( $atts{type}, 'flag' );
+    }
+    elsif ( $el eq 'more' ) {
+        pass("got 'more'");
+    }
 }
 
 sub char {
-  my ($xp, $text) = @_;
+    my ( $xp, $text ) = @_;
 
-  $bartxt .= $text if $xp->current_element eq 'bar';
+    $bartxt .= $text if $xp->current_element eq 'bar';
 }
 
 sub attl {
-  my ($xp, $el, $att, $type, $dflt, $fixed) = @_;
+    my ( $xp, $el, $att, $type, $dflt, $fixed ) = @_;
 
-  $gotinclude = 1 if ($el eq 'bar' and $att eq 'xyz' and $dflt eq "'b'");
-  $gotignore = 1 if ($el eq 'foo' and $att eq 'top' and $dflt eq '"hello"');
+    ok( ( $att eq 'xyz' and $dflt eq "'b'" ), 'when el eq bar' ) if ( $el eq 'bar' );
+    ok( !( $att eq 'top' and $dflt eq '"hello"' ), 'when el eq foo' ) if ( $el eq 'foo' );
 }
 
 sub dtd {
-  my ($xp, $name, $sysid, $pubid, $internal) = @_;
+    my ( $xp, $name, $sysid, $pubid, $internal ) = @_;
 
-  $doctype_called = 1;
-  $internal_exists = $internal;
+    pass("doctype called");
+    $internal_exists = $internal;
 }
 
-$p = new XML::Parser(ParseParamEnt => 1,
-		     ErrorContext  => 2,
-		     Handlers => {Start   => \&start,
-				  Char    => \&char,
-				  Attlist => \&attl,
-				  Doctype => \&dtd
-				 }
-		    );
-
-eval { $p->parse($doc) };
-if($@ && $^O =~ m/freebsd/i) {
-    for(2..12) {
-        print "not ok $_ - Cannot test due to Free BSD PR 157469 # TODO: Waiting for Free BSD fix in expat\n";
+my $p = new XML::Parser(
+    ParseParamEnt => 1,
+    ErrorContext  => 2,
+    Handlers      => {
+        Start   => \&start,
+        Char    => \&char,
+        Attlist => \&attl,
+        Doctype => \&dtd
     }
-    exit;
-}
-
-print "not " unless $gotmore;
-print "ok 6\n";
-
-print "not " unless $bartxt eq ($] < 5.006)
-		? "\xe5\x83\x96, \xe5\x83\x96"
-		: chr(0x50d6). ", " . chr(0x50d6);
-print "ok 7\n";
-
-print "not " unless $gotinclude;
-print "ok 8\n";
+);
 
-print "not " if $gotignore;
-print "ok 9\n";
+eval { $p->parse($doc) };
 
-print "not " unless $doctype_called;
-print "ok 10\n";
+if ( $] < 5.006 ) {
+    is( $bartxt, "\xe5\x83\x96, \xe5\x83\x96" );
+}
+else {
+    is( $bartxt, chr(0x50d6) . ", " . chr(0x50d6) );
+}
 
-print "not " unless $internal_exists;
-print "ok 11\n";
+ok( $internal_exists, 'internal exists' );
 
 $doc =~ s/[\s\n]+\[[^]]*\][\s\n]+//m;
 
-$p->setHandlers(Start => sub {
-		          my ($xp,$el,%atts) = @_;
-			  if ($el eq 'foo') {
-			    print "not " unless defined($atts{zz});
-			    print "ok 12\n";
-			  }
-			});
+$p->setHandlers(
+    Start => sub {
+        my ( $xp, $el, %atts ) = @_;
+        if ( $el eq 'foo' ) {
+            ok( defined( $atts{zz} ) );
+        }
+    }
+);
 
 $p->parse($doc);