File 0002-Clean-build-on-OSX-Mountain-Lion.patch of Package libght

From 608030445f38b041b5d73c34884c763a990e1f72 Mon Sep 17 00:00:00 2001
From: Paul Ramsey <pramsey@cleverelephant.ca>
Date: Mon, 21 Oct 2013 13:39:01 -0700
Subject: [PATCH 2/7] Clean build on OSX Mountain Lion

---
 src/ght_hash.c      |  1 +
 src/ght_internal.h  | 10 ++++++++++
 src/ght_node.c      |  2 ++
 src/ght_schema.c    | 25 +++++++++++++------------
 src/ght_util.c      |  4 ++--
 test/CMakeLists.txt |  2 +-
 tools/las2ght.c     |  4 ++--
 7 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/src/ght_hash.c b/src/ght_hash.c
index 988005f..1d8e1b5 100644
--- a/src/ght_hash.c
+++ b/src/ght_hash.c
@@ -317,6 +317,7 @@ ght_hash_free(GhtHash *hash)
 {
     assert(hash != NULL);
     ght_free(hash);
+    return GHT_OK;
 }
 
 GhtErr 
diff --git a/src/ght_internal.h b/src/ght_internal.h
index 6511069..95e8155 100644
--- a/src/ght_internal.h
+++ b/src/ght_internal.h
@@ -16,6 +16,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
+#include <ctype.h>
 
 #include "ght_config.h"
 #include "ght_core.h"
@@ -390,6 +391,9 @@ GhtErr ght_attribute_get_size(const GhtAttribute *attr, size_t *sz);
 /** Get the dimension associated with a GhtAttribute */
 GhtErr ght_attribute_get_dimension(const GhtAttribute *attr, const GhtDimension **dim);
 
+/** Traverse GhtAttribute chain and copy out GhtAttribute that corresponds to the GhtDimension */
+GhtErr ght_attribute_get_by_dimension(const GhtAttribute *attr, const GhtDimension *dim, GhtAttribute *found);
+
 /** Set the packed attribute value */
 GhtErr ght_attribute_set_value(GhtAttribute *attr, double val);
 
@@ -450,6 +454,9 @@ GhtErr ght_dimension_same(const GhtDimension *dim1, const GhtDimension *dim2, in
 /** Allocate a blank GhtSchema */
 GhtErr ght_schema_new(GhtSchema **schema);
 
+/** Create a copy of a GhtSchema */
+GhtErr ght_schema_clone(const GhtSchema *schema, GhtSchema **newschema);
+
 /** Free an existing schema */
 GhtErr ght_schema_free(GhtSchema *schema);
 
@@ -519,5 +526,8 @@ GhtErr bytes_from_hexbytes(const char *hex, size_t hexsize, uint8_t **bytes);
 /** Convert a byte buffer into a hex string */
 GhtErr hexbytes_from_bytes(const uint8_t *bytes, size_t bytesize, char **hex);
 
+/** Test that a file exists */
+int fexists(const char *filename);
+
 
 #endif /* _GHT_INTERNAL_H */
diff --git a/src/ght_node.c b/src/ght_node.c
index f0ff04e..2fe3d21 100644
--- a/src/ght_node.c
+++ b/src/ght_node.c
@@ -62,6 +62,7 @@ ght_nodelist_free_shallow(GhtNodeList *nl)
         ght_free(nl->nodes);
 
     ght_free(nl);
+	return GHT_OK;
 }
 
 /** Free all the nodes, then the containing stuff */
@@ -403,6 +404,7 @@ ght_node_free(GhtNode *node)
         GHT_TRY(ght_hash_free(node->hash));
 
     ght_free(node);
+	return GHT_OK;
 }
 
 
diff --git a/src/ght_schema.c b/src/ght_schema.c
index eecfb4e..093af0d 100644
--- a/src/ght_schema.c
+++ b/src/ght_schema.c
@@ -10,6 +10,7 @@
 
 #include <libxml/parser.h>
 #include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
 #include "ght_internal.h"
 #include <math.h>
 
@@ -265,6 +266,7 @@ GhtErr ght_schema_add_dimension(GhtSchema *schema, GhtDimension *dim)
     return GHT_OK;
 }
 
+#define TAG_IS(str) (strcmp((char*)(child->name), str) == 0)
 
 static GhtErr ght_dimension_from_xml(xmlNodePtr node, GhtDimension **dimension)
 {
@@ -277,31 +279,29 @@ static GhtErr ght_dimension_from_xml(xmlNodePtr node, GhtDimension **dimension)
     for ( child = node->children; child; child = child->next )
     {
         if ( child->type == XML_ELEMENT_NODE )
-        {
-            
-#define TAG_IS(str) (strcmp(child->name, str) == 0)
-            
+        { 
+			char *content = (char*)(child->children->content);
             if ( TAG_IS("name") )
             {
-                ght_dimension_set_name(dim, child->children->content);
+                ght_dimension_set_name(dim, content);
             }
             else if ( TAG_IS("description") )
             {
-                ght_dimension_set_description(dim, child->children->content);
+                ght_dimension_set_description(dim, content);
             }
             else if ( TAG_IS("interpretation") )
             {
                 GhtType type;
-                GHT_TRY(ght_type_from_str(child->children->content, &type));
+                GHT_TRY(ght_type_from_str(content, &type));
                 GHT_TRY(ght_dimension_set_type(dim, type));
             }
             else if ( TAG_IS("scale") )
             {
-                GHT_TRY(ght_dimension_set_scale(dim, atof(child->children->content)));
+                GHT_TRY(ght_dimension_set_scale(dim, atof(content)));
             }
             else if ( TAG_IS("offset") )
             {
-                GHT_TRY(ght_dimension_set_offset(dim, atof(child->children->content)));
+                GHT_TRY(ght_dimension_set_offset(dim, atof(content)));
             }
             else
             {
@@ -315,7 +315,7 @@ static GhtErr ght_dimension_from_xml(xmlNodePtr node, GhtDimension **dimension)
 
 static GhtErr ght_schema_from_xml(xmlDocPtr xml_doc, GhtSchema **schema)
 {
-    static xmlChar *xpath_str = "/pc:PointCloudSchema/pc:dimension";
+    static xmlChar *xpath_str = (unsigned char*)("/pc:PointCloudSchema/pc:dimension");
     xmlNsPtr xml_ns = NULL;
     xmlXPathContextPtr xpath_ctx;
     xmlXPathObjectPtr xpath_obj;
@@ -337,7 +337,7 @@ static GhtErr ght_schema_from_xml(xmlDocPtr xml_doc, GhtSchema **schema)
 
     /* Register the root namespace if there is one */
     if ( xml_ns )
-        xmlXPathRegisterNs(xpath_ctx, "pc", xml_ns->href);
+        xmlXPathRegisterNs(xpath_ctx, (xmlChar*)("pc"), xml_ns->href);
 
     /* Evaluate xpath expression */
     xpath_obj = xmlXPathEvalExpression(xpath_str, xpath_ctx);
@@ -349,7 +349,8 @@ static GhtErr ght_schema_from_xml(xmlDocPtr xml_doc, GhtSchema **schema)
     }
 
     /* Iterate on the dimensions we found */
-    if ( nodes = xpath_obj->nodesetval )
+    nodes = xpath_obj->nodesetval;
+    if ( nodes )
     {
         int i;
         int ndims = nodes->nodeNr;
diff --git a/src/ght_util.c b/src/ght_util.c
index 6d46934..abdd8cb 100644
--- a/src/ght_util.c
+++ b/src/ght_util.c
@@ -107,8 +107,8 @@ hexbytes_from_bytes(const uint8_t *bytebuf, size_t bytesize, char **hexbytes)
 int
 fexists(const char *filename)
 {
-    FILE *file;
-    if ( file = fopen(filename, "r") )
+    FILE *file = fopen(filename, "r");
+    if ( file )
     {
         fclose(file);
         return 1;
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f562537..12e3375 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -23,7 +23,7 @@ include_directories ("${PROJECT_SOURCE_DIR}/src")
 include_directories ("${CUNIT_INCLUDE_DIR}")
 
 add_executable(cu_tester ${GHT_TEST_SOURCES} ${GHT_TEST_HEADERS})
-target_link_libraries (cu_tester libght-static cunit)
+target_link_libraries (cu_tester libght-static ${CUNIT_LIBRARIES})
 
 add_test(cu_tester cu_tester)
 
diff --git a/tools/las2ght.c b/tools/las2ght.c
index 2cd587d..cf4898c 100644
--- a/tools/las2ght.c
+++ b/tools/las2ght.c
@@ -212,8 +212,8 @@ l2g_state_free(Las2GhtState *state)
 static int
 l2g_fexists(const char *filename)
 {
-    FILE *fd;
-    if ( ! (fd = fopen(filename, "r")) )
+    FILE *fd = fopen(filename, "r");
+    if ( !fd )
         return 0;
     fclose(fd);
     return 1;
-- 
1.8.4.5
openSUSE Build Service is sponsored by