Commits

Anonymous committed e59e8c7

Modified Files:
Makefile.PL
+ win32 tests.

Changes
+ note about win32 fixes

LibXML.xs
+ win32 patches

LibXML.pm
SAX warnings, errors .. now write to $@ not imetiatly to STDERR
this is a prepatch, since XML::LibXML::SAX does not correctly implement
the SAX Execption throwing yet.
for some reason i won't get the correct line/column information from
libxml2's sax parser.

Comments (0)

Files changed (4)

    - fixed memory management within documents that have subsets
    - fixed some threaded perl issues
      (very special thanks to andreas koenig for the patch)
+   - applied Win32 patch
+     (very special thanks to randy kobes for the patch)
    - fixed findnodes() and find() to return empty arrays in array context
      if the statement was legal but produced no result.
    - fixed local namespace handling in DOM functions
 # these functions will use SAX exceptions as soon i know how things really work
 sub warning {
     my ( $parser, $message ) = @_;
-    warn( $message );
+    eval { die( $message ); };
 }
 
 sub error {
     my ( $parser, $message ) = @_;
-    warn( $message );
+    eval { die( $message ); };
 }
 
 sub fatal_error {
     my ( $parser, $message ) = @_;
-    warn( $message );
+    die( $message );
 }
 
 1;
 #include "ppport.h"
 
 #include <fcntl.h>
-#include <unistd.h>
+
+#ifndef WIN32
+#  include <unistd.h>
+#endif
 
 /* libxml2 stuff */
 #include <libxml/xmlmemory.h>
 extern int xmlSubstituteEntitiesDefaultVal;
 #define xmlSubstituteEntitiesDefaultValue xmlSubstituteEntitiesDefaultVal
 #else
-extern int xmlDoValidityCheckingDefaultValue;
-extern int xmlSubstituteEntitiesDefaultValue;
+LIBXML_DLL_IMPORT extern int xmlDoValidityCheckingDefaultValue;
+LIBXML_DLL_IMPORT extern int xmlSubstituteEntitiesDefaultValue;
 #endif
-extern int xmlGetWarningsDefaultValue;
-extern int xmlKeepBlanksDefaultValue;
-extern int xmlLoadExtDtdDefaultValue;
-extern int xmlPedanticParserDefaultValue;
+LIBXML_DLL_IMPORT extern int xmlGetWarningsDefaultValue;
+LIBXML_DLL_IMPORT extern int xmlKeepBlanksDefaultValue;
+LIBXML_DLL_IMPORT extern int xmlLoadExtDtdDefaultValue;
+LIBXML_DLL_IMPORT extern int xmlPedanticParserDefaultValue;
 
 #define TEST_PERL_FLAG(flag) \
     SvTRUE(perl_get_sv(flag, FALSE)) ? 1 : 0
 
         LibXML_init_parser(self);
         RETVAL = xmlParseDocument(ctxt);
+
         xmlFree( ctxt->sax );
         ctxt->sax = NULL;
         PmmSAXCloseContext(ctxt);
         SV * dom
     PREINIT:
         xmlDocPtr real_dom = (xmlDocPtr)PmmSvNode(dom);
-        char * ERROR;
+        char * LibXML_ERROR_MSG;
         STRLEN len;
     CODE:
         if ( real_dom == NULL ) {
         LibXML_cleanup_callbacks();
         LibXML_cleanup_parser();
 
-        ERROR = SvPV(LibXML_error, len );
+        LibXML_ERROR_MSG = SvPV(LibXML_error, len );
     
         if ( len > 0 ){
-                croak(ERROR);
+                croak(LibXML_ERROR_MSG);
                 XSRETURN_UNDEF;            
         }
         else {
 use Symbol;
 use File::Spec;
 
+my $is_win32 = ($^O =~ /Win32/i);
+
 $|=0;
 
 my %config;
 }
 
 # get libs and inc from gnome-config
-eval {
-    my $xml2cfg = "xml2-config";
-    if ( defined $ENV{XMLPREFIX} ) {
-        $xml2cfg = $ENV{XMLPREFIX} . '/bin/' . $xml2cfg;
-    }
-    print "running xml2-config... ";
-    my $ver = backtick("$xml2cfg --version");
-    my ($major, $minor, $point) = $ver =~ /(\d+).(\d+)\.(\d+)/g;
-    die "VERSION $major.$minor.$point" unless $major > $lib_major
-      || ($major == $lib_major && $minor > $lib_minor)
-      || ($major == $lib_major && $minor == $lib_minor && $point >= $lib_patch);
-    $config{LIBS} ||= backtick("$xml2cfg --libs");
-    $config{INC}  ||= backtick("$xml2cfg --cflags");
-    print "ok\n";
-};
-if ($@) {
-    print "failed\n";
-    if ($@ =~ /^VERSION/) {
-        die "XML::LibXML needs libxml2 version $lib_major.$lib_minor.$lib_patch or higher (found $@)\n";
-    }
-    warn "*** ", $@ if $DEBUG;
-    warn "using fallback values for LIBS and INC\n";
-    # backtick fails if gnome-config didn't exist...
-    $config{LIBS} = '-L/usr/local/lib -L/usr/lib -lxml2 -lz -lm';
-    $config{INC} = '-I/usr/local/include -I/usr/include';
-    
-    print <<OPT;
+
+unless ( $win32 ) {
+    eval {
+        my $xml2cfg = "xml2-config";
+        if ( defined $ENV{XMLPREFIX} ) {
+            $xml2cfg = $ENV{XMLPREFIX} . '/bin/' . $xml2cfg;
+        }
+        print "running xml2-config... ";
+        my $ver = backtick("$xml2cfg --version");
+        my ($major, $minor, $point) = $ver =~ /(\d+).(\d+)\.(\d+)/g;
+        die "VERSION $major.$minor.$point" unless $major > $lib_major
+          || ($major == $lib_major && $minor > $lib_minor)
+            || ($major == $lib_major && $minor == $lib_minor && $point >= $lib_patch);
+        $config{LIBS} ||= backtick("$xml2cfg --libs");
+        $config{INC}  ||= backtick("$xml2cfg --cflags");
+        print "ok\n";
+    };
+    if ($@) {
+        print "failed\n";
+        if ($@ =~ /^VERSION/) {
+            die "XML::LibXML needs libxml2 version $lib_major.$lib_minor.$lib_patch or higher (found $@)\n";
+        }
+        warn "*** ", $@ if $DEBUG;
+        warn "using fallback values for LIBS and INC\n";
+        # backtick fails if gnome-config didn't exist...
+        $config{LIBS} = '-L/usr/local/lib -L/usr/lib -lxml2 -lz -lm';
+        $config{INC} = '-I/usr/local/include -I/usr/include';
+        
+        print <<OPT;
 options:
   LIBS='$config{LIBS}'
   INC='$config{INC}'
   \$ $^X Makefile.PL LIBS='-L/path/to/lib' INC='-I/path/to/include'
 
 OPT
-
+    }
 }
 
+
 if ($config{LIBS} !~ /\-lxml2\b/) {
-    $config{LIBS} .= ' -lxml2';
+    $config{LIBS} .= $is_win32 ? '-llibxml2' : ' -lxml2';
 }
 
 if ($config{LIBS} !~ /\-lz\b/) {
-    $config{LIBS} .= ' -lz';
+    $config{LIBS} .= $is_win32 ? '-lzlib' :' -lz';
 }
 
 if ($config{LIBS} !~ /\-lm\b/) {
-    $config{LIBS} .= ' -lm';
+    $config{LIBS} .= $is_win32 ? '' :' -lm';
 }
 
-if (!have_library("xml2")) {
+unless (have_library("xml2") or have_library("libxml2")) {
     die <<DEATH;
 libxml2 not found
 Try setting LIBS and INC values on the command line