Commits

Anonymous committed 6bc6896

Modified Files:
LibXML.xs perl-libxml-mm.c perl-libxml-sax.c dom.c
code cleanings (mainly type casts)
(no warnings with solaris 8 and cc (!= gcc))

  • Participants
  • Parent commits bfab9f4

Comments (0)

Files changed (4)

 
     return; 
 
-    xmlRegisterInputCallbacks((xmlInputMatchCallback) LibXML_input_match,
-                              (xmlInputOpenCallback) LibXML_input_open,
-                              (xmlInputReadCallback) LibXML_input_read,
-                              (xmlInputCloseCallback) LibXML_input_close);
+/*    xmlRegisterInputCallbacks((xmlInputMatchCallback) LibXML_input_match,*/
+/*                              (xmlInputOpenCallback) LibXML_input_open, */
+/*                              (xmlInputReadCallback) LibXML_input_read, */
+/*                              (xmlInputCloseCallback) LibXML_input_close); */
 
 
 
 LibXML_cleanup_callbacks() {
     
     return;
-    xs_warn("      cleanup parser callbacks!\n"); 
-
-    xmlCleanupInputCallbacks();
-    xmlRegisterDefaultInputCallbacks();
+/*    xs_warn("      cleanup parser callbacks!\n"); */
+
+/*    xmlCleanupInputCallbacks(); */
+/*    xmlRegisterDefaultInputCallbacks(); */
 /*    if ( LibXML_old_ext_ent_loader != NULL ) { */
 /*        xmlSetExternalEntityLoader( NULL ); */
 /*        xmlSetExternalEntityLoader( LibXML_old_ext_ent_loader ); */
     PREINIT:
         xmlParserCtxtPtr ctxt = NULL;
         STRLEN len = 0;
-        xmlChar * ptr = NULL;
+        char * ptr = NULL;
         int well_formed;
         int valid;
         int ret;
         HV* real_obj = (HV *)SvRV(self);
         SV** item    = NULL;
         int recover ;
-        xmlChar * directory = NULL;
+        char * directory = NULL;
     CODE:
         ptr = SvPV(string, len);        
         if (len == 0) {
         }
   
         LibXML_init_parser(self);
-        ctxt = xmlCreateMemoryParserCtxt(ptr, len);
+        ctxt = xmlCreateMemoryParserCtxt((const char*)ptr, len);
         if (ctxt == NULL) {
             croak("Couldn't create memory parser context: %s", strerror(errno));
         }
 
-        directory = Sv2C( dir, NULL );
+        directory = (char*)Sv2C( dir, NULL );
 
         xs_warn( "context created\n");
 
         }
         
         LibXML_init_parser(self);
-        real_doc = (xmlDocPtr) docbParseDoc((xmlChar*)ptr,
-                                            Sv2C(encoding, NULL));
+        real_doc = (xmlDocPtr) docbParseDoc((xmlChar *)ptr,
+                                            (const char *)Sv2C(encoding, NULL));
 
         LibXML_cleanup_callbacks();
         LibXML_cleanup_parser();        
     CODE:
         LibXML_init_parser(self);
         real_doc = (xmlDocPtr) docbParseFile(filename,
-                                             Sv2C(encoding, NULL));
+                                             (const char *) Sv2C(encoding, NULL));
         LibXML_cleanup_callbacks();
         LibXML_cleanup_parser();
 
         SV * fn
         SV * enc
     PREINIT:
-        const char * filename = Sv2C(fn, NULL);  
-        const char * encoding = Sv2C(enc, NULL);
+        const char * filename = (const char *)Sv2C(fn, NULL);  
+        const char * encoding = (const char *)Sv2C(enc, NULL);
         xmlParserCtxtPtr ctxt;
         STRLEN len;
     CODE:
     PREINIT:
         xmlParserCtxtPtr ctxt = NULL;
         STRLEN len = 0;
-        xmlChar * chunk = NULL;
+        char * chunk = NULL;
     INIT:
         ctxt = PmmSvContext( pctxt );
         if ( ctxt == NULL ) {
         }
 /*        LibXML_init_error(); */
         LibXML_init_parser(self);
-        xmlParseChunk(ctxt, chunk, len, 0);
+        xmlParseChunk(ctxt, (const char *)chunk, len, 0);
         LibXML_cleanup_callbacks();
         LibXML_cleanup_parser();
     
         SV * self
         SV * filename
     PREINIT:
-        const char * fn = Sv2C(filename, NULL);
+        const char * fn = (const char *) Sv2C(filename, NULL);
     INIT:
-        if ( fn == NULL || xmlStrlen( fn ) == 0 ) {
+        if ( fn == NULL || xmlStrlen( (xmlChar *)fn ) == 0 ) {
             croak( "cannot load catalog" );
         }
     CODE:
         xmlRegisterDefaultOutputCallbacks();
         encoding = (self)->encoding;
         if ( encoding != NULL ) {
-            if ( xmlParseCharEncoding(encoding) != XML_CHAR_ENCODING_UTF8) {
-                handler = xmlFindCharEncodingHandler(encoding);
+            if ( xmlParseCharEncoding((const char*)encoding) != XML_CHAR_ENCODING_UTF8) {
+                handler = xmlFindCharEncodingHandler((const char*)encoding);
             }
 
         }
 
         RETVAL = xmlSaveFormatFileTo( buffer, 
                                       self,
-                                      encoding,
+                                      (const char *) encoding,
                                       format);
 
         if ( intSubset != NULL ) {
         xmlDocPtr self
     PREINIT:
         xmlChar *result=NULL;
-        int len=0;
+        STRLEN len = 0;
     CODE:
         xs_warn( "use no formated toString!" );
         LibXML_init_error();
-        htmlDocDumpMemory(self, &result, &len);
+        htmlDocDumpMemory(self, &result, (int*)&len);
 
         sv_2mortal( LibXML_error );
         LibXML_croak_error();
 URI( self )
         xmlDocPtr self
     CODE:
-        RETVAL = xmlStrdup(self->URL );
+        RETVAL = (const char*)xmlStrdup(self->URL );
     OUTPUT:
         RETVAL
 
     PREINIT:
         xmlDocPtr doc=NULL;
     CODE:
-        doc = xmlNewDoc(version);
-        if (encoding && *encoding!=0) {
-            doc->encoding = xmlStrdup(encoding);
+        doc = xmlNewDoc((const xmlChar*)version);
+        if (encoding && *encoding != 0) {
+            doc->encoding = (const xmlChar*)xmlStrdup((const xmlChar*)encoding);
         }
         RETVAL = PmmNodeToSv((xmlNodePtr)doc,NULL);
     OUTPUT:
         XML::LibXML::Document::getEncoding    = 1
         XML::LibXML::Document::actualEncoding = 2
     CODE:
-        RETVAL = xmlStrdup((xmlChar*)self->encoding );
+        RETVAL = (char*)xmlStrdup(self->encoding );
     OUTPUT:
         RETVAL
 
         xmlDocPtr self
         char *encoding
     CODE:
-        self->encoding = xmlStrdup( encoding );
+        self->encoding = xmlStrdup( (const xmlChar *)encoding );
 
 int
 standalone( self ) 
     ALIAS:
         XML::LibXML::Document::getVersion = 1
     CODE:
-        RETVAL = xmlStrdup(self->version );
+        RETVAL = (char*)xmlStrdup(self->version );
     OUTPUT:
         RETVAL
 
         xmlDocPtr self
         char *version
     CODE:
-        self->version = xmlStrdup( version );
+        self->version = xmlStrdup( (const xmlChar*)version );
 
 int
 compression( self )
         XML::LibXML::Node::getName = 1
         XML::LibXML::Element::tagName = 2
     PREINIT:
-        char * name = NULL;
+        xmlChar * name = NULL;
     INIT:
         if( self->name == NULL ) {
             croak( "lost the name!?" );
         }
     CODE:
-        name =  domName( self );
+        name =  (xmlChar*)domName( self );
         RETVAL = C2Sv(name,NULL);
         xmlFree( name );
     OUTPUT:
         int format
     PREINIT:
         xmlBufferPtr buffer;
-        char *ret = NULL;
+        xmlChar *ret = NULL;
         SV* internalFlag = NULL;
         int oldTagFlag = xmlSaveNoEmptyTags;
     CODE:
         xmlXPathObjectPtr found = NULL;
         xmlNodeSetPtr nodelist = NULL;
         SV* element = NULL ;
-        int len = 0 ;
+        STRLEN len = 0 ;
         xmlChar * xpath = nodeSv2C(pxpath, node);
     INIT:
         if ( node == NULL ) {
         ProxyNodePtr owner = NULL;
         xmlNodeSetPtr nodelist = NULL;
         SV * element = NULL ;
-        int len = 0 ;
+        STRLEN len = 0 ;
         xmlChar * xpath = nodeSv2C(perl_xpath, node);
     INIT:
         if ( node == NULL ) {
         ProxyNodePtr docfrag;
     CODE:
         docfrag = PmmNewFragment(NULL);
-        newNode = xmlNewNode( NULL, name );
+        newNode = xmlNewNode( NULL, (const xmlChar*)name );
         newNode->doc = NULL;
         xmlAddChild(PmmNODE(docfrag), newNode);
         RETVAL = PmmNodeToSv(newNode, docfrag );
         SV * encoding_sv;
         xmlParserInputBufferPtr buffer;
         xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
-        char * new_string;
+        xmlChar * new_string;
         STRLEN len;
     CODE:
         LibXML_init_error();
         if ( !buffer)
             croak("cant create buffer!\n" );
 
-        new_string = xmlStrdup(str);
-        xmlParserInputBufferPush(buffer, strlen(new_string), new_string);
+        new_string = xmlStrdup((const xmlChar*)str);
+        xmlParserInputBufferPush(buffer, xmlStrlen(new_string), (const char*)new_string);
 
         res = xmlIOParseDTD(NULL, buffer, enc);
 
     if ( node ) {
         if (node->ns != NULL && node->ns->prefix != NULL) {
             xmlChar *tname = xmlStrdup( node->ns->prefix );
-            tname = xmlStrcat( tname , ":" );
+            tname = xmlStrcat( tname , (const xmlChar *) ":" );
             tname = xmlStrcat( tname , node->name );
             qname = tname;
         } 
     if ( n == NULL ) 
         return;
     if ( val == NULL ){
-        val = "";
+        val = (xmlChar *) "";
     }
   
     if( n->type == XML_ATTRIBUTE_NODE ){

File perl-libxml-mm.c

         case XML_DOCUMENT_NODE:
         case XML_HTML_DOCUMENT_NODE:
         case XML_DOCB_DOCUMENT_NODE:
-            dfProxy->encoding = (int)xmlParseCharEncoding( ((xmlDocPtr)node)->encoding );
+            dfProxy->encoding = (int)xmlParseCharEncoding( (const char*)((xmlDocPtr)node)->encoding );
             break;
         default:
             break;
     }
     else if ( charset == XML_CHAR_ENCODING_ERROR ){
         /* warn("no standard encoding %s\n", encoding); */
-        coder =xmlFindCharEncodingHandler( encoding );
+        coder =xmlFindCharEncodingHandler( (const char *)encoding );
     }
     else {
         xs_warn("no encoding found\n");
         xs_warn("coding machine found \n");
         in    = xmlBufferCreate();
         out   = xmlBufferCreate();
-        xmlBufferCCat( in, string );
+        xmlBufferCCat( in, (const char *) string );
         if ( xmlCharEncInFunc( coder, out, in ) >= 0 ) {
             retval = xmlStrdup( out->content );
             /* warn( "encoded string is %s" , retval); */
     }
     else if ( charset == XML_CHAR_ENCODING_ERROR ){
         /* warn("no standard encoding\n"); */
-        coder = xmlFindCharEncodingHandler( encoding );
+        coder = xmlFindCharEncodingHandler( (const char *) encoding );
     }
     else {
         xs_warn("no encoding found\n");
         if( encoding != NULL ) {
             xs_warn( encoding );
             enc = xmlParseCharEncoding( encoding );
-            ret = PmmFastEncodeString( enc, string, encoding );
+            ret = PmmFastEncodeString( enc, string, (const xmlChar *)encoding );
         }
         else {
             /* if utf-8 is requested we do nothing */
         xs_warn( "PmmDecodeString called" );
         if( encoding != NULL ) {
             enc = xmlParseCharEncoding( encoding );
-            ret = PmmFastDecodeString( enc, string, encoding );
+            ret = (char*)PmmFastDecodeString( enc, string, (const xmlChar*)encoding );
             xs_warn( "PmmDecodeString done" );
         }
         else {
-            ret = xmlStrdup(string);
+            ret = (char*)xmlStrdup(string);
         }
     }
     return ret;
     xmlCharEncoding enc;
     if ( string != NULL ) {
         if ( encoding != NULL ) {
-            enc = xmlParseCharEncoding( encoding );
+            enc = xmlParseCharEncoding( (const char*)encoding );
         }
         else {
             enc = 0;
             /* string[len] = 0; */
 
             retval = NEWSV(0, len+1); 
-            sv_setpvn(retval, string, len );
+            sv_setpvn(retval, (const char*) string, len );
 #ifdef HAVE_UTF8
             xs_warn("set UTF8-SV-flag");
             SvUTF8_on(retval);
             if ( encoding != NULL ) {        
 #endif
                 xs_warn( "domEncodeString!" );
-                ts= PmmEncodeString( encoding, string );
+                ts= PmmEncodeString( (const char *)encoding, string );
                 xs_warn( "done!" );
                 if ( string != NULL ) {
                     xmlFree(string);

File perl-libxml-sax.c

         xmlChar * str = xmlStrdup( string );
         len = xmlStrlen( str );
         retval = NEWSV(0, len+1); 
-        sv_setpvn(retval, str, len );
+        sv_setpvn(retval, (const char *)str, len );
 #ifdef HAVE_UTF8
         SvUTF8_on( retval );
 #endif
     vec->ns_stack_root = xmlNewDoc(NULL);
     vec->ns_stack      = xmlNewDocNode(vec->ns_stack_root,
                                        NULL,
-                                       "stack",
+                                       (const xmlChar*)"stack",
                                        NULL );
 
     xmlAddChild((xmlNodePtr)vec->ns_stack_root, vec->ns_stack);
     }
     else {
         hv_store(param, "Prefix", 6,
-                 _C2Sv("", NULL), PrefixHash);
+                 _C2Sv((const xmlChar*)"", NULL), PrefixHash);
     }
 
     PUSHMARK(SP) ;
     }
     else {
         hv_store(param, "Prefix", 6,
-                 _C2Sv("", NULL), PrefixHash);
+                 _C2Sv((const xmlChar *)"", NULL), PrefixHash);
     }
 
     PUSHMARK(SP) ;
     xmlNsPtr list = sax->ns_stack->nsDef;
 
     while ( list ) {
-        if ( !xmlStrEqual(list->prefix, "xml") ) {
+        if ( !xmlStrEqual(list->prefix, (const xmlChar*)"xml") ) {
             PSaxEndPrefix( sax, list->prefix, list->href, handler );
         }
         list = list->next;        
             }
             else {
                 hv_store(retval, "Prefix", 6,
-                         _C2Sv("",NULL), PrefixHash);
+                         _C2Sv((const xmlChar *)"",NULL), PrefixHash);
             }
 
             hv_store(retval, "LocalName", 9,
         }
         else {
             hv_store(retval, "NamespaceURI", 12,
-                     _C2Sv("",NULL), NsURIHash);
+                     _C2Sv((const xmlChar *)"",NULL), NsURIHash);
             hv_store(retval, "Prefix", 6,
-                     _C2Sv("",NULL), PrefixHash);
+                     _C2Sv((const xmlChar *)"",NULL), PrefixHash);
             hv_store(retval, "LocalName", 9,
                      _C2Sv(name, NULL), LocalNameHash);
         }
     }
     namelen = xmlStrlen( name );
 
-    retval =xmlStrncat( retval, "{",1 );
+    retval =xmlStrncat( retval, (const xmlChar *)"{", 1 );
     if ( nsURI != NULL ) {
         urilen = xmlStrlen( nsURI );
         retval =xmlStrncat( retval, nsURI, urilen );
     } 
-    retval = xmlStrncat( retval, "}",1 );
+    retval = xmlStrncat( retval, (const xmlChar *)"}", 1 );
     retval = xmlStrncat( retval, name, namelen );
     return retval;
 }
                              _C2Sv(value, NULL), ValueHash);
                 }
 
-                if ( xmlStrEqual( "xmlns", name ) ) {
+                if ( xmlStrEqual( (const xmlChar *)"xmlns", name ) ) {
                     /* a default namespace */
                     PmmAddNamespace( sax, NULL, value, handler);  
-                    nsURI = NSDEFAULTURI;
+                    nsURI = (const xmlChar*)NSDEFAULTURI;
 
                     hv_store(atV, "Prefix", 6,
                              _C2Sv(name, NULL), PrefixHash);
                     hv_store(atV, "LocalName", 9,
-                             _C2Sv("",NULL), LocalNameHash);
+                             _C2Sv((const xmlChar *)"",NULL), LocalNameHash);
                     hv_store(atV, "NamespaceURI", 12,
-                             _C2Sv(NSDEFAULTURI,NULL),
+                             _C2Sv((const xmlChar *)NSDEFAULTURI,NULL),
                              NsURIHash);
                     
                 }
-                else if (xmlStrncmp("xmlns:", name, 6 ) == 0 ) {
+                else if (xmlStrncmp((const xmlChar *)"xmlns:", name, 6 ) == 0 ) {
                     PmmAddNamespace( sax,
                                      localname,
                                      value,
                     hv_store(atV, "Prefix", 6,
                              _C2Sv(prefix, NULL), PrefixHash);
                     hv_store(atV, "LocalName", 9,
-                             _C2Sv(localname,NULL), LocalNameHash);
+                             _C2Sv(localname, NULL), LocalNameHash);
                     hv_store(atV, "NamespaceURI", 12,
-                             _C2Sv(NSDEFAULTURI,NULL),
+                             _C2Sv((const xmlChar *)NSDEFAULTURI,NULL),
                              NsURIHash);
                 }
                 else if ( prefix != NULL
                 }
                 else {
                     hv_store(atV, "NamespaceURI", 12,
-                             _C2Sv("",NULL), NsURIHash);
+                             _C2Sv((const xmlChar *)"", NULL), NsURIHash);
                     hv_store(atV, "Prefix", 6,
-                             _C2Sv("", NULL), PrefixHash);
+                             _C2Sv((const xmlChar *)"", NULL), PrefixHash);
                     hv_store(atV, "LocalName", 9,
                              _C2Sv(name, NULL), LocalNameHash);
                 }
                                         nsURI );
 
                 len = xmlStrlen( keyname );
-                PERL_HASH( atnameHash, keyname, len );
+                PERL_HASH( atnameHash, (const char *)keyname, len );
                 hv_store(retval,
-                         keyname,
+                         (const char *)keyname,
                          len,
                          newRV_noinc((SV*)atV),
                          atnameHash );
         }
         else {
             hv_store(retval, "Data", 4,
-                     _C2Sv("", NULL), DataHash);
+                     _C2Sv((const xmlChar *)"", NULL), DataHash);
         }
     }
 
         }
         else {
             hv_store(empty, "Version", 7,
-                     _C2Sv("1.0", NULL), VersionHash);
+                     _C2Sv((const xmlChar *)"1.0", NULL), VersionHash);
         }
         
         if ( ctxt->encoding != NULL ) {
 
         PUSHMARK(SP) ;
         XPUSHs(handler);
-        element = PmmGenPISV(aTHX_ sax, target, data);
+        element = (SV*)PmmGenPISV(aTHX_ sax, (const xmlChar *)target, data);
         rv = newRV_noinc((SV*)element);
         XPUSHs(rv);
 
     svMessage = NEWSV(0,512);
 
     va_start(args, msg);
-    sv_vsetpvfn(svMessage, msg, xmlStrlen(msg), &args, NULL, 0, NULL);
+    sv_vsetpvfn(svMessage,
+                msg,
+                xmlStrlen((const xmlChar *)msg),
+                &args,
+                NULL,
+                0,
+                NULL);
     va_end(args);
 
     ENTER;
     svMessage = NEWSV(0,512);
 
     va_start(args, msg);
-    sv_vsetpvfn(svMessage, msg, xmlStrlen(msg), &args, NULL, 0, NULL);
+    sv_vsetpvfn(svMessage, msg, xmlStrlen((const xmlChar *)msg), &args, NULL, 0, NULL);
     va_end(args);
 
     XPUSHs(sv_2mortal(svMessage));
     svMessage = NEWSV(0,512);
 
     va_start(args, msg);
-    sv_vsetpvfn(svMessage, msg, xmlStrlen(msg), &args, NULL, 0, NULL);
+    sv_vsetpvfn(svMessage, msg, xmlStrlen((const xmlChar *)msg), &args, NULL, 0, NULL);
     va_end(args);
 
     ENTER;