[redland-dev] Raptor 1.4.2 (and probably earlier) compile problem on OS X

Dave Beckett dave.beckett at bristol.ac.uk
Sat Nov 6 11:51:19 GMT 2004


On Tue, 2 Nov 2004, René Puls wrote:
> Dave Beckett wrote:
> > Yes, OSX is shipped with broken libxml2.  Don't bother with it.
> 
> I wish I wouldn't have to, but since my Redland-ObjC framework is meant 
> for binary redistribution, it has to use the system libxml2.
> ...

You won't need to do that, more below.

> My current "solution" is to disable the Raptor RSS parser until Apple 
> provides a non-broken libxml2 by default, but that is unlikely to happen 
> before 10.4. Of course, if someone really needs the RSS parser under 
> Objective-C, there's still the option of compiling and linking the 
> framework manually.

Yes, thats the right answer, using the parser enabling/disabling
feature explicitly to remove the RSS parser for now.

However, I've done more delving into the problem and have consequently
worked out a way to make the RSS parser work with older libxml2s.  I've
got fixes so it works with 2.5.2 onwards (clearly newer ones have bug
fixes and are recommended) and in particular, it now works with the
system libxml2 on OSX 10.3.5 - 2.5.4, pretending to be 2.6.7.

So, you can either wait for the next raptor release or apply
the attached patch.

Dave
-------------- next part --------------
Index: raptor_rss.c
===================================================================
RCS file: /Users/cmdjb/cvsroot/redland/raptor/raptor_rss.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -c -r1.26 -r1.27
--- raptor_rss.c	2004/10/28 21:07:41	1.26
+++ raptor_rss.c	2004/11/06 11:18:49	1.27
@@ -205,7 +205,7 @@
 } raptor_rss_fields_type;
 
 
-raptor_rss_info raptor_rss_fields_info[RAPTOR_RSS_FIELDS_SIZE]={
+raptor_rss_info raptor_rss_fields_info[RAPTOR_RSS_FIELDS_SIZE+1]={
   { "title",          RSS1_0_NS },
   { "link",           RSS1_0_NS },
   { "description",    RSS1_0_NS },
@@ -268,6 +268,7 @@
   { "rights",         DC_NS },
 
   { "<unknown>",      RSS_UNKNOWN_NS },
+  { "<none>",         RSS_UNKNOWN_NS }
 };
 
 
@@ -558,22 +559,56 @@
   RAPTOR_DEBUG2("Added item %d\n", rss_parser->items_count);
 }
 
+#if LIBXML_VERSION < 20509
 
+#define XML_READER_TYPE_ELEMENT 1
+#define XML_READER_TYPE_TEXT 3
+#define XML_READER_TYPE_CDATA 4
+#define XML_READER_TYPE_ENTITY_REFERENCE 5
+#define XML_READER_TYPE_ENTITY 6
+#define XML_READER_TYPE_PROCESSING_INSTRUCTION 7
+#define XML_READER_TYPE_COMMENT 8
+#define XML_READER_TYPE_DOCUMENT 9
+#define XML_READER_TYPE_DOCUMENT_TYPE 10
+#define XML_READER_TYPE_DOCUMENT_FRAGMENT 11
+#define XML_READER_TYPE_NOTATION 12
+#define XML_READER_TYPE_WHITESPACE 13
+#define XML_READER_TYPE_SIGNIFICANT_WHITESPACE 14
+#define XML_READER_TYPE_END_ELEMENT 15
+#define XML_READER_TYPE_END_ENTITY 16
+#define XML_READER_TYPE_XML_DECLARATION 17
+
+#endif
+
+
+
 static void
 raptor_rss_parser_processNode(raptor_parser *rdf_parser) {
   raptor_rss_parser_context* rss_parser=(raptor_rss_parser_context*)rdf_parser->context;
   xmlTextReaderPtr reader=rss_parser->reader;
+#if LIBXML_VERSION > 20511
   const xmlChar *name;
+#else
+  xmlChar *name;
+#endif
+  int free_name=0;
   xmlChar *value;
   int type;
   int is_empty;
   raptor_uri *uri=NULL;
   xmlChar *rel=NULL;
   raptor_rss_enclosure *enclosure=NULL;
-  
+
+#if LIBXML_VERSION > 20511
   name = xmlTextReaderConstLocalName(reader);
-  if (name == NULL)
+#else
+  name = xmlTextReaderLocalName(reader);
+  free_name = 1;
+#endif
+  if (name == NULL) {
     name = xmlStrdup(BAD_CAST "--");
+    free_name = 1;
+  }
   value = xmlTextReaderValue(reader);
   
   type=xmlTextReaderNodeType(reader);
@@ -636,16 +671,30 @@
         rss_parser->current_field=RAPTOR_RSS_FIELD_UNKNOWN;
         for(i=0; i<RAPTOR_RSS_FIELDS_SIZE; i++)
           if(!strcmp((const char*)name, raptor_rss_fields_info[i].name)) {
+#if LIBXML_VERSION > 20511
             const xmlChar *nspace_URI=xmlTextReaderConstNamespaceUri(reader);
+#else
+            xmlChar *nspace_URI=xmlTextReaderNamespaceUri(reader);
+#endif
             if(nspace_URI && raptor_rss_fields_info[i].nspace != RSS_NO_NS) {
               const char *field_nspace_URI=rss_namespace_uri_strings[raptor_rss_fields_info[i].nspace];
             
               if(!strcmp((const char*)nspace_URI, field_nspace_URI)) {
                 rss_parser->current_field=(raptor_rss_fields_type)i;
+#if LIBXML_VERSION > 20511
+                /* nop */
+#else
+                xmlFree(nspace_URI);
+#endif
                 break;
               }
             } else {
               rss_parser->current_field=(raptor_rss_fields_type)i;
+#if LIBXML_VERSION > 20511
+              /* nop */
+#else
+              xmlFree(nspace_URI);
+#endif
               break;
             }
           }
@@ -680,7 +729,11 @@
 
       /* Now check for attributes */
       while((xmlTextReaderMoveToNextAttribute(reader))) {
+#if LIBXML_VERSION > 20511
         const xmlChar *attrName = xmlTextReaderConstLocalName(reader);
+#else
+        xmlChar *attrName = xmlTextReaderLocalName(reader);
+#endif
         xmlChar *attrValue = xmlTextReaderValue(reader);
         RAPTOR_DEBUG3("  attribute %s=%s\n", attrName, attrValue);
 
@@ -743,6 +796,11 @@
 
         if(attrValue)
           xmlFree(attrValue);
+#if LIBXML_VERSION > 20511
+        /* nop */
+#else
+        xmlFree(attrName);
+#endif
       }
       
       if(!is_empty) {
@@ -871,6 +929,9 @@
     
   if(value)
     xmlFree(value);
+
+  if(free_name)
+    xmlFree(name);
 
 }
 


More information about the redland-dev mailing list