Merge pull request #8 from rleigh-codelibre/clang-fixes

Fixes for LLVM on MacOS and FreeBSD
diff --git a/Makefile.incl.in b/Makefile.incl.in
index 7f6b30d..bb9d249 100644
--- a/Makefile.incl.in
+++ b/Makefile.incl.in
@@ -619,7 +619,7 @@
   ALLLIBS = ${LIBS} -L/usr/lib -L/usr/local/lib
   SHLIBSUFFIX=.dylib
   CC1 = ${CXX} $(CPPFLAGS) $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS)
-  CC4 = ${CC} $(CXXFLAGS) $(PLATFORM_COMPILE_OPTIONS)
+  CC4 = ${CC} $(CPPFLAGS) $(CFLAGS) $(PLATFORM_COMPILE_OPTIONS)
   LIB = $(LIB_NAME).$(LIB_MAJOR_VER).$(LIB_MINOR_VER)$(SHLIBSUFFIX)
   SO_NAME = $(LIB_NAME).$(LIB_MAJOR_VER)$(SHLIBSUFFIX)
   MAKE_SHARED = ${CXX} $(CXXFLAGS) -D${PLATFORM} -dynamiclib -prebind -seg1addr 0x38000000  -compatibility_version 1 -current_version $(LIB_MAJOR_DOT_VER) -install_name ${PREFIX}/lib/${LINK_NAME} ${LDFLAGS}
diff --git a/Tests/Threads/ThreadTest.cpp b/Tests/Threads/ThreadTest.cpp
index d5183ab..4583141 100644
--- a/Tests/Threads/ThreadTest.cpp
+++ b/Tests/Threads/ThreadTest.cpp
@@ -176,7 +176,7 @@
 ThreadInfo
 {
     ThreadInfo(
-            long                    theThreadNumber = 0L,
+            XMLInt32                theThreadNumber = 0L,
             SynchronizedCounter*    theCounter = 0) :
         m_threadNumber(theThreadNumber),
         m_counter(theCounter),
@@ -184,7 +184,7 @@
     {
     }
 
-    long                    m_threadNumber;
+    XMLInt32                m_threadNumber;
 
     SynchronizedCounter*    m_counter;
 
@@ -414,7 +414,7 @@
 
 #if defined(WINDOWS_THREAD_FUNCTIONS)
 
-    const unsigned long     theThreadID =
+    const XMLInt32     theThreadID =
             _beginthread(theThreadRoutine, 4096, reinterpret_cast<LPVOID>(&theThreadInfo));
 
     if (theThreadID == unsigned(-1))
@@ -490,7 +490,7 @@
 void
 startThread(
             ThreadInfo                  theThreadInfo[],
-            long                        theThreadNumber)
+            XMLInt32                    theThreadNumber)
 {
     bool    fResult = false;
 
@@ -530,14 +530,14 @@
 doContinuousThreads(
             const SynchronizedCounter&  theCounter,
             ThreadInfo                  theThreadInfo[],
-            long                        theThreadCount,
+            XMLInt32                    theThreadCount,
             clock_t&                    theClock)
 {
     while(fContinue == true)
     {
         if (theCounter.getCounter() < theThreadCount)
         {
-            for (long i = 0; i < theThreadCount && fContinue == true; ++i)
+            for (XMLInt32 i = 0; i < theThreadCount && fContinue == true; ++i)
             {
                 if (theThreadInfo[i].m_done == true)
                 {
@@ -554,8 +554,8 @@
 
 void
 doThreads(
-            long    theThreadCount,
-            bool    fContinuous)
+            XMLInt32 theThreadCount,
+            bool     fContinuous)
 {
     if (fContinuous == true)
     {
@@ -584,7 +584,7 @@
 
         SynchronizedCounter     theCounter;
 
-        long    i = 0;
+        XMLInt32    i = 0;
 
         while (i < theThreadCount && fContinue == true)
         {
diff --git a/samples/Makefile.in b/samples/Makefile.in
index 6ad73e4..d81803d 100644
--- a/samples/Makefile.in
+++ b/samples/Makefile.in
@@ -178,7 +178,7 @@
 
 $(XSL_BIN_DIR)/SimpleXPathCAPI: $(XSL_OBJ_DIR)/SimpleXPathCAPI.o
 	$(LINK) $(XSL_BUILD_OPTIONS) $(PLATFORM_LIB_LINK_OPTIONS)  \
-	${EXTRA_LINK_OPTIONS} $^ $(XALAN_LIB) $(ALLLIBS) $(CXXFLAGS) -o $@  \
+	${EXTRA_LINK_OPTIONS} $^ $(XALAN_LIB) $(ALLLIBS) $(CFLAGS) -o $@  \
 	$(OTHER_LINK_PARAMETERS)
 
 $(XSL_OBJ_DIR)/%.o:$(SAMPLES_DIR)/SimpleXPathCAPI/%.c
diff --git a/src/xalanc/Harness/XalanFileUtility.cpp b/src/xalanc/Harness/XalanFileUtility.cpp
index 2d14c0f..997fc3d 100644
--- a/src/xalanc/Harness/XalanFileUtility.cpp
+++ b/src/xalanc/Harness/XalanFileUtility.cpp
@@ -1659,8 +1659,8 @@
         collectData(
             "Wrong number of attributes. ",
             docNodeName,
-            NumberToDOMString(numGoldAttr, numGoldStr),
-            NumberToDOMString(numDomAttr, numDOMStr));
+            NumberToDOMString(static_cast<XMLUInt64>(numGoldAttr), numGoldStr),
+            NumberToDOMString(static_cast<XMLUInt64>(numDomAttr), numDOMStr));
 
         return false;
     }
@@ -1805,8 +1805,8 @@
         collectData(
             "Wrong number of attributes. ",
             docNodeName,
-            NumberToDOMString(numGoldAttr, numGoldStr),
-            NumberToDOMString(numDomAttr, numDOMStr));
+            NumberToDOMString(static_cast<XMLUInt64>(numGoldAttr), numGoldStr),
+            NumberToDOMString(static_cast<XMLUInt64>(numDomAttr), numDOMStr));
 
         return false;
     }
diff --git a/src/xalanc/ICUBridge/ICUXalanNumberFormatProxy.cpp b/src/xalanc/ICUBridge/ICUXalanNumberFormatProxy.cpp
index b330ba6..17d12a5 100644
--- a/src/xalanc/ICUBridge/ICUXalanNumberFormatProxy.cpp
+++ b/src/xalanc/ICUBridge/ICUXalanNumberFormatProxy.cpp
@@ -131,7 +131,7 @@
 
 {
     // $$$ ToDo: Fix this!
-    return format(static_cast<unsigned long>(theValue), theResult);
+    return format(theValue, theResult);
 }
 
 
@@ -143,7 +143,7 @@
 
 {
     // $$$ ToDo: Fix this!
-    return format(static_cast<long>(theValue), theResult);
+    return format(theValue, theResult);
 }
 
 
diff --git a/src/xalanc/PlatformSupport/DOMStringPrintWriter.cpp b/src/xalanc/PlatformSupport/DOMStringPrintWriter.cpp
index 9d68498..0e41c3c 100644
--- a/src/xalanc/PlatformSupport/DOMStringPrintWriter.cpp
+++ b/src/xalanc/PlatformSupport/DOMStringPrintWriter.cpp
@@ -190,7 +190,7 @@
 
 
 void
-DOMStringPrintWriter::print(int i)
+DOMStringPrintWriter::print(XMLInt32 i)
 {
     assert ( m_outputString != 0 );
 
@@ -204,7 +204,7 @@
 
 
 void
-DOMStringPrintWriter::print(long    l)
+DOMStringPrintWriter::print(XMLInt64 l)
 {
     assert ( m_outputString != 0 );
 
@@ -290,7 +290,7 @@
 
 
 void
-DOMStringPrintWriter::println(int   i)
+DOMStringPrintWriter::println(XMLInt32   i)
 {
     print(i);
 
@@ -300,7 +300,7 @@
 
 
 void
-DOMStringPrintWriter::println(long  l)
+DOMStringPrintWriter::println(XMLInt64  l)
 {
     print(l);
 
diff --git a/src/xalanc/PlatformSupport/DOMStringPrintWriter.hpp b/src/xalanc/PlatformSupport/DOMStringPrintWriter.hpp
index 979ec59..4a432c4 100644
--- a/src/xalanc/PlatformSupport/DOMStringPrintWriter.hpp
+++ b/src/xalanc/PlatformSupport/DOMStringPrintWriter.hpp
@@ -112,10 +112,10 @@
     print(double    d);
 
     virtual void
-    print(int   i);
+    print(XMLInt32   i);
 
     virtual void
-    print(long  l);
+    print(XMLInt64  l);
 
     virtual void
     print(const XalanDOMString&     s);
@@ -145,10 +145,10 @@
     println(double  x);
 
     virtual void
-    println(int     x);
+    println(XMLInt32     x);
 
     virtual void
-    println(long    x);
+    println(XMLInt64    x);
 
     virtual void
     println(const XalanDOMString&   s);
diff --git a/src/xalanc/PlatformSupport/DoubleSupport.hpp b/src/xalanc/PlatformSupport/DoubleSupport.hpp
index 1d99842..16955d1 100644
--- a/src/xalanc/PlatformSupport/DoubleSupport.hpp
+++ b/src/xalanc/PlatformSupport/DoubleSupport.hpp
@@ -584,11 +584,7 @@
 
 private:
 
-#if defined(XALAN_NO_STD_NUMERIC_LIMITS)
-    static NumberUnion          s_NaN;
-#else
     static const NumberUnion    s_NaN;
-#endif
 
     static const NumberUnion    s_positiveInfinity;
     static const NumberUnion    s_negativeInfinity;
diff --git a/src/xalanc/PlatformSupport/PrintWriter.hpp b/src/xalanc/PlatformSupport/PrintWriter.hpp
index d873aca..c3ca0ab 100644
--- a/src/xalanc/PlatformSupport/PrintWriter.hpp
+++ b/src/xalanc/PlatformSupport/PrintWriter.hpp
@@ -118,10 +118,10 @@
     print(double    d) = 0;
 
     virtual void
-    print(int   i) = 0;
+    print(XMLInt32   i) = 0;
 
     virtual void
-    print(long  l) = 0;
+    print(XMLInt64  l) = 0;
 
     virtual void
     print(const XalanDOMString&     s) = 0;
@@ -151,10 +151,10 @@
     println(double  x) = 0;
 
     virtual void
-    println(int     x) = 0;
+    println(XMLInt32     x) = 0;
 
     virtual void
-    println(long    x) = 0;
+    println(XMLInt64    x) = 0;
 
     virtual void
     println(const XalanDOMString&   s) = 0;
diff --git a/src/xalanc/PlatformSupport/XalanOutputStreamPrintWriter.cpp b/src/xalanc/PlatformSupport/XalanOutputStreamPrintWriter.cpp
index 41e1b62..69d7b83 100644
--- a/src/xalanc/PlatformSupport/XalanOutputStreamPrintWriter.cpp
+++ b/src/xalanc/PlatformSupport/XalanOutputStreamPrintWriter.cpp
@@ -277,7 +277,7 @@
 
 
 void
-XalanOutputStreamPrintWriter::print(int     i)
+XalanOutputStreamPrintWriter::print(XMLInt32     i)
 {
     m_buffer.clear();
 
@@ -289,7 +289,7 @@
 
 
 void
-XalanOutputStreamPrintWriter::print(long    l)
+XalanOutputStreamPrintWriter::print(XMLInt64    l)
 {
     m_buffer.clear();
 
@@ -375,7 +375,7 @@
 
 
 void
-XalanOutputStreamPrintWriter::println(int   i)
+XalanOutputStreamPrintWriter::println(XMLInt32   i)
 {
     print(i);
 
@@ -385,7 +385,7 @@
 
 
 void
-XalanOutputStreamPrintWriter::println(long  l)
+XalanOutputStreamPrintWriter::println(XMLInt64  l)
 {
     print(l);
 
diff --git a/src/xalanc/PlatformSupport/XalanOutputStreamPrintWriter.hpp b/src/xalanc/PlatformSupport/XalanOutputStreamPrintWriter.hpp
index f2b7293..4b3dd47 100644
--- a/src/xalanc/PlatformSupport/XalanOutputStreamPrintWriter.hpp
+++ b/src/xalanc/PlatformSupport/XalanOutputStreamPrintWriter.hpp
@@ -123,10 +123,10 @@
     print(double    d);
 
     virtual void
-    print(int   i);
+    print(XMLInt32   i);
 
     virtual void
-    print(long  l);
+    print(XMLInt64  l);
 
     virtual void
     print(const XalanDOMString&     s);
@@ -156,10 +156,10 @@
     println(double  x);
 
     virtual void
-    println(int     x);
+    println(XMLInt32     x);
 
     virtual void
-    println(long    x);
+    println(XMLInt64    x);
 
     virtual void
     println(const XalanDOMString&   s);
diff --git a/src/xalanc/PlatformSupport/XalanTranscodingServices.cpp b/src/xalanc/PlatformSupport/XalanTranscodingServices.cpp
index d9f367c..fece427 100644
--- a/src/xalanc/PlatformSupport/XalanTranscodingServices.cpp
+++ b/src/xalanc/PlatformSupport/XalanTranscodingServices.cpp
@@ -476,7 +476,7 @@
             theBuffer,
             XalanMessages::CreateTranscoderError_2Param,
             NumberToDOMString(
-                static_cast<long>(theCode),
+                static_cast<XMLInt64>(theCode),
                 theBuffer).c_str(),
             theEncoding),
         theBuffer.getMemoryManager(),
diff --git a/src/xalanc/XMLSupport/FormatterToXMLUnicode.hpp b/src/xalanc/XMLSupport/FormatterToXMLUnicode.hpp
index c118c07..eca5483 100644
--- a/src/xalanc/XMLSupport/FormatterToXMLUnicode.hpp
+++ b/src/xalanc/XMLSupport/FormatterToXMLUnicode.hpp
@@ -664,7 +664,7 @@
     }
 
     void
-    writeNumericCharacterReference(unsigned long  theNumber)
+    writeNumericCharacterReference(XMLUInt32  theNumber)
     {
         m_writer.write(value_type(XalanUnicode::charAmpersand));
         m_writer.write(value_type(XalanUnicode::charNumberSign));
diff --git a/src/xalanc/XSLT/ElemNumber.cpp b/src/xalanc/XSLT/ElemNumber.cpp
index 864bc27..4d5b31f 100644
--- a/src/xalanc/XSLT/ElemNumber.cpp
+++ b/src/xalanc/XSLT/ElemNumber.cpp
@@ -1414,7 +1414,7 @@
                         executionContext.getMemoryManager(),
                         getNumberFormatter(executionContext));
 
-                formatter->format(listElement, theResult);
+                formatter->format(static_cast<XMLUInt64>(listElement), theResult);
 
                 const XalanDOMString::size_type     lengthNumString = theResult.length();
 
diff --git a/src/xalanc/XSLT/XSLTEngineImpl.cpp b/src/xalanc/XSLT/XSLTEngineImpl.cpp
index 50b15d3..9c5bd95 100644
--- a/src/xalanc/XSLT/XSLTEngineImpl.cpp
+++ b/src/xalanc/XSLT/XSLTEngineImpl.cpp
@@ -1148,7 +1148,7 @@
         const ECGetCachedString     theGuard1(executionContext);
 
         XalanDOMString& theBuffer = theGuard1.get();
-        NumberToDOMString(nl.getLength(), theBuffer);
+        NumberToDOMString(static_cast<XMLUInt64>(nl.getLength()), theBuffer);
 
         msg += theBuffer;
             
diff --git a/src/xalanc/XSLT/XSLTEngineImpl.hpp b/src/xalanc/XSLT/XSLTEngineImpl.hpp
index 49d418f..ef65081 100644
--- a/src/xalanc/XSLT/XSLTEngineImpl.hpp
+++ b/src/xalanc/XSLT/XSLTEngineImpl.hpp
@@ -1541,7 +1541,7 @@
     /**
      * This is used whenever a unique namespace is needed.
      */
-    unsigned long       m_uniqueNSValue;
+    XMLUInt32       m_uniqueNSValue;
 
     ParamVectorType     m_topLevelParams;