Shlomi Fish avatar Shlomi Fish committed bdc2e21

Got rid of a lot of trailing space.

With a test. TODO: test for trailing space in more files.

Comments (0)

Files changed (59)

  * Perl itself.
  *
  * Copyright 2011 Joachim Zobel
- * 
- * This module gives external access to the functions needed to create 
- * and use XML::LibXML::Nodes from C functions. These functions are made 
+ *
+ * This module gives external access to the functions needed to create
+ * and use XML::LibXML::Nodes from C functions. These functions are made
  * accessible from Perl to have cleaner dependencies.
- * The idea is to pass xmlNode * pointers (as typemapped void *) to and 
- * from Perl and call the functions that turns them to and from  
- * XML::LibXML::Nodes there.  
+ * The idea is to pass xmlNode * pointers (as typemapped void *) to and
+ * from Perl and call the functions that turns them to and from
+ * XML::LibXML::Nodes there.
  *
  * Be aware that using this module gives you the ability to easily create
  * segfaults and memory leaks.
                           xmlMemStrdup);
 }
 
-MODULE = XML::LibXML::Devel		PACKAGE = XML::LibXML::Devel		
+MODULE = XML::LibXML::Devel		PACKAGE = XML::LibXML::Devel
 
 PROTOTYPES: DISABLE
 
     OUTPUT:
         RETVAL
 
-void 
+void
 refcnt_inc( n )
         void *n
     PREINIT:
     CODE:
         PmmREFCNT_inc(((ProxyNode *)(node->_private)));
 
-int 
+int
 refcnt_dec( n )
         void *n
     PREINIT:
     OUTPUT:
         RETVAL
 
-int 
+int
 refcnt( n )
         void *n
     PREINIT:
   $flags |=     4 if $opts->{no_defdtd}; # default is ON: injects DTD as needed
   $flags |=    32 if exists $opts->{suppress_errors} ? $opts->{suppress_errors} : $self->get_option('suppress_errors');
   # This is to fix https://rt.cpan.org/Ticket/Display.html?id=58024 :
-  # <quote> 
+  # <quote>
   # In XML::LibXML, warnings are not suppressed when specifying the recover
   # or recover_silently flags as per the following excerpt from the manpage:
   # </quote>
     my $result;
 
     $self->_init_callbacks();
-    eval { 
+    eval {
       $result = $self->_parse_html_string( $str,
 					   $self->_html_options($opts)
-					  ); 
+					  );
     };
     my $err = $@;
     $self->{_State_} = 0;
       $self->_cleanup_callbacks();
       croak $err;
     }
-    
+
     $self->_cleanup_callbacks();
 
     return $result;
 
     my $result;
     $self->_init_callbacks();
-    eval { $result = $self->_parse_html_fh( $fh, 
+    eval { $result = $self->_parse_html_fh( $fh,
 					    $self->_html_options($opts)
 					   ); };
     my $err = $@;
     my $self = shift;
 
     $self->_init_callbacks();
-    
+
     if ( not defined $self->{CONTEXT} ) {
         $self->init_push();
     }
     return ((not $self->_isSameNodeLax($other)) ? 1 : '');
 }
 
-sub _isSameNodeLax { 
+sub _isSameNodeLax {
     my ($self, $other) = @_;
 
-    if (blessed($other) and $other->isa('XML::LibXML::Element')) 
-    { 
-        return ($self->isSameNode($other) ? 1 : ''); 
+    if (blessed($other) and $other->isa('XML::LibXML::Element'))
+    {
+        return ($self->isSameNode($other) ? 1 : '');
     }
     else
     {
   my $class = shift;
   my ($pattern,$ns_map)=@_;
   my $self = undef;
-  
+
   unless (UNIVERSAL::can($class,'_compilePattern')) {
     croak("Cannot create XML::LibXML::Pattern - ".
 	  "your libxml2 is compiled without pattern support!");
     # any new global callbacks are shifted to the callback stack.
     foreach my $cb ( @_GLOBAL_CALLBACKS ) {
 
-        # callbacks have to return 1, 0 or undef, while 0 and undef 
-        # are handled the same way. 
-        # in fact, if callbacks return other values, the global match 
+        # callbacks have to return 1, 0 or undef, while 0 and undef
+        # are handled the same way.
+        # in fact, if callbacks return other values, the global match
         # assumes silently that the callback failed.
 
         $retval = $cb->[0]->($uri);
         if ( defined $retval and $retval == 1 ) {
             # make the other callbacks use this callback
             $_CUR_CB = $cb;
-            unshift @_CB_STACK, $cb; 
+            unshift @_CB_STACK, $cb;
             last;
         }
     }
 sub _callback_open {
     my $uri = shift;
     my $retval = undef;
-    
-    # the open callback has to return a defined value. 
-    # if one works on files this can be a file handle. But 
-    # depending on the needs of the callback it also can be a 
+
+    # the open callback has to return a defined value.
+    # if one works on files this can be a file handle. But
+    # depending on the needs of the callback it also can be a
     # database handle or a integer labeling a certain dataset.
 
     if ( defined $_CUR_CB ) {
         $retval = $_CUR_CB->[1]->( $uri );
-        
+
         # reset the callbacks, if one callback cannot open an uri
         if ( not defined $retval or $retval == 0 ) {
             shift @_CB_STACK;
             $_CUR_CB = $_CB_STACK[0];
         }
     }
-    
+
     return $retval;
 }
 
 sub _callback_close {
     my $fh = shift;
     my $retval = 0;
-    
+
     if ( defined $_CUR_CB ) {
         $retval = $_CUR_CB->[3]->( $fh );
         shift @_CB_STACK;
 sub register_callbacks {
     my $self = shift;
     my $cbset = shift;
-    
+
     # test if callback set is complete
     if ( ref $cbset eq "ARRAY" and scalar( @$cbset ) == 4 ) {
         unshift @{$self->{_CALLBACKS}}, $cbset;
     }
 }
 
-# make libxml2 use the callbacks 
+# make libxml2 use the callbacks
 sub init_callbacks {
     my $self = shift;
     my $parser = shift;
     $_CUR_CB           = undef;
     @_CB_STACK         = ();
     @_GLOBAL_CALLBACKS = @{ $self->{_CALLBACKS} };
-    
+
     #attach parser specific callbacks
     if($parser) {
         my $mcb = $parser->match_callback();
     }
 
     #attach global callbacks
-    if ( defined $XML::LibXML::match_cb and 
-         defined $XML::LibXML::open_cb  and 
-         defined $XML::LibXML::read_cb  and 
+    if ( defined $XML::LibXML::match_cb and
+         defined $XML::LibXML::open_cb  and
+         defined $XML::LibXML::read_cb  and
          defined $XML::LibXML::close_cb ) {
         push @_GLOBAL_CALLBACKS, [$XML::LibXML::match_cb,
                                   $XML::LibXML::open_cb,
     if ( saved_error == NULL ) {
         warn( "have no save_error\n" );
     }
-    
+
     ENTER;
     SAVETMPS;
     PUSHMARK(SP);
-    
+
     XPUSHs(sv_2mortal(libErr));
     if ( saved_error != NULL && SvOK(saved_error) ) {
         XPUSHs(saved_error);
     }
     PUTBACK;
-    
+
     if ( saved_error != NULL ) {
       call_pv( "XML::LibXML::Error::_callback_error", G_SCALAR | G_EVAL );
     } else {
     if (!recover || recover==1) {
       dTHX;
       dSP;
-      
+
       ENTER;
       SAVETMPS;
       PUSHMARK(SP);
 	call_pv( "XML::LibXML::Error::_report_error", G_SCALAR | G_DISCARD);
       }
       SPAGAIN;
-      
+
       PUTBACK;
       FREETMPS;
       LEAVE;
 
 #ifndef WITH_SERRORS
 static void
-LibXML_reader_error_handler(void * ctxt, 
-				const char * msg,  
-				xmlParserSeverities severity, 
+LibXML_reader_error_handler(void * ctxt,
+				const char * msg,
+				xmlParserSeverities severity,
 				xmlTextReaderLocatorPtr locator)
 {
   int line = xmlTextReaderLocatorLineNumber(locator);
   }
   if (filename) {
     sv_catpvf(error, " in %s", filename);
-    xmlFree(filename);    
+    xmlFree(filename);
   }
   if (line >= 0) {
     sv_catpvf(error, " at line %d", line);
 }
 #endif /* !defined WITH_SERRORS */
 
-SV * 
+SV *
 LibXML_get_reader_error_data(xmlTextReaderPtr reader)
 {
   SV * saved_error = NULL;
         PUSHs(sv_2mortal(newSVpv((char*)filename, 0)));
         PUTBACK;
 
-        count = call_pv("XML::LibXML::InputCallback::_callback_match", 
+        count = call_pv("XML::LibXML::InputCallback::_callback_match",
                              G_SCALAR | G_EVAL);
 
         SPAGAIN;
     PUSHs(sv_2mortal(newSVpv((char*)filename, 0)));
     PUTBACK;
 
-    count = call_pv("XML::LibXML::InputCallback::_callback_open", 
+    count = call_pv("XML::LibXML::InputCallback::_callback_open",
                               G_SCALAR | G_EVAL);
 
     SPAGAIN;
         PUSHs(sv_2mortal(newSViv(len)));
         PUTBACK;
 
-        count = call_pv("XML::LibXML::InputCallback::_callback_read", 
+        count = call_pv("XML::LibXML::InputCallback::_callback_read",
                              G_SCALAR | G_EVAL);
 
         SPAGAIN;
          * being set. See t/49callbacks_returning_undef.t and:
          * https://rt.cpan.org/Ticket/Display.html?id=70321
          * */
-        
+
         output_sv = POPs;
-        output = SvOK(output_sv) ? SvPV_nolen(output_sv) : NULL;    
+        output = SvOK(output_sv) ? SvPV_nolen(output_sv) : NULL;
 
         if (output != NULL) {
             res_len = strlen(output);
         PUSHs(ctxt);
         PUTBACK;
 
-        call_pv("XML::LibXML::InputCallback::_callback_close", 
+        call_pv("XML::LibXML::InputCallback::_callback_close",
                              G_SCALAR | G_EVAL | G_DISCARD);
 
         SvREFCNT_dec(ctxt);
     /* documentation is quite clear about this. If       */
     /* something fails it is a problem elsewhere. Simply */
     /* resetting the entire module will lead to unwanted */
-    /* results in server environments, such as if        */ 
+    /* results in server environments, such as if        */
     /* mod_perl is used together with php's xml module.  */
     /* calling xmlInitParser() here is definitely wrong!  */
-    /* xmlInitParser(); */ 
+    /* xmlInitParser(); */
 
 #ifndef WITH_SERRORS
     xmlGetWarningsDefaultValue = 0;
         }
         if (ctxt) xmlCtxtUseOptions(ctxt, parserOptions ); /* Note: sets ctxt->linenumbers = 1 */
 
-        /* 
+        /*
          * Without this if/else conditional, NOBLANKS has no effect.
          *
          * For more information, see:
                 LibXML_old_ext_ent_loader =  xmlGetExternalEntityLoader();
                 xmlSetExternalEntityLoader( (xmlExternalEntityLoader)LibXML_load_external_entity );
             }
-            else 
+            else
              {
                 if (parserOptions & XML_PARSE_NONET)
                 {
 
     key = newSViv(PTR2IV(hashkey));
     strkey = SvPV(key, len);
-    if (pnode != NULL && !hv_exists(XPathContextDATA(ctxt)->pool,strkey,len)) {        
+    if (pnode != NULL && !hv_exists(XPathContextDATA(ctxt)->pool,strkey,len)) {
         value = hv_store(XPathContextDATA(ctxt)->pool,strkey,len, SvREFCNT_inc(pnode),0);
     } else {
         value = hv_fetch(XPathContextDATA(ctxt)->pool,strkey,len, 0);
     }
     SvREFCNT_dec(key);
-    
+
     if (value == NULL) {
         return &PL_sv_undef;
     } else {
     dTHX;
 
     if (!SvOK(perl_result)) {
-        return (xmlXPathObjectPtr)xmlXPathNewCString("");        
+        return (xmlXPathObjectPtr)xmlXPathNewCString("");
     }
     if (SvROK(perl_result) &&
         SvTYPE(SvRV(perl_result)) == SVt_PVAV) {
             pnode = av_fetch(array_result,i,0);
             if (pnode != NULL && sv_isobject(*pnode) &&
                 sv_derived_from(*pnode,"XML::LibXML::Node")) {
-                xmlXPathNodeSetAdd(ret->nodesetval, 
+                xmlXPathNodeSetAdd(ret->nodesetval,
                                    INT2PTR(xmlNodePtr,PmmSvNode(*pnode)));
                 if(ctxt) {
                     LibXML_XPathContext_pool(ctxt->context,
             }
         }
         return ret;
-    } else if (sv_isobject(perl_result) && 
-               (SvTYPE(SvRV(perl_result)) == SVt_PVMG)) 
+    } else if (sv_isobject(perl_result) &&
+               (SvTYPE(SvRV(perl_result)) == SVt_PVMG))
         {
             if (sv_derived_from(perl_result, "XML::LibXML::Node")) {
                 xmlNodePtr tmp_node;
                 tmp_node = INT2PTR(xmlNodePtr,PmmSvNode(perl_result));
                 xmlXPathNodeSetAdd(ret->nodesetval,tmp_node);
                 if(ctxt) {
-                    LibXML_XPathContext_pool(ctxt->context, PmmSvNode(perl_result), 
+                    LibXML_XPathContext_pool(ctxt->context, PmmSvNode(perl_result),
                                              perl_result);
                 }
 
 	if (XPathContextDATA(copy)) {
 	    memcpy(XPathContextDATA(copy), XPathContextDATA(ctxt),sizeof(XPathContextData));
 	    /* clear ctxt->pool, so that it is not used freed during re-entrance */
-	    XPathContextDATA(ctxt)->pool = NULL; 
+	    XPathContextDATA(ctxt)->pool = NULL;
 	}
     }
     return copy;
     data = XPathContextDATA(ctxt);
     if ( data == NULL )
 	croak("XPathContext: missing xpath context private data");
-    if ( data->varLookup == NULL || !SvROK(data->varLookup) || 
+    if ( data->varLookup == NULL || !SvROK(data->varLookup) ||
 	 SvTYPE(SvRV(data->varLookup)) != SVt_PVCV )
         croak("XPathContext: lost variable lookup function!");
 
     SAVETMPS;
     PUSHMARK(SP);
 
-    XPUSHs( (data->varData != NULL) ? data->varData : &PL_sv_undef ); 
-    XPUSHs(sv_2mortal(C2Sv(name,NULL))); 
+    XPUSHs( (data->varData != NULL) ? data->varData : &PL_sv_undef );
+    XPUSHs(sv_2mortal(C2Sv(name,NULL)));
     XPUSHs(sv_2mortal(C2Sv(ns_uri,NULL)));
 
     /* save context to allow recursive usage of XPathContext */
     copy = LibXML_save_context(ctxt);
 
-    PUTBACK ;    
+    PUTBACK ;
     count = call_sv(data->varLookup, G_SCALAR|G_EVAL);
     SPAGAIN;
 
     if (SvTRUE(ERRSV)) {
         (void) POPs;
         croak_obj;
-    } 
+    }
     if (count != 1) croak("XPathContext: variable lookup function returned none or more than one argument!");
 
     ret = LibXML_perldata_to_LibXMLdata(NULL, POPs);
  * **************************************************************** */
 /* Much of the code is borrowed from Matt Sergeant's XML::LibXSLT   */
 static void
-LibXML_generic_extension_function(xmlXPathParserContextPtr ctxt, int nargs) 
+LibXML_generic_extension_function(xmlXPathParserContextPtr ctxt, int nargs)
 {
     xmlXPathObjectPtr obj,ret;
     xmlNodeSetPtr nodelist = NULL;
         SvTYPE(SvRV(data)) != SVt_PVHV) {
         croak("XPathContext: lost function lookup data structure!");
     }
-    
+
     function = (char*) ctxt->context->function;
     uri = (char*) ctxt->context->functionURI;
-    
+
     key = newSVpvn("",0);
     if (uri && *uri) {
         sv_catpv(key, "{");
     strkey = SvPV(key, len);
     perl_function =
         hv_fetch((HV*)SvRV(data), strkey, len, 0);
-    if ( perl_function == NULL || !SvOK(*perl_function) || 
+    if ( perl_function == NULL || !SvOK(*perl_function) ||
          !(SvPOK(*perl_function) ||
            (SvROK(*perl_function) &&
             SvTYPE(SvRV(*perl_function)) == SVt_PVCV))) {
     ENTER;
     SAVETMPS;
     PUSHMARK(SP);
-    
+
     XPUSHs(*perl_function);
 
     /* set up call to perl dispatcher function */
         case XPATH_NODESET:
             nodelist = obj->nodesetval;
             if ( nodelist ) {
-                XPUSHs(sv_2mortal(newSVpv("XML::LibXML::NodeList", 0)));                
+                XPUSHs(sv_2mortal(newSVpv("XML::LibXML::NodeList", 0)));
                 XPUSHs(sv_2mortal(newSViv(nodelist->nodeNr)));
                 if ( nodelist->nodeNr > 0 ) {
                     int j;
             } else {
                 /* PP: We can't simply leave out an empty nodelist as Matt does! */
                 /* PP: The number of arguments must match! */
-                XPUSHs(sv_2mortal(newSVpv("XML::LibXML::NodeList", 0)));                
+                XPUSHs(sv_2mortal(newSVpv("XML::LibXML::NodeList", 0)));
                 XPUSHs(sv_2mortal(newSViv(0)));
             }
             /* prevent libxml2 from freeing the actual nodes */
     /* call perl dispatcher */
     PUTBACK;
     perl_dispatch = sv_2mortal(newSVpv("XML::LibXML::XPathContext::_perl_dispatcher",0));
-    count = call_sv(perl_dispatch, G_SCALAR|G_EVAL);    
+    count = call_sv(perl_dispatch, G_SCALAR|G_EVAL);
     SPAGAIN;
 
     /* restore the xpath context */
     LibXML_restore_context(ctxt->context, copy);
-    
+
     if (SvTRUE(ERRSV)) {
         (void) POPs;
         croak_obj;
-    } 
+    }
 
     if (count != 1) croak("XPathContext: perl-dispatcher in pm file returned none or more than one argument!");
-    
+
     ret = LibXML_perldata_to_LibXMLdata(ctxt, POPs);
 
     valuePush(ctxt, ret);
     PUTBACK;
     FREETMPS;
-    LEAVE;    
+    LEAVE;
 }
 
 static void
 LibXML_configure_xpathcontext( xmlXPathContextPtr ctxt ) {
     xmlNodePtr node = PmmSvNode(XPathContextDATA(ctxt)->node);
 
-    if (node != NULL) {    
+    if (node != NULL) {
         ctxt->doc = node->doc;
     } else {
         ctxt->doc = NULL;
 PROTOTYPES: DISABLE
 
 BOOT:
-    /* Load Devel first, so debug_memory can 
+    /* Load Devel first, so debug_memory can
        be called before any allocation. */
     boot_XML__LibXML__Devel(aTHX_ cv);
     LIBXML_TEST_VERSION
                 croak("Could not create memory parser context!\n");
             }
             xs_warn( "context created\n");
-            real_obj = LibXML_init_parser(self, ctxt); 
+            real_obj = LibXML_init_parser(self, ctxt);
             recover = LibXML_get_recover(real_obj);
 
 
                 croak("Could not create memory parser context!\n");
             }
             xs_warn( "context created\n");
-            real_obj = LibXML_init_parser(self, ctxt); 
+            real_obj = LibXML_init_parser(self, ctxt);
             recover = LibXML_get_recover(real_obj);
 
             PmmSAXInitContext( ctxt, self, saved_error );
           recover = ((options & HTML_PARSE_NOERROR) ? 2 : 1);
         }
 #if LIBXML_VERSION >= 20627
-        real_doc = htmlReadFile((const char *)filename, 
+        real_doc = htmlReadFile((const char *)filename,
 				encoding,
 				options);
 #else
                     rv_end->parent = fragment;
                     rv_end = rv_end->next;
                 }
-                /* the following line is important, otherwise we'll have 
+                /* the following line is important, otherwise we'll have
                    occasional segmentation faults
                  */
                 rv_end->parent = fragment;
             if ( dtd->doc == NULL ) {
                 xmlSetTreeDoc( (xmlNodePtr) dtd, self );
             } else if ( dtd->doc != self ) {
-	        domImportNode( self, (xmlNodePtr) dtd,1,1); 
+	        domImportNode( self, (xmlNodePtr) dtd,1,1);
             }
 
             if ( dtd == self->intSubset ) {
         RETVAL
 
 SV*
-cloneNode( self, deep=0 ) 
+cloneNode( self, deep=0 )
         xmlDocPtr self
         int deep
     PREINIT:
         if ( ret == NULL ) {
             XSRETURN_UNDEF;
         }
-        RETVAL = PmmNodeToSv((xmlNodePtr)ret, NULL); 
+        RETVAL = PmmNodeToSv((xmlNodePtr)ret, NULL);
     OUTPUT:
         RETVAL
 
     CODE:
         PERL_UNUSED_VAR(ix);
         if( ( self->type == XML_ELEMENT_NODE
-	    || self->type == XML_ATTRIBUTE_NODE 
-	    || self->type == XML_PI_NODE ) 
+	    || self->type == XML_ATTRIBUTE_NODE
+	    || self->type == XML_PI_NODE )
             && self->ns != NULL
             && self->ns->prefix != NULL ) {
             RETVAL = C2Sv(self->ns->prefix, NULL);
     CODE:
         PERL_UNUSED_VAR(ix);
         if ( ( self->type == XML_ELEMENT_NODE
-	    || self->type == XML_ATTRIBUTE_NODE 
-	    || self->type == XML_PI_NODE ) 
+	    || self->type == XML_ATTRIBUTE_NODE
+	    || self->type == XML_PI_NODE )
 	     && self->ns != NULL
              && self->ns->href != NULL ) {
             nsURI =  xmlStrdup(self->ns->href);
             croak( "bad name" );
         }
         if( ( self->type == XML_ELEMENT_NODE
-	    || self->type == XML_ATTRIBUTE_NODE 
-	    || self->type == XML_PI_NODE) 
+	    || self->type == XML_ATTRIBUTE_NODE
+	    || self->type == XML_PI_NODE)
 	    && self->ns ){
             localname = xmlSplitQName2(string, &prefix);
 	    if ( localname == NULL ) {
             XSRETURN_UNDEF;
         }
         if( ( self->type == XML_ELEMENT_NODE
-	     || self->type == XML_ATTRIBUTE_NODE 
+	     || self->type == XML_ATTRIBUTE_NODE
 	     || self->type == XML_PI_NODE)
 	    && self->ns ){
             localname = xmlSplitQName2(string, &prefix);
         name = nodeSv2C(node_name, self );
         nsURI = nodeSv2C(namespaceURI, self );
 
-        if ( nsURI != NULL ) { 
+        if ( nsURI != NULL ) {
             if (xmlStrlen(nsURI) == 0 ) {
                 xmlFree(nsURI);
                 nsURI = NULL;
             } else if (xmlStrcmp( nsURI, (xmlChar *)"*" )==0) {
-                ns_wildcard = 1;	        
+                ns_wildcard = 1;
             }
         }
         if ( name !=NULL && xmlStrcmp( name, (xmlChar *)"*" ) == 0) {
             cld = self->children;
             xs_warn("childnodes start");
             while ( cld ) {
-	      if (((name_wildcard && (cld->type == XML_ELEMENT_NODE)) || 
+	      if (((name_wildcard && (cld->type == XML_ELEMENT_NODE)) ||
 		   xmlStrcmp( name, cld->name ) == 0)
 		   && (ns_wildcard ||
-		       (cld->ns != NULL && 
+		       (cld->ns != NULL &&
                         xmlStrcmp(nsURI,cld->ns->href) == 0 ) ||
                        (cld->ns == NULL && nsURI == NULL))) {
                 if( wantarray != G_SCALAR ) {
     CODE:
         PERL_UNUSED_VAR(ix);
 	if ( node->type == XML_ELEMENT_NODE
-	    || node->type == XML_ATTRIBUTE_NODE 
+	    || node->type == XML_ATTRIBUTE_NODE
 	    || node->type == XML_PI_NODE ) {
 	  ns = node->ns;
 	  if ( ns != NULL ) {
                 RETVAL = C2Sv(ret, NULL);
             }
             xmlFree( ret );
-        } 
+        }
         else {
             XSRETURN_UNDEF;
 	}
         }
         value = nodeSv2C(attr_value, self );
 #if LIBXML_VERSION >= 20621
-	/* 
+	/*
 	 * For libxml2-2.6.21 and later we can use just xmlSetProp
          */
         xmlSetProp(self,name,value);
 #else
-        /* 
+        /*
          * but xmlSetProp does not work correctly for older libxml2 versions
 	 * The following is copied from libxml2 source
          * with xmlSplitQName3 replaced by xmlSplitQName2 for compatibility
         if ( nsURI ) {
             xmlFree(nsURI);
         }
-        if ( ret && 
+        if ( ret &&
 	     ret->type == XML_ATTRIBUTE_NODE /* we don't want fixed attribute decls */
-	   ) { 
+	   ) {
             RETVAL = PmmNodeToSv( (xmlNodePtr)ret,
                                    PmmOWNERPO(PmmPROXYNODE(self)) );
         }
             RETVAL = NEWSV(0,0);
             RETVAL = sv_setref_pv( RETVAL,
                                    CLASS,
-                                   (void*)ns);           
+                                   (void*)ns);
 	}
         xmlFree(nsURI);
         if ( nsPrefix )
 
 MODULE = XML::LibXML         PACKAGE = XML::LibXML::RelaxNG
 
-void 
-DESTROY( self ) 
+void
+DESTROY( self )
         xmlRelaxNGPtr self
     CODE:
         xmlRelaxNGFree( self );
 
 MODULE = XML::LibXML         PACKAGE = XML::LibXML::Schema
 
-void 
-DESTROY( self ) 
+void
+DESTROY( self )
         xmlSchemaPtr self
     CODE:
         xmlSchemaFree( self );
         New(0, ctxt->user, sizeof(XPathContextData), XPathContextData);
         if (ctxt->user == NULL) {
             croak("XPathContext: failed to allocate proxy object\n");
-        } 
+        }
 
         if (SvOK(pnode)) {
-          XPathContextDATA(ctxt)->node = newSVsv(pnode); 
+          XPathContextDATA(ctxt)->node = newSVsv(pnode);
         } else {
           XPathContextDATA(ctxt)->node = &PL_sv_undef;
         }
 DESTROY( self )
         SV * self
     INIT:
-        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); 
+        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self)));
     CODE:
         xs_warn( "DESTROY XPATH CONTEXT" );
         if (ctxt) {
                 && SvTYPE(SvRV((SV *)ctxt->funcLookupData)) == SVt_PVHV) {
                 SvREFCNT_dec((SV *)ctxt->funcLookupData);
             }
-            
+
             xmlXPathFreeContext(ctxt);
         }
 
 getContextNode( self )
         SV * self
     INIT:
-        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); 
+        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self)));
         if ( ctxt == NULL ) {
             croak("XPathContext: missing xpath context\n");
         }
 getContextPosition( self )
         SV * self
     INIT:
-        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); 
+        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self)));
         if ( ctxt == NULL ) {
             croak("XPathContext: missing xpath context\n");
         }
 getContextSize( self )
         SV * self
     INIT:
-        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); 
+        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self)));
         if ( ctxt == NULL ) {
             croak("XPathContext: missing xpath context\n");
         }
     OUTPUT:
 	RETVAL
 
-void 
+void
 setContextNode( self , pnode )
         SV * self
         SV * pnode
     INIT:
-        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); 
+        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self)));
         if ( ctxt == NULL ) {
             croak("XPathContext: missing xpath context\n");
         }
             XPathContextDATA(ctxt)->node = NULL;
         }
 
-void 
+void
 setContextPosition( self , position )
         SV * self
         int position
     INIT:
-        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); 
+        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self)));
         if ( ctxt == NULL )
             croak("XPathContext: missing xpath context\n");
         if ( position < -1 || position > ctxt->contextSize )
     PPCODE:
         ctxt->proximityPosition = position;
 
-void 
+void
 setContextSize( self , size )
         SV * self
         int size
     INIT:
-        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); 
+        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self)));
         if ( ctxt == NULL )
             croak("XPathContext: missing xpath context\n");
         if ( size < -1 )
 	    ctxt->proximityPosition = 0;
 	else if ( size > 0 )
 	    ctxt->proximityPosition = 1;
-        else 
+        else
 	    ctxt->proximityPosition = -1;
 
 void
 getVarLookupData( self )
         SV * self
     INIT:
-        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); 
+        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self)));
         if ( ctxt == NULL ) {
             croak("XPathContext: missing xpath context\n");
         }
 getVarLookupFunc( self )
         SV * self
     INIT:
-        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self))); 
+        xmlXPathContextPtr ctxt = INT2PTR(xmlXPathContextPtr,SvIV(SvRV(self)));
         if ( ctxt == NULL ) {
             croak("XPathContext: missing xpath context\n");
         }
         if (SvOK(lookup_func)) {
             if ( SvROK(lookup_func) && SvTYPE(SvRV(lookup_func)) == SVt_PVCV ) {
 		data->varLookup = newSVsv(lookup_func);
-		if (SvOK(lookup_data)) 
+		if (SvOK(lookup_data))
 		    data->varData = newSVsv(lookup_data);
-		xmlXPathRegisterVariableLookup(ctxt, 
+		xmlXPathRegisterVariableLookup(ctxt,
 					       LibXML_generic_variable_lookup, ctxt);
 		if (ctxt->varLookupData==NULL || ctxt->varLookupData != ctxt) {
 		    croak( "XPathContext: registration failure\n" );
-		}    
+		}
             } else {
                 croak("XPathContext: 1st argument is not a CODE reference\n");
             }
             croak("XPathContext: missing xpath context\n");
         }
         LibXML_configure_xpathcontext(ctxt);
-        if ( !SvOK(func) || 
+        if ( !SvOK(func) ||
              (SvOK(func) && ((SvROK(func) && SvTYPE(SvRV(func)) == SVt_PVCV )
                 || SvPOK(func)))) {
             if (ctxt->funcLookupData == NULL) {
     PPCODE:
         if (SvOK(uri)) {
 	    xmlXPathRegisterFuncNS(ctxt, (xmlChar *) name,
-                                   (xmlChar *) SvPV(uri, len), 
-                                    (SvOK(func) ? 
+                                   (xmlChar *) SvPV(uri, len),
+                                    (SvOK(func) ?
                                     LibXML_generic_extension_function : NULL));
-        } else {    
-            xmlXPathRegisterFunc(ctxt, (xmlChar *) name, 
-                                 (SvOK(func) ? 
+        } else {
+            xmlXPathRegisterFunc(ctxt, (xmlChar *) name,
+                                 (SvOK(func) ?
                                  LibXML_generic_extension_function : NULL));
         }
 
         } else {
             xpath = nodeSv2C(perl_xpath, ctxt->node);
             if ( !(xpath && xmlStrlen(xpath)) ) {
-                if ( xpath ) 
+                if ( xpath )
                     xmlFree(xpath);
                 croak("XPathContext: empty XPath found\n");
                 XSRETURN_UNDEF;
         SPAGAIN ;
 
         if (found != NULL) {
-          nodelist = found->nodesetval;  
+          nodelist = found->nodesetval;
         } else {
           nodelist = NULL;
         }
                 xmlNodePtr tnode;
                 int l = nodelist->nodeNr;
                 for( i = 0  ; i < l; i++){
-                    /* we have to create a new instance of an objectptr. 
-                     * and then place the current node into the new object. 
+                    /* we have to create a new instance of an objectptr.
+                     * and then place the current node into the new object.
                      * afterwards we can push the object to the array!
-                     */ 
+                     */
                     element = NULL;
                     tnode = nodelist->nodeTab[i];
                     if (tnode->type == XML_NAMESPACE_DECL) {
                             /* we try to find a known node on the ancestor axis */
                             xmlNodePtr n = tnode;
                             while (n && n->_private == NULL) n = n->parent;
-                            if (n) owner = PmmOWNERPO(((ProxyNodePtr)n->_private)); 
+                            if (n) owner = PmmOWNERPO(((ProxyNodePtr)n->_private));
                             else owner = NULL; /* self contained node */
                         }
                         element = PmmNodeToSv(tnode, owner);
         } else {
             xpath = nodeSv2C(pxpath, ctxt->node);
             if ( !(xpath && xmlStrlen(xpath)) ) {
-                if ( xpath ) 
+                if ( xpath )
                     xmlFree(xpath);
                 croak("XPathContext: empty XPath found\n");
                 XSRETURN_UNDEF;
                                         /* we try to find a known node on the ancestor axis */
                                         xmlNodePtr n = tnode;
                                         while (n && n->_private == NULL) n = n->parent;
-                                        if (n) owner = PmmOWNERPO(((ProxyNodePtr)n->_private)); 
+                                        if (n) owner = PmmOWNERPO(((ProxyNodePtr)n->_private));
                                         else owner = NULL;  /* self contained node */
                                     }
                                     element = PmmNodeToSv(tnode, owner);
                         }
                     }
                     /* prevent libxml2 from freeing the actual nodes */
-                    if (found->boolval) found->boolval=0;    
+                    if (found->boolval) found->boolval=0;
                     break;
                 case XPATH_BOOLEAN:
                     /* return as a Boolean */
                                   (xmlInputReadCallback) LibXML_input_read,
                                   (xmlInputCloseCallback) LibXML_input_close);
 
-#ifdef HAVE_READER_SUPPORT        
+#ifdef HAVE_READER_SUPPORT
 
 MODULE = XML::LibXML	PACKAGE = XML::LibXML::Reader
 
         xmlFree(result);
     OUTPUT:
 	RETVAL
-	
+
 SV *
 getAttributeNs(reader, localName, namespaceURI)
 	xmlTextReaderPtr reader
     PREINIT:
 	xmlChar *result = NULL;
     CODE:
-	result = xmlTextReaderGetAttributeNs(reader,  (xmlChar*) localName, 
+	result = xmlTextReaderGetAttributeNs(reader,  (xmlChar*) localName,
 					     (xmlChar*) namespaceURI);
 	RETVAL = C2Sv(result, NULL);
         xmlFree(result);
 	RETVAL = xmlTextReaderMoveToAttributeNo(reader, no);
     OUTPUT:
 	RETVAL
-	
+
 int
 moveToAttributeNs(reader, localName, namespaceURI)
 	xmlTextReaderPtr reader
 	char * localName
 	char * namespaceURI = SvOK($arg) ? SvPV_nolen($arg) : NULL;
     CODE:
-	RETVAL = xmlTextReaderMoveToAttributeNs(reader, 
+	RETVAL = xmlTextReaderMoveToAttributeNs(reader,
 						(xmlChar*) localName, (xmlChar*) namespaceURI);
     OUTPUT:
 	RETVAL
 	   croak("Usage: $reader->nextPatternMatch( a-XML::LibXML::Pattern-object )");
 	do {
 	  RETVAL = xmlTextReaderRead(reader);
-          node = xmlTextReaderCurrentNode(reader);	  
+          node = xmlTextReaderCurrentNode(reader);
 	  if (node && xmlPatternMatch(compiled, node)) {
 	    break;
-	  } 
+	  }
 	} while (RETVAL == 1);
         CLEANUP_ERROR_HANDLER;
 	REPORT_ERROR(0);
 _preservePattern(reader,pattern,ns_map=NULL)
 	xmlTextReaderPtr reader
         char * pattern
-        AV * ns_map 
+        AV * ns_map
     PREINIT:
         xmlChar** namespaces = NULL;
 	SV** aux;
           }
 	  namespaces[i]=0;
 	}
-	RETVAL = xmlTextReaderPreservePattern(reader,(const xmlChar*) pattern, 
+	RETVAL = xmlTextReaderPreservePattern(reader,(const xmlChar*) pattern,
 					      (const xmlChar**)namespaces);
         Safefree(namespaces);
     OUTPUT:
     CODE:
 	INIT_ERROR_HANDLER;
 	doc = xmlTextReaderCurrentDoc(reader);
-        if (!doc) { 
+        if (!doc) {
 	  CLEANUP_ERROR_HANDLER;
 	  REPORT_ERROR(0);
 	  XSRETURN_UNDEF;
 	}
         n = 0;
         /* search backwards for beginning-of-line (to max buff size) */
-        while ((n++ < (sizeof(content)-1)) && (cur > base) && 
+        while ((n++ < (sizeof(content)-1)) && (cur > base) &&
 	       (*(cur) != '\n') && (*(cur) != '\r'))
 	  cur--;
 	/* search backwards for beginning-of-line for calculating the
 	n = 0;
 	ctnt = content;
 	/* copy selected text to our buffer */
-	while ((*cur != 0) && (*(cur) != '\n') && 
+	while ((*cur != 0) && (*(cur) != '\n') &&
 	       (*(cur) != '\r') && (n < sizeof(content)-1)) {
 	  *ctnt++ = *cur++;
 	  n++;
 xmlPatternPtr
 _compilePattern(CLASS, ppattern, pattern_type, ns_map=NULL)
         SV * ppattern
-        AV * ns_map 
+        AV * ns_map
 	int pattern_type
     PREINIT:
         xmlChar * pattern = Sv2C(ppattern, NULL);
             /* warn("encode %s", realstring ); */
 #ifdef HAVE_UTF8
             if ( !DO_UTF8(string) && encoding != NULL ) {
-#else 
+#else
             if ( encoding != NULL ) {
 #endif
                 enc = xmlParseCharEncoding( encoding );
-    
+
                 if ( enc == 0 ) {
                     /* this happens if the encoding is "" or NULL */
                     enc = XML_CHAR_ENCODING_UTF8;
                     tstr = xmlStrndup( realstring, len );
                 }
                 else {
-                    INIT_ERROR_HANDLER;                
+                    INIT_ERROR_HANDLER;
                     if ( enc > 1 ) {
                         coder= xmlGetCharEncodingHandler( enc );
                     }
                     else {
                         croak("no encoder found\n");
                     }
-                    if ( coder == NULL ) {  
+                    if ( coder == NULL ) {
                         croak( "cannot encode string" );
                     }
                     in    = xmlBufferCreateStatic((void*)realstring, len );
                     if ( xmlCharEncInFunc( coder, out, in ) >= 0 ) {
                         tstr = xmlStrdup( out->content );
                     }
-        
+
                     xmlBufferFree( in );
                     xmlBufferFree( out );
                     xmlCharEncCloseFunc( coder );
                 croak( "return value missing!" );
             }
 
-            len = xmlStrlen( tstr ); 
+            len = xmlStrlen( tstr );
             RETVAL = newSVpvn( (const char *)tstr, len );
 #ifdef HAVE_UTF8
             SvUTF8_on(RETVAL);
-#endif  
+#endif
             xmlFree(tstr);
         }
         else {
         RETVAL
 
 SV*
-decodeFromUTF8( encoding, string ) 
+decodeFromUTF8( encoding, string )
         const char * encoding
         SV* string
     PREINIT:
         xmlBufferPtr in = NULL, out = NULL;
         xmlCharEncodingHandlerPtr coder = NULL;
 	PREINIT_SAVED_ERROR
-    CODE: 
+    CODE:
 #ifdef HAVE_UTF8
         if ( !SvOK(string) ) {
             XSRETURN_UNDEF;
                     len = xmlStrlen( tstr );
                 }
                 else {
-                    INIT_ERROR_HANDLER;                
+                    INIT_ERROR_HANDLER;
                     if ( enc > 1 ) {
                         coder= xmlGetCharEncodingHandler( enc );
                     }
                         croak("no encoder found\n");
                     }
 
-                    if ( coder == NULL ) {  
+                    if ( coder == NULL ) {
                         croak( "cannot encode string" );
                     }
 
                         len  = xmlBufferLength( out );
                         tstr = xmlCharStrndup( (char*) xmlBufferContent( out ), len );
                     }
-        
+
                     xmlBufferFree( in );
                     xmlBufferFree( out );
                     xmlCharEncCloseFunc( coder );
                 if ( enc == XML_CHAR_ENCODING_UTF8 ) {
                     SvUTF8_on(RETVAL);
                 }
-#endif  
+#endif
             }
             else {
                 XSRETURN_UNDEF;
 Av_CharPtrPtr.h
 Changes
 Devel.xs
+HACKING.txt
+LICENSE
+LibXML.pm
+LibXML.pod
+LibXML.xs
+MANIFEST
+Makefile.PL
+README
+TODO
 debian/changelog
 debian/compat
 debian/control
 docs/libxml.dbk
 dom.c
 dom.h
+example/JBR-ALLENtrees.htm
+example/article.xml
 example/article_bad.xml
 example/article_external_bad.xml
+example/article_internal.xml
 example/article_internal_bad.xml
-example/article_internal.xml
-example/article.xml
 example/bad.dtd
 example/bad.xml
 example/catalog.xml
 example/cb_example.pl
-example/complex/complex2.xml
 example/complex/complex.dtd
 example/complex/complex.xml
+example/complex/complex2.xml
 example/complex/dtd/f.dtd
 example/complex/dtd/g.dtd
 example/dromeds.xml
 example/enc2_latin2.html
 example/enc_latin2.html
 example/ext_ent.dtd
-example/JBR-ALLENtrees.htm
 example/ns.xml
-example/test2.xml
-example/test3.xml
-example/test4.xml
 example/test.dtd
 example/test.html
 example/test.xhtml
 example/test.xml
+example/test2.xml
+example/test3.xml
+example/test4.xml
 example/thedieline.rss
 example/utf-16-1.html
 example/utf-16-2.html
 example/xmlns/goodguy.xml
 example/xpath.pl
 example/yahoo-finance-html-with-errors.html
-HACKING.txt
 lib/XML/LibXML/Attr.pod
 lib/XML/LibXML/AttributeHash.pm
 lib/XML/LibXML/Boolean.pm
 lib/XML/LibXML/Comment.pod
 lib/XML/LibXML/Common.pm
 lib/XML/LibXML/Common.pod
+lib/XML/LibXML/DOM.pod
+lib/XML/LibXML/Devel.pm
+lib/XML/LibXML/Document.pod
 lib/XML/LibXML/DocumentFragment.pod
-lib/XML/LibXML/Document.pod
-lib/XML/LibXML/Devel.pm
-lib/XML/LibXML/DOM.pod
 lib/XML/LibXML/Dtd.pod
 lib/XML/LibXML/Element.pod
 lib/XML/LibXML/ErrNo.pm
 lib/XML/LibXML/InputCallback.pod
 lib/XML/LibXML/Literal.pm
 lib/XML/LibXML/Namespace.pod
+lib/XML/LibXML/Node.pod
 lib/XML/LibXML/NodeList.pm
-lib/XML/LibXML/Node.pod
 lib/XML/LibXML/Number.pm
+lib/XML/LibXML/PI.pod
 lib/XML/LibXML/Parser.pod
 lib/XML/LibXML/Pattern.pod
-lib/XML/LibXML/PI.pod
 lib/XML/LibXML/Reader.pm
 lib/XML/LibXML/Reader.pod
 lib/XML/LibXML/RegExp.pod
 lib/XML/LibXML/RelaxNG.pod
+lib/XML/LibXML/SAX.pm
+lib/XML/LibXML/SAX.pod
 lib/XML/LibXML/SAX/Builder.pm
 lib/XML/LibXML/SAX/Builder.pod
 lib/XML/LibXML/SAX/Generator.pm
 lib/XML/LibXML/SAX/Parser.pm
-lib/XML/LibXML/SAX.pm
-lib/XML/LibXML/SAX.pod
 lib/XML/LibXML/Schema.pod
 lib/XML/LibXML/Text.pod
 lib/XML/LibXML/XPathContext.pm
 lib/XML/LibXML/XPathContext.pod
 lib/XML/LibXML/XPathExpression.pod
-LibXML.pm
-LibXML.pod
-LibXML.xs
-LICENSE
-Makefile.PL
-MANIFEST
 perl-libxml-mm.c
 perl-libxml-mm.h
 perl-libxml-sax.c
 perl-libxml-sax.h
 ppport.h
-README
+scripts/Test.pm-to-Test-More.pl
 scripts/bump-version-number.pl
 scripts/fast-eumm.pl
 scripts/prints-to-comments.pl
 scripts/tag-release.pl
 scripts/update-HACKING-file.bash
-scripts/Test.pm-to-Test-More.pl
 t/01basic.t
 t/02parse.t
 t/03doc.t
 t/45regex.t
 t/46err_column.t
 t/47load_xml_callbacks.t
+t/48_rt55000.t
 t/48importing_nodes_IDs_rt_69520.t
-t/48_rt55000.t
+t/49_load_html.t
 t/49callbacks_returning_undef.t
 t/49global_extent.t
-t/49_load_html.t
 t/50devel.t
 t/60error_prev_chain.t
 t/60struct_error.t
 t/80registryleak.t
 t/90threads.t
 t/data/callbacks_returning_undef.xml
+t/lib/Collector.pm
+t/lib/Counter.pm
+t/lib/Stacker.pm
+t/lib/TestHelpers.pm
+t/pod.t
+t/style-trailing-space.t
 test/relaxng/badschema.rng
+test/relaxng/demo.rng
+test/relaxng/demo.xml
 test/relaxng/demo2.rng
 test/relaxng/demo3.rng
 test/relaxng/demo4.rng
-test/relaxng/demo.rng
-test/relaxng/demo.xml
 test/relaxng/invaliddemo.xml
 test/relaxng/schema.rng
 test/schema/badschema.xsd
 test/xinclude/entity.txt
 test/xinclude/test.xml
 test/xinclude/xinclude.xml
-t/lib/Collector.pm
-t/lib/Counter.pm
-t/lib/Stacker.pm
-t/lib/TestHelpers.pm
-TODO
-t/pod.t
 typemap
 xpath.c
+xpath.h
 xpathcontext.h
-xpath.h
 /* #define warn(string) fprintf(stderr, string) */
 
 #ifdef XS_WARNINGS
-#define xs_warn(string) warn("%s",string) 
+#define xs_warn(string) warn("%s",string)
 #else
 #define xs_warn(string)
 #endif
 }
 
 /* ns->next must be NULL, or bad things could happen */
-xmlNsPtr 
+xmlNsPtr
 _domAddNsChain(xmlNsPtr c, xmlNsPtr ns)
 {
         if( c == NULL )
         if( attr->ns != NULL )
         {
 		xmlNsPtr ns;
-		if ((attr->ns->prefix != NULL) && 
+		if ((attr->ns->prefix != NULL) &&
 		    (xmlStrEqual(attr->ns->prefix, BAD_CAST "xml"))) {
 			/* prefix 'xml' has no visible declaration */
 			ns = xmlSearchNsByHref(tree->doc, tree, XML_XML_NAMESPACE);
                         if( domRemoveNsDef(tree, tree->ns) )
                                 /* Queue the namespace for freeing */
                                 *unused = _domAddNsChain(*unused, tree->ns);
-                
+
                         /* Replace the namespace with the one found */
                         tree->ns = ns;
                 }
         if( tree->type == XML_ELEMENT_NODE )
         {
                 xmlElementPtr ele = (xmlElementPtr) tree;
-                /* attributes is set to xmlAttributePtr, 
+                /* attributes is set to xmlAttributePtr,
                    but is an xmlAttrPtr??? */
                 xmlAttrPtr attr = (xmlAttrPtr) ele->attributes;
                 while( attr != NULL )
         {
           /* Recurse through all child nodes */
           xmlNodePtr child = tree->children;
-          while( child != NULL ) 
+          while( child != NULL )
           {
               _domReconcileNs(child, unused);
               child = child->next;
  * character is -1!
  */
 int
-domParseChar( xmlChar *cur, int *len ) 
+domParseChar( xmlChar *cur, int *len )
 {
     unsigned char c;
         unsigned int val;
          * UCS-4 range (hex.)           UTF-8 octet sequence (binary)
          * 0000 0000-0000 007F   0xxxxxxx
          * 0000 0080-0000 07FF   110xxxxx 10xxxxxx
-         * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx 
+         * 0000 0800-0000 FFFF   1110xxxx 10xxxxxx 10xxxxxx
          *
          * Check for the 0x110000 limit too
          */
-    
+
     if ( cur == NULL || *cur == 0 ) {
         *len = 0;
         return(0);
     }
-    
+
     c = *cur;
-    if ( c & 0x80 ) { 
+    if ( c & 0x80 ) {
         if ((c & 0xe0) == 0xe0) {
             if ((c & 0xf0) == 0xf0) {
                 /* 4-byte code */
     else {
         /* 1-byte code */
             *len = 1;
-        return((int)c); 
+        return((int)c);
     }
 }
 
  * @doc: the document, the string should belong to
  * @string: the string to parse
  *
- * this function is pretty neat, since you can read in well balanced 
+ * this function is pretty neat, since you can read in well balanced
  * strings and get a list of nodes, which can be added to any other node.
  * (sure - this should return a doucment_fragment, but still it doesn't)
  *
- * the code is pretty heavy i think, but deep in my heard i believe it's 
- * worth it :) (e.g. if you like to read a chunk of well-balanced code 
+ * the code is pretty heavy i think, but deep in my heard i believe it's
+ * worth it :) (e.g. if you like to read a chunk of well-balanced code
  * from a databasefield)
  *
  * in 99% the cases i believe it is faster than to create the dom by hand,
  *
  * the repair flag will not be recognized with the current libxml2
  **/
-xmlNodePtr 
+xmlNodePtr
 domReadWellBalancedString( xmlDocPtr doc, xmlChar* block, int repair ) {
     int retCode       = -1;
     xmlNodePtr nodes  = NULL;
-    
+
     if ( block ) {
         /* read and encode the chunk */
-        retCode = xmlParseBalancedChunkMemory( doc, 
+        retCode = xmlParseBalancedChunkMemory( doc,
                                                NULL,
                                                NULL,
                                                0,
 
         /* error handling */
         if ( retCode != 0 && repair == 0 ) {
-            /* if the code was not well balanced, we will not return 
+            /* if the code was not well balanced, we will not return
              * a bad node list, but we have to free the nodes */
             xmlFreeNodeList( nodes );
             nodes = NULL;
     return nodes;
 }
 
-/** 
+/**
  * internal helper: insert node to nodelist
  * synopsis: xmlNodePtr insert_node_to_nodelist( leader, insertnode, followup );
  * while leader and followup are already list nodes. both may be NULL
  * the first node of the list will returned
  *
  * i ran into a misconception here. there should be a normalization function
- * for the DOM, so sequences of text nodes can get replaced by a single 
+ * for the DOM, so sequences of text nodes can get replaced by a single
  * text node. as i see DOM Level 1 does not allow text node sequences, while
  * Level 2 and 3 do.
  **/
 int
-domAddNodeToList(xmlNodePtr cur, xmlNodePtr leader, xmlNodePtr followup) 
+domAddNodeToList(xmlNodePtr cur, xmlNodePtr leader, xmlNodePtr followup)
 {
    xmlNodePtr c1 = NULL, c2 = NULL, p = NULL;
-   if ( cur ) { 
+   if ( cur ) {
        c1 = c2 = cur;
        if( leader ) {
           p = leader->parent;
            while ( c1 ){
                c1->parent = p;
                c1 = c1->next;
-           }  
+           }
            c1 = cur->children;
            c2 = cur->last;
            cur->last = cur->children = NULL;
        else {
            cur->parent = p;
        }
-       
+
        if (c1 && c2 && c1!=leader) {
            if ( leader ) {
                leader->next = c1;
            else if ( p ) {
                p->children = c1;
            }
-           
+
            if ( followup ) {
                followup->prev = c2;
                c2->next = followup;
            }
        }
        return 1;
-   }    
+   }
    return 0;
 }
 
 }
 
 int
-domTestHierarchy(xmlNodePtr cur, xmlNodePtr refNode) 
+domTestHierarchy(xmlNodePtr cur, xmlNodePtr refNode)
 {
     if ( !refNode || !cur ) {
         return 0;
     default:
         break;
     }
-    
+
     if ( domIsParent( cur, refNode ) ) {
         return 0;
     }
     }
 
 
-    /* tell all children about the new boss */ 
+    /* tell all children about the new boss */
     if ( node && node->doc != doc ) {
         /* if the source document contained psvi, mark the current document as psvi tainted */
         if (PmmIsPSVITainted(node->doc))
         xmlSetTreeDoc(return_node, doc);
     }
 
-    if ( reconcileNS && doc && return_node 
+    if ( reconcileNS && doc && return_node
          && return_node->type != XML_ENTITY_REF_NODE ) {
                 domReconcileNs(return_node);
     }
  * Synopsis: string = domName( node );
  *
  * domName returns the full name for the current node.
- * If the node belongs to a namespace it returns the prefix and 
+ * If the node belongs to a namespace it returns the prefix and
  * the local name. otherwise only the local name is returned.
  **/
 xmlChar*
 domName(xmlNodePtr node) {
     const xmlChar *prefix = NULL;
     const xmlChar *name   = NULL;
-    xmlChar *qname        = NULL; 
-    
+    xmlChar *qname        = NULL;
+
     if ( node == NULL ) {
         return NULL;
     }
         qname = xmlStrdup( prefix );
         qname = xmlStrcat( qname , (const xmlChar *) ":" );
         qname = xmlStrcat( qname , name );
-    } 
+    }
     else {
         qname = xmlStrdup( name );
     }
  * @newCld: the node to append
  *
  * Returns newCld on success otherwise NULL
- * The function will unbind newCld first if nesseccary. As well the 
- * function will fail, if par or newCld is a Attribute Node OR if newCld 
- * is a parent of par. 
- * 
- * If newCld belongs to a different DOM the node will be imported 
- * implicit before it gets appended. 
+ * The function will unbind newCld first if nesseccary. As well the
+ * function will fail, if par or newCld is a Attribute Node OR if newCld
+ * is a parent of par.
+ *
+ * If newCld belongs to a different DOM the node will be imported
+ * implicit before it gets appended.
  **/
 xmlNodePtr
 domAppendChild( xmlNodePtr self,
 
     if ( !(domTestHierarchy(self, newChild)
            && domTestDocument(self, newChild))){
-        croak("appendChild: HIERARCHY_REQUEST_ERR\n"); 
+        croak("appendChild: HIERARCHY_REQUEST_ERR\n");
         return NULL;
     }
 
     if ( newChild->doc == self->doc ){
-        domUnlinkNode( newChild ); 
+        domUnlinkNode( newChild );
     }
     else {
-        xs_warn("WRONG_DOCUMENT_ERR - non conform implementation\n"); 
+        xs_warn("WRONG_DOCUMENT_ERR - non conform implementation\n");
         /* xmlGenericError(xmlGenericErrorContext,"WRONG_DOCUMENT_ERR\n"); */
         newChild = domImportNode( self->doc, newChild, 1, 0 );
     }
- 
+
     if ( self->children != NULL ) {
         if (newChild->type == XML_DOCUMENT_FRAG_NODE )
             fragment = newChild->children;
         while ( c1 ){
             c1->parent = self;
             c1 = c1->next;
-        }  
+        }
         self->last = newChild->last;
         newChild->last = newChild->children = NULL;
     }
         self->last     = newChild;
         newChild->parent= self;
     }
- 
+
     if ( fragment ) {
         /* we must reconcile all nodes in the fragment */
         newChild = fragment; /* return the first node in the fragment */
         return NULL;
     }
 
-    domUnlinkNode( old );    
+    domUnlinkNode( old );
         if ( old->type == XML_ELEMENT_NODE ) {
                 domReconcileNs( old );
         }
 xmlNodePtr
 domReplaceChild( xmlNodePtr self, xmlNodePtr new, xmlNodePtr old ) {
     xmlNodePtr fragment = NULL;
-    xmlNodePtr fragment_next = NULL;    
+    xmlNodePtr fragment_next = NULL;
     if ( self== NULL )
         return NULL;
 
-    if ( new == old ) 
+    if ( new == old )
         return new;
- 
+
     if ( new == NULL ) {
         /* level2 sais nothing about this case :( */
         return domRemoveChild( self, old );
         croak("replaceChild: HIERARCHY_REQUEST_ERR\n");
         return NULL;
     }
-    
+
     if ( new->doc == self->doc ) {
         domUnlinkNode( new );
     }
         /* WRONG_DOCUMENT_ERR - non conform implementation */
         new = domImportNode( self->doc, new, 1, 1 );
     }
-    
+
     if( old == self->children && old == self->last ) {
         domRemoveChild( self, old );
         domAppendChild( self, new );
     }
-    else if ( new->type == XML_DOCUMENT_FRAG_NODE 
+    else if ( new->type == XML_DOCUMENT_FRAG_NODE
               && new->children == NULL ) {
         /* want to replace with an empty fragment, then remove ... */
         fragment = new->children;
     }
     else {
         domAddNodeToList(new, old->prev, old->next );
-        old->parent = old->next = old->prev = NULL;    
+        old->parent = old->next = old->prev = NULL;
     }
     if ( fragment ) {
         while ( fragment && fragment != fragment_next ) {
 
 
 xmlNodePtr
-domInsertBefore( xmlNodePtr self, 
+domInsertBefore( xmlNodePtr self,
                  xmlNodePtr newChild,
                  xmlNodePtr refChild ){
     xmlNodePtr fragment = NULL;
     if ( refChild == newChild ) {
         return newChild;
     }
-    
+
     if ( self == NULL || newChild == NULL ) {
         return NULL;
     }
 
     if ( refChild != NULL ) {
         if ( refChild->parent != self
-             || (  newChild->type     == XML_DOCUMENT_FRAG_NODE 
+             || (  newChild->type     == XML_DOCUMENT_FRAG_NODE
                    && newChild->children == NULL ) ) {
             /* NOT_FOUND_ERR */
             xmlGenericError(xmlGenericErrorContext,"NOT_FOUND_ERR\n");
     if ( self->children == NULL ) {
         return domAppendChild( self, newChild );
     }
-   
+
     if ( !(domTestHierarchy( self, newChild )
            && domTestDocument( self, newChild ))) {
         croak("insertBefore/insertAfter: HIERARCHY_REQUEST_ERR\n");
     else {
         newChild = domImportNode( self->doc, newChild, 1, 0 );
     }
-    
+
     if ( newChild->type == XML_DOCUMENT_FRAG_NODE ) {
       fragment = newChild->children;
     }
     if ( refChild == NULL ) {
         domAddNodeToList(newChild, self->last, NULL);
     }
-    else { 
+    else {
         domAddNodeToList(newChild, refChild->prev, refChild);
     }
-    
+
     if ( fragment ) {
         newChild = fragment; /* return the first node in the fragment */
         while ( fragment && fragment != refChild ) {
  * this function does not exist in the spec although it's useful
  */
 xmlNodePtr
-domInsertAfter( xmlNodePtr self, 
+domInsertAfter( xmlNodePtr self,
                 xmlNodePtr newChild,
                 xmlNodePtr refChild ){
     if ( refChild == NULL ) {
 xmlNodePtr
 domReplaceNode( xmlNodePtr oldNode, xmlNodePtr newNode ) {
     xmlNodePtr prev = NULL, next = NULL, par = NULL, fragment = NULL;
-    
+
     if ( oldNode == NULL
          || newNode == NULL ) {
         /* NOT_FOUND_ERROR */
         return NULL;
-    } 
+    }
 
     if ( oldNode->type == XML_ATTRIBUTE_NODE
          || newNode->type == XML_ATTRIBUTE_NODE
         croak("replaceNode: HIERARCHY_REQUEST_ERR\n");
         return NULL;
     }
-        
+
     par  = oldNode->parent;
     prev = oldNode->prev;
     next = oldNode->next;
     }
     if( prev == NULL && next == NULL ) {
         /* oldNode was the only child */
-        domAppendChild( par , newNode ); 
+        domAppendChild( par , newNode );
     }
     else {
         domAddNodeToList( newNode, prev,  next );
 
 void
 domSetNodeValue( xmlNodePtr n , xmlChar* val ){
-    if ( n == NULL ) 
+    if ( n == NULL )
         return;
     if ( val == NULL ){
         val = (xmlChar *) "";
     }
-  
+
     if( n->type == XML_ATTRIBUTE_NODE ){
       /* can't use xmlNodeSetContent - for Attrs it parses entities */
         if ( n->children != NULL ) {
         n->children = xmlNewText( val );
         n->children->parent = n;
         n->children->doc = n->doc;
-        n->last = n->children; 
+        n->last = n->children;
     }
     else {
         xmlNodeSetContent( n, val );
             cld = cld->next;
         }
     }
-  
+
     return rv;
 }
 
     if ( nsURI == NULL ) {
         return domGetElementsByTagName( n, name );
     }
-  
+
     if ( n != NULL && name != NULL  ) {
         xmlNodePtr cld = n->children;
         while ( cld != NULL ) {
-            if ( xmlStrcmp( name, cld->name ) == 0 
+            if ( xmlStrcmp( name, cld->name ) == 0
                  && cld->ns != NULL
                  && xmlStrcmp( nsURI, cld->ns->href ) == 0  ){
                 if ( rv == NULL ) {
             cld = cld->next;
         }
     }
-  
+
     return rv;
 }
 
 xmlNsPtr
 domNewNs ( xmlNodePtr elem , xmlChar *prefix, xmlChar *href ) {
     xmlNsPtr ns = NULL;
-  
+
     if (elem != NULL) {
         ns = xmlSearchNs( elem->doc, elem, prefix );
     }
     }
 }
 
-xmlAttrPtr 
+xmlAttrPtr
 domSetAttributeNode( xmlNodePtr node, xmlAttrPtr attr ) {
     if ( node == NULL || attr == NULL ) {
         return attr;
         return NULL;
     if ( node == attr->parent ) {
         return attr; /* attribute is already part of the node */
-    }  
+    }
     if ( attr->doc != node->doc ){
-        attr = (xmlAttrPtr) domImportNode( node->doc, (xmlNodePtr) attr, 1, 1 ); 
-    } 
+        attr = (xmlAttrPtr) domImportNode( node->doc, (xmlNodePtr) attr, 1, 1 );
+    }
     else {
         xmlUnlinkNode( (xmlNodePtr) attr );
     }
             node->properties = attr;
         } else {
             xmlAttrPtr prev = node->properties;
-            
+
             while (prev->next != NULL) prev = prev->next;
             prev->next = attr;
             attr->prev = prev;
 {
     xmlNodePtr next = NULL;
 
-    if ( node == NULL ) 
+    if ( node == NULL )
         return(0);
 
     switch ( node->type ) {
         break;
     default:
         break;
-    }    
+    }
     return(1);
 }
 
                 }
             }
             /* exit condition */
-            if (node == tree) 
+            if (node == tree)
                 node = NULL;
         } else
             break;
 /* dom.h
  * $Id$
  * Author: Christian Glahn (2001)
- * 
+ *
  * This header file provides some definitions for wrapper functions.
  * These functions hide most of libxml2 code, and should make the
- * code in the XS file more readable . 
+ * code in the XS file more readable .
  *
  * The Functions are sorted in four parts:
- * part 0 ..... general wrapper functions which do not belong 
- *              to any of the other parts and not specified in DOM. 
+ * part 0 ..... general wrapper functions which do not belong
+ *              to any of the other parts and not specified in DOM.
  * part A ..... wrapper functions for general nodeaccess
- * part B ..... document wrapper 
+ * part B ..... document wrapper
  * part C ..... element wrapper
- * 
+ *
  * I did not implement any Text, CDATASection or comment wrapper functions,
- * since it is pretty straightforeward to access these nodes. 
+ * since it is pretty straightforeward to access these nodes.
  */
 
 #ifndef __LIBXML_DOM_H__
 /**
  * part 0:
  *
- * unsortet. 
+ * unsortet.
  **/
 
 void
 int
 domParseChar( xmlChar *characters, int *len );
 
-xmlNodePtr 
+xmlNodePtr
 domReadWellBalancedString( xmlDocPtr doc, xmlChar* string, int repair );
 
 /**
  *
  * SYNOPSIS
  * if ( domIsParent(cur, ref) ) ...
- * 
- * this function is very useful to resolve if an operation would cause 
+ *
+ * this function is very useful to resolve if an operation would cause
  * circular references.
  *
  * the function returns 1 if the ref node is a parent of the cur node.
  * SYNOPSIS
  * if ( domTestHierarchy(cur, ref) ) ...
  *
- * this function tests the general hierarchy error.   
- * it tests if the ref node would cause any hierarchical error for 
+ * this function tests the general hierarchy error.
+ * it tests if the ref node would cause any hierarchical error for
  * cur node. the function evaluates domIsParent() internally.
- * 
- * the function will retrun 1 if there is no hierarchical error found. 
+ *
+ * the function will retrun 1 if there is no hierarchical error found.
  * otherwise it returns 0.
- */ 
+ */
 int
 domTestHierarchy( xmlNodePtr cur, xmlNodePtr ref );
 
 * SYNOPSIS
 * domAddNodeToList( cur, prevNode, nextNode )
 *
-* This function inserts a node between the two nodes prevNode 
+* This function inserts a node between the two nodes prevNode
 * and nextNode. prevNode and nextNode MUST be adjacent nodes,
 * otherwise the function leads into undefined states.
-* Either prevNode or nextNode can be NULL to mark, that the 
-* node has to be inserted to the beginning or the end of the 
-* nodelist. in such case the given reference node has to be 
-* first or the last node in the list. 
+* Either prevNode or nextNode can be NULL to mark, that the
+* node has to be inserted to the beginning or the end of the
+* nodelist. in such case the given reference node has to be
+* first or the last node in the list.
 *
-* if prevNode is the same node as cur node (or in case of a 
-* Fragment its first child) only the parent information will 
+* if prevNode is the same node as cur node (or in case of a
+* Fragment its first child) only the parent information will
 * get updated.
-* 
+*
 * The function behaves different to libxml2's list functions.
-* The function is aware about document fragments. 
+* The function is aware about document fragments.
 * the function does not perform any text node normalization!
 *
-* NOTE: this function does not perform any highlevel 
+* NOTE: this function does not perform any highlevel
 * errorhandling. use this function with caution, since it can
 * lead into undefined states.
-* 
-* the function will return 1 if the cur node is appended to 
+*
+* the function will return 1 if the cur node is appended to
 * the list. otherwise the function returns 0.
 */
 int
 domRemoveChild( xmlNodePtr self,
                xmlNodePtr Child );
 xmlNodePtr
-domInsertBefore( xmlNodePtr self, 
+domInsertBefore( xmlNodePtr self,
                  xmlNodePtr newChild,
                  xmlNodePtr refChild );
 
 xmlNodePtr
-domInsertAfter( xmlNodePtr self, 
+domInsertAfter( xmlNodePtr self,
                 xmlNodePtr newChild,
                 xmlNodePtr refChild );
 
 xmlNodePtr
 domReplaceNode( xmlNodePtr old, xmlNodePtr new );
 
-/** 
+/**
  * part B:
  *
  * class Document
  * node = domImportNode( document, node, move, reconcileNS);
  *
  * the function will import a node to the given document. it will work safe
- * with namespaces and subtrees. 
+ * with namespaces and subtrees.
  *
- * if move is set to 1, then the node will be entirely removed from its 
- * original document. if move is set to 0, the node will be copied with the 
- * deep option. 
+ * if move is set to 1, then the node will be entirely removed from its
+ * original document. if move is set to 0, the node will be copied with the
+ * deep option.
  *
  * if reconcileNS is 1, namespaces are reconciled.
  *
  * the function will return the imported node on success. otherwise NULL
- * is returned 
+ * is returned
  */
 xmlNodePtr
 domImportNode( xmlDocPtr document, xmlNodePtr node, int move, int reconcileNS );

example/cb_example.pl

     if ( not $handler->open( "<$uri" ) ){
         $handler = 0;
     }
-    
+
     return $handler;
 }
 

example/xmllibxmldocs.pl

         my $dir = $self->{directory};
 
         $filename =~ s/XML\:\:LibXML//g;
-        $filename =~ s/^-|^\:\://g;   # remove the first colon or minus. 
+        $filename =~ s/^-|^\:\://g;   # remove the first colon or minus.
         $filename =~ s/\:\:/\//g;     # transform remaining colons to paths.
         # the previous statement should work for existing modules. This could be
         # dangerous for nested modules, which do not exist at the time of writing
             my $str = $title->string_value();
             my $len = length $str;
 
-            $self->{OFILE}->print( "\n" . uc($str) . "\n" ); 
+            $self->{OFILE}->print( "\n" . uc($str) . "\n" );
             $self->{OFILE}->print( "=" x $len );
             $self->{OFILE}->print( "\n\n" );
             $self->dump_text( $node );

lib/XML/LibXML/Devel.pm

 # This is free software, you may use it and distribute it under the same terms as
 # Perl itself.
 #
-# Copyright 2011 Joachim Zobel 
+# Copyright 2011 Joachim Zobel
 #
 package XML::LibXML::Devel;
 
 # This allows declaration	use XML::LibXML::Devel ':all';
 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
 # will save memory.
-our %EXPORT_TAGS = ( 'all' => [ qw(	
+our %EXPORT_TAGS = ( 'all' => [ qw(
   node_to_perl
   node_from_perl
   refcnt_inc
 XML::LibXML::Devel - makes functions from LibXML.xs available
 
 =head1 SYNOPSIS
-  
+
   /**********************************************
    * C functions you want to access
    */
   # Perl code
   use XML::LibXML::Devel;
 
-  sub return_node 
+  sub return_node
   {
     my $raw_node = xs_return_node();
     my $node = XML::LibXML::Devel::node_to_perl($raw_node);
     return $node;
   }
 
-  sub receive_node 
+  sub receive_node
   {
     my ($node) = @_;