← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/llvm into lp:zorba

 

William Candillon has proposed merging lp:~zorba-coders/zorba/llvm into lp:zorba.

Requested reviews:
  Matthias Brantner (matthias-brantner)
  Paul J. Lucas (paul-lucas)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/llvm/+merge/141233

Fix build with the following options:
- ZORBA_NO_ICU
- ZORBA_NO_XMLSCHEMA
- ZORBA_NO_FULLTEXT
- ZORBA_WITH_FILE_ACCESS=OFF

Update references of ulong to u_long

Add EMSCRIPTEN options for UUID, traits,  and static assert support.
-- 
https://code.launchpad.net/~zorba-coders/zorba/llvm/+merge/141233
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'CMakeCompiler.txt'
--- CMakeCompiler.txt	2012-09-19 21:16:15 +0000
+++ CMakeCompiler.txt	2012-12-24 23:39:23 +0000
@@ -257,8 +257,10 @@
     MESSAGE (FATAL_ERROR "Could not find libuuid - required on Linux!")
   ENDIF (NOT LIBUUID_EXISTS)
 ELSE (APPLE)
-  # We're not Apple or Win32, and we didn't find uuid.h - can't compile
-  MESSAGE (FATAL_ERROR "Could not find uuid/uuid.h header, which is "
-    "required on Linux. On Ubuntu, the 'uuid-dev' package is required; "
-    "look for similar packages on other platforms.")
+  IF(NOT EMSCRIPTEN)
+    # We're not Apple or Win32, and we didn't find uuid.h - can't compile
+    MESSAGE (FATAL_ERROR "Could not find uuid/uuid.h header, which is "
+      "required on Linux. On Ubuntu, the 'uuid-dev' package is required; "
+      "look for similar packages on other platforms.")
+  ENDIF(NOT EMSCRIPTEN)
 ENDIF (APPLE)

=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2012-10-08 12:09:36 +0000
+++ CMakeLists.txt	2012-12-24 23:39:23 +0000
@@ -95,11 +95,11 @@
 CHECK_INCLUDE_FILES ("limits.h"                     ZORBA_HAVE_LIMITS_H)
 CHECK_INCLUDE_FILES ("sys/types.h"                  ZORBA_HAVE_SYS_TYPES_H)
 CHECK_INCLUDE_FILES ("iconv.h"                      ZORBA_HAVE_ICONV_H)
-IF (NOT APPLE OR ${CMAKE_SYSTEM_VERSION} VERSION_GREATER "10.4")
+IF (NOT APPLE OR CMAKE_SYSTEM_VERSION VERSION_GREATER "10.4")
   # execinfo is found by this macro when cross compiling for Mac OS X 10.4
   # although it shouldn't be found for this platform
   CHECK_INCLUDE_FILES ("execinfo.h"                   ZORBA_HAVE_EXECINFO_H)
-ENDIF (NOT APPLE OR ${CMAKE_SYSTEM_VERSION} VERSION_GREATER "10.4")
+ENDIF (NOT APPLE OR CMAKE_SYSTEM_VERSION VERSION_GREATER "10.4")
 CHECK_INCLUDE_FILE_CXX ("FlexLexer.h"               ZORBA_HAVE_FLEXLEXER_H)
 CHECK_INCLUDE_FILES ("uuid/uuid.h"                  ZORBA_HAVE_UUID_H)
 
@@ -324,18 +324,20 @@
 #
 # ICU
 #
-MESSAGE(STATUS "Looking for ICU")
-FIND_PACKAGE(ICU)
+IF(NOT ZORBA_NO_ICU)
+  MESSAGE(STATUS "Looking for ICU")
+  FIND_PACKAGE(ICU)
+    
+  IF(ICU_FOUND AND ICU_I18N_FOUND AND ICU_DATA_FOUND)
+    MESSAGE(STATUS "Found ICU library -- " ${ICU_LIBRARIES})
   
-IF(ICU_FOUND AND ICU_I18N_FOUND AND ICU_DATA_FOUND)
-  MESSAGE(STATUS "Found ICU library -- " ${ICU_LIBRARIES})
-
-  INCLUDE_DIRECTORIES(${ICU_INCLUDE_DIRS})
-  SET(requiredlibs ${requiredlibs} ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES} ${ICU_DATA_LIBRARIES}) 
-ELSE(ICU_FOUND AND ICU_I18N_FOUND AND ICU_DATA_FOUND)
-  MESSAGE(FATAL_ERROR "The ICU library is required in order to build Zorba.")
-ENDIF(ICU_FOUND AND ICU_I18N_FOUND AND ICU_DATA_FOUND)       
-MESSAGE(STATUS "")
+    INCLUDE_DIRECTORIES(${ICU_INCLUDE_DIRS})
+    SET(requiredlibs ${requiredlibs} ${ICU_LIBRARIES} ${ICU_I18N_LIBRARIES} ${ICU_DATA_LIBRARIES}) 
+  ELSE(ICU_FOUND AND ICU_I18N_FOUND AND ICU_DATA_FOUND)
+    MESSAGE(FATAL_ERROR "The ICU library is required in order to build Zorba.")
+  ENDIF(ICU_FOUND AND ICU_I18N_FOUND AND ICU_DATA_FOUND)       
+  MESSAGE(STATUS "")
+ENDIF(NOT ZORBA_NO_ICU)
 
 #
 # Xerces-C part 1 - finding in default locations

=== modified file 'bin/zorbacmd.cpp'
--- bin/zorbacmd.cpp	2012-11-06 10:11:37 +0000
+++ bin/zorbacmd.cpp	2012-12-24 23:39:23 +0000
@@ -622,6 +622,7 @@
 void
 removeOutputFileIfNeeded(const ZorbaCMDProperties& lProperties)
 {
+#ifdef ZORBA_WITH_FILE_ACCESS
   if (lProperties.outputFile().size() > 0)
   {
     File_t lFile = zorba::File::createFile(lProperties.outputFile());
@@ -630,6 +631,7 @@
       lFile->remove();
     }
   }
+#endif
 }
 
 

=== modified file 'include/zorba/config.h.cmake'
--- include/zorba/config.h.cmake	2012-09-19 21:16:15 +0000
+++ include/zorba/config.h.cmake	2012-12-24 23:39:23 +0000
@@ -126,7 +126,7 @@
 
 ////////// C++ tr1 include directory & namespace //////////////////////////////
 
-#if defined( __GNUC__ ) && (__GNUC__ * 100 + __GNUC_MINOR__ < 430)
+#if defined( __GNUC__ ) && (__GNUC__ * 100 + __GNUC_MINOR__ < 430) && !defined(EMSCRIPTEN)
 # define ZORBA_GCC_OLDER_THAN_430 1
 #endif
 

=== modified file 'src/api/CMakeLists.txt'
--- src/api/CMakeLists.txt	2012-12-05 03:33:46 +0000
+++ src/api/CMakeLists.txt	2012-12-24 23:39:23 +0000
@@ -46,7 +46,6 @@
     invoke_item_sequence.cpp
     item_sequence_chainer.cpp
     empty_sequence.cpp
-    fileimpl.cpp
     serializerimpl.cpp
     base64impl.cpp
     base64_streambuf.cpp
@@ -63,6 +62,10 @@
     uuid.cpp
     )
 
+IF (ZORBA_WITH_FILE_ACCESS)
+  LIST(APPEND API_SRCS fileimpl.cpp)
+ENDIF (ZORBA_WITH_FILE_ACCESS)
+
 IF (NOT ZORBA_NO_FULL_TEXT)
   LIST(APPEND API_SRCS
     stemmer.cpp

=== modified file 'src/api/dynamiccontextimpl.cpp'
--- src/api/dynamiccontextimpl.cpp	2012-11-28 12:32:38 +0000
+++ src/api/dynamiccontextimpl.cpp	2012-12-24 23:39:23 +0000
@@ -200,7 +200,7 @@
 
     VarInfo* var = get_var_info(nameSpace, localName);
 
-    ulong varId = var->getId();
+    u_long varId = var->getId();
 
     store::Item_t item;
     store::TempSeq_t tempseq;
@@ -265,7 +265,7 @@
       throw;
     }
 
-    ulong varId = var->getId();
+    u_long varId = var->getId();
 
     theCtx->add_variable(varId, value);
 
@@ -327,7 +327,7 @@
       throw;
     }
 
-    ulong varId = var->getId();
+    u_long varId = var->getId();
 
     // add it to the internal context
     theCtx->add_variable(varId, value);
@@ -377,7 +377,7 @@
       throw;
     }
 
-    ulong varId = var->getId();
+    u_long varId = var->getId();
 
     theCtx->add_variable(varId, value);
 

=== modified file 'src/api/serialization/serializer.cpp'
--- src/api/serialization/serializer.cpp	2012-10-15 19:25:46 +0000
+++ src/api/serialization/serializer.cpp	2012-12-24 23:39:23 +0000
@@ -79,14 +79,14 @@
     const char* str,
     zstring::size_type strlen,
     const char* separators,
-    ulong seplen,
+    u_long seplen,
     std::vector<zstring>& tokens)
 {
-  ulong start = 0;
+  u_long start = 0;
 
-  for (ulong i = 0; i < strlen; ++i)
+  for (u_long i = 0; i < strlen; ++i)
   {
-    for (ulong j = 0; j < seplen; ++j)
+    for (u_long j = 0; j < seplen; ++j)
     {
       if (str[i] == separators[j])
       {
@@ -129,7 +129,7 @@
   theIsFirstElementNode(true),
   theEmitAttributes(aEmitAttributes)
 {
-  for (ulong i = 0; i < 8; i++)
+  for (u_long i = 0; i < 8; i++)
     theChildIters[i] = GENV_ITERATOR_FACTORY->createChildrenIterator();
 
   theAttrIter = GENV_ITERATOR_FACTORY->createAttributesIterator();
@@ -141,8 +141,8 @@
 ********************************************************************************/
 serializer::emitter::~emitter()
 {
-  ulong numIters = (ulong)theChildIters.size();
-  for (ulong i = 0; i < numIters; i++)
+  u_long numIters = (u_long)theChildIters.size();
+  for (u_long i = 0; i < numIters; i++)
     delete theChildIters[i];
 
   delete theAttrIter;
@@ -616,7 +616,7 @@
     zstring name;
     parent->getNodeName()->getStringValue2(name);
 
-    for (ulong i = 0; i < ser->cdata_section_elements_tokens.size(); ++i)
+    for (u_long i = 0; i < ser->cdata_section_elements_tokens.size(); ++i)
     {
       if (ser->cdata_section_elements_tokens[i] == name)
       {

=== modified file 'src/api/serialization/serializer.h'
--- src/api/serialization/serializer.h	2012-10-08 12:09:36 +0000
+++ src/api/serialization/serializer.h	2012-12-24 23:39:23 +0000
@@ -332,7 +332,7 @@
     }                                     thePreviousItemKind;
 
     std::vector<store::ChildrenIterator*> theChildIters;
-    ulong                                 theFirstFreeChildIter;
+    u_long                                 theFirstFreeChildIter;
     store::AttributesIterator           * theAttrIter;
 
     bool                                  theIsFirstElementNode;

=== modified file 'src/api/staticcontextimpl.cpp'
--- src/api/staticcontextimpl.cpp	2012-10-10 21:15:05 +0000
+++ src/api/staticcontextimpl.cpp	2012-12-24 23:39:23 +0000
@@ -39,6 +39,7 @@
 #include "api/staticcollectionmanagerimpl.h"
 #include "api/vectoriterator.h"
 
+#include "context/dynamic_context.h"
 #include "context/static_context.h"
 #include "context/static_context_consts.h"
 #ifndef ZORBA_NO_FULL_TEXT
@@ -59,10 +60,10 @@
 #include "types/typeops.h"
 
 #include "diagnostics/xquery_diagnostics.h"
+#include "diagnostics/assert.h"
 
 #include "runtime/util/flowctl_exception.h"
 
-
 namespace zorba {
 
 /*******************************************************************************

=== modified file 'src/api/staticcontextimpl.h'
--- src/api/staticcontextimpl.h	2012-10-08 12:09:36 +0000
+++ src/api/staticcontextimpl.h	2012-12-24 23:39:23 +0000
@@ -64,7 +64,7 @@
 
   CompilerCB                          * theCompilerCB;
 
-  ulong                                 theMaxVarId;
+  u_long                                 theMaxVarId;
 
   DiagnosticHandler                   * theDiagnosticHandler;
   bool                                  theUserDiagnosticHandler;
@@ -84,9 +84,9 @@
 
   void loadProlog(const String&, const Zorba_CompilerHints_t& hints);
 
-  ulong getMaxVarId() const { return theMaxVarId; }
+  u_long getMaxVarId() const { return theMaxVarId; }
 
-  void setMaxVarId(ulong v) { if (v > theMaxVarId) theMaxVarId = v; }
+  void setMaxVarId(u_long v) { if (v > theMaxVarId) theMaxVarId = v; }
 
   StaticContext_t createChildContext() const;
 

=== modified file 'src/api/uuid.cpp'
--- src/api/uuid.cpp	2012-10-08 12:09:36 +0000
+++ src/api/uuid.cpp	2012-12-24 23:39:23 +0000
@@ -27,6 +27,8 @@
 # include <uuid/uuid.h>
 #elif defined( _WIN32 )
 # include <Rpc.h>
+#elif defined( EMSCRIPTEN )
+# include <boost/uuid/uuid.hpp>
 #else
 # error "Unsupported operating system for generating UUIDs"
 #endif
@@ -47,6 +49,9 @@
   uuid_generate( result->data );
 #elif defined( _WIN32 )
   UuidCreateSequential( (UUID*)result->data );
+#elif defined( EMSCRIPTEN )
+    boost::uuids::uuid u;
+    ::memcpy(&u, result->data, sizeof result->data );  
 #endif /* _WIN32 */
 }
 

=== modified file 'src/api/xqueryimpl.cpp'
--- src/api/xqueryimpl.cpp	2012-10-08 12:09:36 +0000
+++ src/api/xqueryimpl.cpp	2012-12-24 23:39:23 +0000
@@ -433,7 +433,7 @@
 
     // 0 is reserved as an invalid var id, and 1 is taken by the context item
     // in the main module.
-    ulong nextVarId = dynamic_context::MAX_IDVARS_RESERVED;
+    u_long nextVarId = dynamic_context::MAX_IDVARS_RESERVED;
 
     doCompile(lQueryStream, aHints, true, nextVarId);
   }
@@ -457,7 +457,7 @@
 
     // 0 is reserved as an invalid var id, and 1 is taken by the context item
     // in the main module.
-    ulong nextVarId = dynamic_context::MAX_IDVARS_RESERVED;
+    u_long nextVarId = dynamic_context::MAX_IDVARS_RESERVED;
 
     doCompile(aQuery, aHints, true, nextVarId);
   }
@@ -492,7 +492,7 @@
     if (externalSctx->theCompilerCB)
       theCompilerCB->theSctxMap = externalSctx->theCompilerCB->theSctxMap;
 
-    ulong nextVarId = externalSctx->getMaxVarId();
+    u_long nextVarId = externalSctx->getMaxVarId();
 
     std::istringstream lQueryStream(aQuery.c_str());
 
@@ -535,7 +535,7 @@
     if (externalSctx->theCompilerCB)
       theCompilerCB->theSctxMap = externalSctx->theCompilerCB->theSctxMap;
 
-    ulong nextVarId = externalSctx->getMaxVarId();
+    u_long nextVarId = externalSctx->getMaxVarId();
 
     doCompile(aQuery, aHints, true, nextVarId);
   }
@@ -550,7 +550,7 @@
     std::istream& aQuery,
     const Zorba_CompilerHints_t& aHints,
     bool fork_sctx,
-    ulong& nextDynamicVarId)
+    u_long& nextDynamicVarId)
 {
   if ( ! theStaticContext )
   {
@@ -641,7 +641,7 @@
 
     StaticContextImpl* sctx = static_cast<StaticContextImpl*>(aStaticContext.get());
 
-    ulong nextVarId = sctx->getMaxVarId();
+    u_long nextVarId = sctx->getMaxVarId();
 
     doCompile(lQueryStream, aHints, false, nextVarId);
 
@@ -859,7 +859,7 @@
     if (var->hasInitializer())
       return true;
     
-    ulong varId = var->getId();
+    u_long varId = var->getId();
 
     if (theDynamicContext->is_set_variable(varId))
       return true;

=== modified file 'src/api/xqueryimpl.h'
--- src/api/xqueryimpl.h	2012-09-19 21:16:15 +0000
+++ src/api/xqueryimpl.h	2012-12-24 23:39:23 +0000
@@ -357,7 +357,7 @@
         std::istream&,
         const Zorba_CompilerHints_t& aHints,
         bool fork_sctx,
-        ulong& nextVarId);
+        u_long& nextVarId);
 
   PlanWrapper_t generateWrapper();
 

=== modified file 'src/api/zorbaimpl.h'
--- src/api/zorbaimpl.h	2012-09-19 21:16:15 +0000
+++ src/api/zorbaimpl.h	2012-12-24 23:39:23 +0000
@@ -57,7 +57,7 @@
   friend class Zorba;
 
   SYNC_CODE(Mutex theUsersMutex);
-  ulong           theNumUsers;
+  u_long           theNumUsers;
 public:
 #ifdef WIN32
   static bool ctrl_c_signaled;

=== modified file 'src/compiler/api/compiler_api.cpp'
--- src/compiler/api/compiler_api.cpp	2012-12-14 07:27:04 +0000
+++ src/compiler/api/compiler_api.cpp	2012-12-24 23:39:23 +0000
@@ -211,7 +211,7 @@
 PlanIter_t XQueryCompiler::compile(
     std::istream& aXQuery,
     const zstring& aFileName,
-    ulong& nextDynamicVarId)
+    u_long& nextDynamicVarId)
 {
   audit::Event* ae = theCompilerCB->theRootSctx->get_audit_event();
   zorba::audit::ScopedRecord sar(ae);
@@ -248,7 +248,7 @@
 PlanIter_t XQueryCompiler::compile(
     const parsenode_t& ast,
     bool applyPUL,
-    ulong& nextDynamicVarId,
+    u_long& nextDynamicVarId,
     audit::ScopedRecord& aAuditRecord)
 {
   expr* rootExpr;

=== modified file 'src/compiler/api/compiler_api.h'
--- src/compiler/api/compiler_api.h	2012-10-08 12:09:36 +0000
+++ src/compiler/api/compiler_api.h	2012-12-24 23:39:23 +0000
@@ -51,12 +51,12 @@
   PlanIter_t compile(
       std::istream& aXQuery,
       const zstring& aFileName,
-      ulong& nextDynamicVarId);
+      u_long& nextDynamicVarId);
 
   PlanIter_t compile(
       const parsenode_t& ast,
       bool applyPUL,
-      ulong& nextDynamicVarId,
+      u_long& nextDynamicVarId,
       audit::ScopedRecord& aAuditRecord);
 
 protected:

=== modified file 'src/compiler/codegen/plan_visitor.cpp'
--- src/compiler/codegen/plan_visitor.cpp	2012-12-18 15:09:02 +0000
+++ src/compiler/codegen/plan_visitor.cpp	2012-12-24 23:39:23 +0000
@@ -336,7 +336,7 @@
   std::stack<EnclosedExprContext>            theEnclosedContextStack;
   std::stack<bool>                           theCopyNodesStack;
 
-  ulong                                      theNextDynamicVarId;
+  u_long                                     theNextDynamicVarId;
 
   hash64map<std::vector<LetVarIter_t> *>   * arg_var_iter_map;
   hash64map<std::vector<LetVarIter_t> *>     catchvar_iter_map;
@@ -358,7 +358,7 @@
 
 plan_visitor(
     CompilerCB* ccb,
-    ulong nextDynamicVarId,
+    u_long nextDynamicVarId,
     hash64map<std::vector<LetVarIter_t>*>* arg_var_map = NULL)
   :
   theDepth(0),
@@ -390,7 +390,7 @@
 }
 
 
-ulong getNextDynamicVarId() const
+u_long getNextDynamicVarId() const
 {
   return theNextDynamicVarId;
 }
@@ -504,7 +504,7 @@
 {
   CODEGEN_TRACE_OUT("");
 
-  ulong numArgs = (ulong)v.get_args().size() + 1;
+  u_long numArgs = (u_long)v.get_args().size() + 1;
 
   std::vector<PlanIter_t> argIters(numArgs);
 
@@ -570,10 +570,10 @@
 {
   CODEGEN_TRACE_OUT("");
 
-  ulong numArgs = v.size();
+  u_long numArgs = v.size();
   checked_vector<PlanIter_t> args(numArgs);
 
-  for (ulong i = numArgs; i > 0; --i)
+  for (u_long i = numArgs; i > 0; --i)
   {
     PlanIter_t arg = pop_itstack();
     args[i-1] = arg;
@@ -1374,7 +1374,7 @@
   wincond_var_iters(
         const flwor_wincond* cond,
         FlworClauseVarMap* clauseVarMap,
-        ulong& varPos)
+        u_long& varPos)
   {
     const flwor_wincond::vars& inVars = cond->get_in_vars();
     const flwor_wincond::vars& outVars = cond->get_out_vars();
@@ -1461,7 +1461,7 @@
   if (c.get_kind() != flwor_clause::where_clause)
   {
     ZORBA_ASSERT(!theClauseStack.empty());
-    ulong stackSize = (ulong)theClauseStack.size();
+    u_long stackSize = (u_long)theClauseStack.size();
 
     clauseVarMap = theClauseStack[stackSize-1];
     theClauseStack.resize(stackSize - 1);
@@ -1555,7 +1555,7 @@
     std::auto_ptr<flwor::StartClause> start_clause;
     std::auto_ptr<flwor::EndClause> end_clause;
     const flwor_wincond* cond;
-    ulong varPos = 1;
+    u_long varPos = 1;
 
     if (NULL == (cond = wc->get_win_stop()))
     {
@@ -1616,16 +1616,16 @@
   //
   else if (c.get_kind() == flwor_clause::order_clause)
   {
-    ulong numVars = (ulong)clauseVarMap->theVarRebinds.size();
-    ulong numForVars = 0;
-    ulong numLetVars = 0;
+    u_long numVars = (u_long)clauseVarMap->theVarRebinds.size();
+    u_long numForVars = 0;
+    u_long numLetVars = 0;
 
     std::vector<ForVarIter_t> inputForVars(numVars);
     std::vector<LetVarIter_t> inputLetVars(numVars);
     std::vector<std::vector<PlanIter_t> > outputForVarsRefs(numVars);
     std::vector<std::vector<PlanIter_t> > outputLetVarsRefs(numVars);
 
-    for (ulong i = 0; i < numVars; ++i)
+    for (u_long i = 0; i < numVars; ++i)
     {
       VarRebind* varRebind = clauseVarMap->theVarRebinds[i].getp();
 
@@ -1658,7 +1658,7 @@
     outputLetVarsRefs.resize(numLetVars);
 
     const orderby_clause* obc = static_cast<const orderby_clause *>(&c);
-    ulong numColumns = obc->num_columns();
+    u_long numColumns = obc->num_columns();
     const std::vector<OrderModifier>& modifiers = obc->get_modifiers();
 
     std::vector<flwor::OrderSpec> orderSpecs(numColumns);
@@ -1743,16 +1743,16 @@
     //
     case flwor_clause::materialize_clause:
     {
-      ulong numVars = (ulong)clauseVarMap->theVarRebinds.size();
-      ulong numForVars = 0;
-      ulong numLetVars = 0;
+      u_long numVars = (u_long)clauseVarMap->theVarRebinds.size();
+      u_long numForVars = 0;
+      u_long numLetVars = 0;
 
       std::vector<ForVarIter_t> inputForVars(numVars);
       std::vector<LetVarIter_t> inputLetVars(numVars);
       std::vector<std::vector<PlanIter_t> > outputForVarsRefs(numVars);
       std::vector<std::vector<PlanIter_t> > outputLetVarsRefs(numVars);
 
-      for (ulong i = 0; i < numVars; ++i)
+      for (u_long i = 0; i < numVars; ++i)
       {
         VarRebind* varRebind = clauseVarMap->theVarRebinds[i];
 
@@ -2367,8 +2367,8 @@
 
   if (v.is_sequential())
   {
-    ulong numArgs = v.num_args();
-    for (ulong i = 0; i < numArgs; ++i)
+    u_long numArgs = v.num_args();
+    for (u_long i = 0; i < numArgs; ++i)
     {
       if (v.get_arg(i)->is_sequential())
       {
@@ -3661,7 +3661,7 @@
     const char* descr,
     expr* root,
     CompilerCB* ccb,
-    ulong& nextDynamicVarId,
+    u_long& nextDynamicVarId,
     hash64map<std::vector<LetVarIter_t> *>* arg_var_map)
 {
   plan_visitor c(ccb, nextDynamicVarId, arg_var_map);

=== modified file 'src/compiler/codegen/plan_visitor.h'
--- src/compiler/codegen/plan_visitor.h	2012-09-19 21:16:15 +0000
+++ src/compiler/codegen/plan_visitor.h	2012-12-24 23:39:23 +0000
@@ -32,7 +32,7 @@
         const char* descr,
         expr* root,
         CompilerCB* ccb,
-        ulong& nextDynamicVarId,
+        u_long& nextDynamicVarId,
         hash64map<std::vector<LetVarIter_t> *>* param_var_map = NULL);
 
 } /* namespace zorba */

=== modified file 'src/compiler/expression/expr_manager.cpp'
--- src/compiler/expression/expr_manager.cpp	2012-10-26 07:13:42 +0000
+++ src/compiler/expression/expr_manager.cpp	2012-12-24 23:39:23 +0000
@@ -538,7 +538,7 @@
     static_context* sctx,
     user_function* udf,
     const QueryLoc& loc,
-    ulong varKind,
+    u_long varKind,
     store::Item* name)
 {
   CREATE_AND_RETURN_EXPR(var_expr,
@@ -813,7 +813,7 @@
   CREATE_AND_RETURN_EXPR(function_item_expr, sctx, udf, loc);
 }
 
-
+#ifndef ZORBA_NO_FULL_TEXT
 ftcontains_expr* ExprManager::create_ftcontains_expr(
     static_context* sctx,
     user_function* udf,
@@ -824,7 +824,7 @@
 {
   CREATE_AND_RETURN_EXPR(ftcontains_expr, sctx, udf, loc, range, ftselection, ftignore);
 }
-
+#endif
 
 ////////////////////////////////////////////////////////////////////////////////
 

=== modified file 'src/compiler/expression/expr_manager.h'
--- src/compiler/expression/expr_manager.h	2012-10-26 07:13:42 +0000
+++ src/compiler/expression/expr_manager.h	2012-12-24 23:39:23 +0000
@@ -333,7 +333,7 @@
       static_context* sctx,
       user_function* udf,
       const QueryLoc& loc,
-      ulong varKind,
+      u_long varKind,
       store::Item* name);
 
   var_expr* create_var_expr(user_function* udf, const var_expr& source);
@@ -495,6 +495,7 @@
       user_function* udf,
       const QueryLoc& loc);
 
+#ifndef ZORBA_NO_FULL_TEXT
   ftcontains_expr* create_ftcontains_expr(
       static_context*,
       user_function* udf,
@@ -502,6 +503,7 @@
       expr* range,
       ftnode* ftselection,
       expr* ftignore);
+#endif
 
 ////////////////////////////////////////////////////////////////////////////////
 

=== modified file 'src/compiler/expression/flwor_expr.cpp'
--- src/compiler/expression/flwor_expr.cpp	2012-10-26 07:13:42 +0000
+++ src/compiler/expression/flwor_expr.cpp	2012-12-24 23:39:23 +0000
@@ -1108,9 +1108,9 @@
 ********************************************************************************/
 void flwor_expr::compute_scripting_kind()
 {
-  ulong numClauses = num_clauses();
+  u_long numClauses = num_clauses();
 
-  for (ulong i = 0; i < numClauses; ++i)
+  for (u_long i = 0; i < numClauses; ++i)
   {
     const flwor_clause* c = theClauses[i];
     flwor_clause::ClauseKind k = c->get_kind();

=== modified file 'src/compiler/expression/var_expr.cpp'
--- src/compiler/expression/var_expr.cpp	2012-12-06 22:49:35 +0000
+++ src/compiler/expression/var_expr.cpp	2012-12-24 23:39:23 +0000
@@ -153,7 +153,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-void var_expr::set_unique_id(ulong v)
+void var_expr::set_unique_id(u_long v)
 {
   assert(theUniqueId == 0);
 

=== modified file 'src/compiler/expression/var_expr.h'
--- src/compiler/expression/var_expr.h	2012-12-06 22:49:35 +0000
+++ src/compiler/expression/var_expr.h	2012-12-24 23:39:23 +0000
@@ -151,7 +151,7 @@
   };
 
 protected:
-  ulong                 theUniqueId;
+  u_long                 theUniqueId;
 
   var_kind              theVarKind;
 
@@ -198,9 +198,9 @@
 
   VarInfo* get_var_info() const { return theVarInfo; }
 
-  ulong get_unique_id() const { return theUniqueId; }
+  u_long get_unique_id() const { return theUniqueId; }
 
-  void set_unique_id(ulong v);
+  void set_unique_id(u_long v);
 
   store::Item* get_name() const;
 

=== modified file 'src/compiler/parsetree/parsenode_print_xml_visitor.cpp'
--- src/compiler/parsetree/parsenode_print_xml_visitor.cpp	2012-09-19 21:16:15 +0000
+++ src/compiler/parsetree/parsenode_print_xml_visitor.cpp	2012-12-24 23:39:23 +0000
@@ -323,7 +323,6 @@
 
 void *begin_visit(const SchemaImport &n)
 {
-#ifndef ZORBA_NO_XMLSCHEMA
     INDENT;
 
     os << "<SchemaImport" << IDS;
@@ -332,9 +331,6 @@
 
     INDENT_INC; NL;
     return no_state;
-#else
-  throw XQUERY_EXCEPTION(err::XQST0009);
-#endif
 }
 
 void *begin_visit (const URILiteralList &n)
@@ -347,7 +343,7 @@
 
   INDENT_INC; NL;
 
-  for (ulong i = 0; i < n.size(); i++)
+  for (u_long i = 0; i < n.size(); i++)
   {
     INDENT;
     os << "<URI>" << n [i] << "</URI>" << "\n";

=== modified file 'src/compiler/parsetree/parsenode_print_xquery_visitor.cpp'
--- src/compiler/parsetree/parsenode_print_xquery_visitor.cpp	2012-10-08 12:09:36 +0000
+++ src/compiler/parsetree/parsenode_print_xquery_visitor.cpp	2012-12-24 23:39:23 +0000
@@ -966,7 +966,7 @@
 
     void* begin_visit(const URILiteralList& n)
     {
-      for(ulong i = 0; i < n.size(); i++)
+      for(u_long i = 0; i < n.size(); i++)
       {
         if(i!=0)
         {

=== modified file 'src/compiler/parsetree/parsenodes.cpp'
--- src/compiler/parsetree/parsenodes.cpp	2012-10-09 14:06:08 +0000
+++ src/compiler/parsetree/parsenodes.cpp	2012-12-24 23:39:23 +0000
@@ -1192,7 +1192,7 @@
 {
   BEGIN_VISITOR();
 
-  for (ulong i = 0; i < size(); ++i)
+  for (u_long i = 0; i < size(); ++i)
     (*this)[i]->accept(v);
 
   END_VISITOR();

=== modified file 'src/compiler/parsetree/parsenodes.h'
--- src/compiler/parsetree/parsenodes.h	2012-10-08 12:09:36 +0000
+++ src/compiler/parsetree/parsenodes.h	2012-12-24 23:39:23 +0000
@@ -740,7 +740,7 @@
 
   const zstring& operator[](int i) const { return theUris[i]; }
 
-  ulong size() const { return (ulong)theUris.size(); }
+  u_long size() const { return (u_long)theUris.size(); }
 
   void accept(parsenode_visitor&) const;
 };
@@ -1334,9 +1334,9 @@
 
   void addKeySpec(IndexKeySpec* spec) { theKeySpecs.push_back(spec); }
 
-  ulong size() const { return (ulong)theKeySpecs.size(); }
+  u_long size() const { return (u_long)theKeySpecs.size(); }
 
-  const IndexKeySpec* getKeySpec(ulong i) const { return theKeySpecs[i].getp(); }
+  const IndexKeySpec* getKeySpec(u_long i) const { return theKeySpecs[i].getp(); }
 
   void accept(parsenode_visitor&) const;
 };
@@ -1613,9 +1613,9 @@
   {
   }
 
-  const parsenode* operator[](ulong k) const { return theStatements[k].getp(); }
+  const parsenode* operator[](u_long k) const { return theStatements[k].getp(); }
 
-  parsenode* operator[](ulong k) { return theStatements[k].getp(); }
+  parsenode* operator[](u_long k) { return theStatements[k].getp(); }
 
   csize size() const { return theStatements.size(); }
 
@@ -2661,7 +2661,7 @@
 
   rchandle<QVarInDecl> operator[](int i) const { return qvar_decl_hv[i]; }
 
-  ulong size () const { return (ulong)qvar_decl_hv.size ();}
+  u_long size () const { return (u_long)qvar_decl_hv.size ();}
 
   void accept(parsenode_visitor&) const;
 };
@@ -3913,7 +3913,7 @@
 
   rchandle<exprnode> operator[](int i) { return pred_hv[i]; }
 
-  ulong size () const { return (ulong)pred_hv.size (); }
+  u_long size () const { return (u_long)pred_hv.size (); }
 
   void accept(parsenode_visitor&) const;
 };
@@ -4202,7 +4202,7 @@
 
   rchandle<exprnode> operator[](int i) const { return arg_hv[i]; }
 
-  ulong size() const { return (ulong)arg_hv.size (); }
+  u_long size() const { return (u_long)arg_hv.size (); }
 
   void accept(parsenode_visitor&) const;
 };
@@ -4361,7 +4361,7 @@
 
   const DirAttr *operator[] (int i) const { return theAttributes[i]; }
 
-  ulong size () const { return (ulong)theAttributes.size (); }
+  u_long size () const { return (u_long)theAttributes.size (); }
 
   void accept(parsenode_visitor&) const;
 };
@@ -5762,7 +5762,7 @@
 
   rchandle<SequenceType> operator[](int i) const { return theTypes[i]; }
 
-  ulong size() const { return (ulong)theTypes.size (); }
+  u_long size() const { return (u_long)theTypes.size (); }
 
   void accept(parsenode_visitor&) const;
 };

=== modified file 'src/compiler/rewriter/framework/rewriter_context.h'
--- src/compiler/rewriter/framework/rewriter_context.h	2012-10-26 18:24:00 +0000
+++ src/compiler/rewriter/framework/rewriter_context.h	2012-12-24 23:39:23 +0000
@@ -32,7 +32,7 @@
 
 class user_function;
 
-typedef std::map<var_expr *, ulong> VarIdMap;
+typedef std::map<var_expr *, u_long> VarIdMap;
 typedef std::vector<var_expr*> IdVarMap;
 typedef std::map<const expr *, DynamicBitset> ExprVarsMap;
 

=== modified file 'src/compiler/rewriter/rewriters/default_optimizer.cpp'
--- src/compiler/rewriter/rewriters/default_optimizer.cpp	2012-10-26 18:24:00 +0000
+++ src/compiler/rewriter/rewriters/default_optimizer.cpp	2012-12-24 23:39:23 +0000
@@ -193,7 +193,7 @@
     rCtx.theIdVarMap = new IdVarMap;
     rCtx.theExprVarsMap = new ExprVarsMap;
 
-    ulong numVars = 0;
+    u_long numVars = 0;
     expr_tools::index_flwor_vars(rCtx.getRoot(),
                                  numVars,
                                  *rCtx.theVarIdMap,

=== modified file 'src/compiler/rewriter/rules/flwor_rules.cpp'
--- src/compiler/rewriter/rules/flwor_rules.cpp	2012-12-18 15:09:02 +0000
+++ src/compiler/rewriter/rules/flwor_rules.cpp	2012-12-24 23:39:23 +0000
@@ -259,7 +259,7 @@
       expr* domExpr = fc->get_expr();
       xqtref_t domType = domExpr->get_return_type();
       TypeConstants::quantifier_t domQuant = domType->get_quantifier();
-      ulong domCount = domType->max_card();
+      u_long domCount = domType->max_card();
       var_expr* pvar = fc->get_pos_var();
       var = fc->get_var();
 
@@ -1519,7 +1519,7 @@
                               posExpr->get_loc()))
       {
         VarIdMap varidMap;
-        ulong numFlworVars = 0;
+        u_long numFlworVars = 0;
         expr_tools::index_flwor_vars(flworExpr, numFlworVars, varidMap, NULL);
         
         DynamicBitset varset(numFlworVars);
@@ -1527,9 +1527,9 @@
         expr_tools::build_expr_to_vars_map(posExpr, varidMap, varset, exprVarMap);
         
         var_expr* forVar = forClause->get_var();
-        ulong forVarId = varidMap[forVar];
+        u_long forVarId = varidMap[forVar];
 
-        std::vector<ulong> posExprVarIds;
+        std::vector<u_long> posExprVarIds;
         exprVarMap[posExpr].getSet(posExprVarIds);
 
         csize numPosExprVars = posExprVarIds.size();

=== modified file 'src/compiler/rewriter/rules/fold_rules.cpp'
--- src/compiler/rewriter/rules/fold_rules.cpp	2012-11-12 17:12:41 +0000
+++ src/compiler/rewriter/rules/fold_rules.cpp	2012-12-24 23:39:23 +0000
@@ -455,7 +455,7 @@
     expr* node,
     store::Item_t& result)
 {
-  ulong nextVarId = 1;
+  u_long nextVarId = 1;
   PlanIter_t plan = codegen("const-folded expr", node, compilercb, nextVarId);
 
   QueryLoc loc = LOC (node);

=== modified file 'src/compiler/rewriter/rules/hoist_rules.cpp'
--- src/compiler/rewriter/rules/hoist_rules.cpp	2012-12-06 22:49:35 +0000
+++ src/compiler/rewriter/rules/hoist_rules.cpp	2012-12-24 23:39:23 +0000
@@ -98,7 +98,7 @@
 {
   assert(node == rCtx.getRoot());
 
-  ulong numVars = 0;
+  u_long numVars = 0;
   VarIdMap varmap;
 
   expr_tools::index_flwor_vars(node, numVars, varmap, NULL);

=== modified file 'src/compiler/rewriter/rules/index_join_rule.cpp'
--- src/compiler/rewriter/rules/index_join_rule.cpp	2012-12-06 22:49:35 +0000
+++ src/compiler/rewriter/rules/index_join_rule.cpp	2012-12-24 23:39:23 +0000
@@ -43,13 +43,13 @@
 
 static void rewriteJoin(RewriterContext&, PredicateInfo&, bool&);
 
-static var_expr* findForVar(static_context*, RewriterContext&, const expr*, ulong&);
-
-static bool checkVarDependency(RewriterContext&, expr*, ulong);
-
-static bool expandVars(RewriterContext&, expr*, ulong, long&);
-
-static bool findFlworForVar(RewriterContext&, const var_expr*, flwor_expr*&, ulong&, ulong&);
+static var_expr* findForVar(static_context*, RewriterContext&, const expr*, u_long&);
+
+static bool checkVarDependency(RewriterContext&, expr*, u_long);
+
+static bool expandVars(RewriterContext&, expr*, u_long, long&);
+
+static bool findFlworForVar(RewriterContext&, const var_expr*, flwor_expr*&, u_long&, u_long&);
 
 
 struct PredicateInfo
@@ -58,7 +58,7 @@
   expr        * thePredicate;
   expr        * theOuterOp;
   var_expr    * theOuterVar;
-  ulong         theOuterVarId;
+  u_long        theOuterVarId;
   expr        * theInnerOp;
   var_expr    * theInnerVar;
   bool          theIsGeneral;
@@ -241,12 +241,12 @@
 
   // Analyze each operand of the eq to see if it depends on a single for
   // variable. If that is not true, we reject this predicate.
-  ulong var1id;
+  u_long var1id;
   var_expr* var1 = findForVar(sctx, rCtx, op1, var1id);
   if (var1 == NULL)
     return false;
 
-  ulong var2id;
+  u_long var2id;
   var_expr* var2 = findForVar(sctx, rCtx, op2, var2id);
   if (var2 == NULL)
     return false;
@@ -255,7 +255,7 @@
     return false;
 
   // Determine the outer and inner side of the join
-  ulong outerVarId;
+  u_long outerVarId;
 
   if (var1id < var2id)
   {
@@ -363,13 +363,13 @@
     static_context* sctx,
     RewriterContext& rCtx,
     const expr* curExpr,
-    ulong& varid)
+    u_long& varid)
 {
   var_expr* var = NULL;
 
   while (true)
   {
-    std::vector<ulong> varidSet;
+    std::vector<u_long> varidSet;
 
     const DynamicBitset& bitset = (*rCtx.theExprVarsMap)[curExpr];
 
@@ -421,14 +421,14 @@
 static bool checkVarDependency(
     RewriterContext& rCtx,
     expr* curExpr,
-    ulong searchVarId)
+    u_long searchVarId)
 {
   const DynamicBitset& bitset = (*rCtx.theExprVarsMap)[curExpr];
 
   if (bitset.get(searchVarId))
     return true;
 
-  std::vector<ulong> varidSet;
+  std::vector<u_long> varidSet;
   bitset.getSet(varidSet);
 
   csize numVars = varidSet.size();
@@ -515,8 +515,8 @@
     flwor_clause* mostInnerVarClause = mostInnerVar->get_flwor_clause();
 
     flwor_expr* innerFlwor = NULL;
-    ulong innerPosInStack = 0;
-    ulong mostInnerVarPos = 0;
+    u_long innerPosInStack = 0;
+    u_long mostInnerVarPos = 0;
 
     if (!findFlworForVar(rCtx,
                          mostInnerVar,
@@ -604,8 +604,8 @@
     // find the flwor expr defining the outer var and create the index just
     // before this flwor.
     flwor_expr* outerFlworExpr = NULL;
-    ulong outerPosInStack = 0;
-    ulong dummy = 0;
+    u_long outerPosInStack = 0;
+    u_long dummy = 0;
 
     if (!findFlworForVar(rCtx,
                          predInfo.theOuterVar,
@@ -730,7 +730,7 @@
 static bool expandVars(
     RewriterContext& rCtx,
     expr* subExpr,
-    ulong outerVarId,
+    u_long outerVarId,
     long& maxVarId)
 {
   if (subExpr->get_expr_kind() == wrapper_expr_kind)
@@ -812,8 +812,8 @@
     RewriterContext& rCtx,
     const var_expr* var,
     flwor_expr*& flworExpr,
-    ulong& varPos,
-    ulong& posInStack)
+    u_long& varPos,
+    u_long& posInStack)
 {
   flworExpr = NULL;
 

=== modified file 'src/compiler/rewriter/tools/dataflow_annotations.cpp'
--- src/compiler/rewriter/tools/dataflow_annotations.cpp	2012-12-20 22:22:31 +0000
+++ src/compiler/rewriter/tools/dataflow_annotations.cpp	2012-12-24 23:39:23 +0000
@@ -366,7 +366,7 @@
     flwor_expr::clause_list_t::const_iterator end = e->clause_end();
 
     const forletwin_clause* fc = NULL;
-    ulong numForClauses = 0;
+    u_long numForClauses = 0;
 
     for (; ite != end; ++ite)
     {
@@ -462,7 +462,7 @@
   {
     const function* f = e->get_func();
 
-    ulong nArgs = e->num_args();
+    u_long nArgs = e->num_args();
 
     FunctionConsts::AnnotationValue sorted = f->producesSortedNodes();
 
@@ -478,7 +478,7 @@
     {
       BoolAnnotationValue sorted = ANNOTATION_FALSE;
 
-      for (ulong i = 0; i < nArgs; ++i)
+      for (u_long i = 0; i < nArgs; ++i)
       {
         if (f->propagatesSortedNodes(i))
         {
@@ -504,7 +504,7 @@
     {
       BoolAnnotationValue distinct = ANNOTATION_FALSE;
 
-      for (ulong i = 0; i < nArgs; ++i)
+      for (u_long i = 0; i < nArgs; ++i)
       {
         if (f->propagatesDistinctNodes(i))
         {
@@ -588,8 +588,8 @@
   {
     csize num_steps = e->size();
     bool only_child_axes = true;
-    ulong num_desc_axes = 0;
-    ulong num_following_axes = 0;
+    u_long num_desc_axes = 0;
+    u_long num_following_axes = 0;
     bool reverse_axes = false;
 
     for (csize i = 1; i < num_steps; ++i)

=== modified file 'src/compiler/rewriter/tools/expr_tools.cpp'
--- src/compiler/rewriter/tools/expr_tools.cpp	2012-10-29 11:41:36 +0000
+++ src/compiler/rewriter/tools/expr_tools.cpp	2012-12-24 23:39:23 +0000
@@ -36,9 +36,9 @@
 namespace expr_tools
 {
 
-static void add_wincond_vars(const flwor_wincond*, ulong&, VarIdMap&, IdVarMap*);
+static void add_wincond_vars(const flwor_wincond*, u_long&, VarIdMap&, IdVarMap*);
 
-static void add_var(var_expr*, ulong&, VarIdMap&, IdVarMap*);
+static void add_var(var_expr*, u_long&, VarIdMap&, IdVarMap*);
 
 static void remove_wincond_vars(const flwor_wincond*, const VarIdMap&, DynamicBitset&);
 
@@ -251,7 +251,7 @@
 ********************************************************************************/
 void index_flwor_vars(
     const expr* e,
-    ulong& numVars,
+    u_long& numVars,
     VarIdMap& varidmap,
     IdVarMap* idvarmap)
 {
@@ -394,7 +394,7 @@
 ********************************************************************************/
 static void add_wincond_vars(
     const flwor_wincond* cond,
-    ulong& numVars,
+    u_long& numVars,
     VarIdMap& varidmap,
     IdVarMap* idvarmap)
 {
@@ -420,7 +420,7 @@
 ********************************************************************************/
 static void add_var(
     var_expr* v,
-    ulong& numVars,
+    u_long& numVars,
     VarIdMap& varidmap,
     IdVarMap* idvarmap)
 {

=== modified file 'src/compiler/rewriter/tools/expr_tools.h'
--- src/compiler/rewriter/tools/expr_tools.h	2012-10-29 11:41:36 +0000
+++ src/compiler/rewriter/tools/expr_tools.h	2012-12-24 23:39:23 +0000
@@ -63,7 +63,7 @@
   Util functions used by rules: HoistExprsOutOfLoops and IndexJoin.
 ********************************************************************************/
 
-void index_flwor_vars(const expr*, ulong&, VarIdMap&, IdVarMap*);
+void index_flwor_vars(const expr*, u_long&, VarIdMap&, IdVarMap*);
 
 void build_expr_to_vars_map(expr*, const VarIdMap&, DynamicBitset&, ExprVarsMap&);
 

=== modified file 'src/compiler/rewriter/tools/udf_graph.cpp'
--- src/compiler/rewriter/tools/udf_graph.cpp	2012-10-31 08:02:16 +0000
+++ src/compiler/rewriter/tools/udf_graph.cpp	2012-12-24 23:39:23 +0000
@@ -192,7 +192,7 @@
 }
 
 
-void UDFGraph::optimizeUDFs(CompilerCB* ccb, UDFNode* node, ulong visit)
+void UDFGraph::optimizeUDFs(CompilerCB* ccb, UDFNode* node, u_long visit)
 {
   if (node->theVisitId == visit)
     return;
@@ -266,7 +266,7 @@
 }
 
 
-bool UDFGraph::inferDeterminism(UDFNode* node, ulong visit)
+bool UDFGraph::inferDeterminism(UDFNode* node, u_long visit)
 {
   if (node->theVisitId == visit)
     return node->theUDF->isDeterministic();

=== modified file 'src/compiler/rewriter/tools/udf_graph.h'
--- src/compiler/rewriter/tools/udf_graph.h	2012-10-19 20:42:38 +0000
+++ src/compiler/rewriter/tools/udf_graph.h	2012-12-24 23:39:23 +0000
@@ -39,7 +39,7 @@
   user_function         * theUDF;
   std::vector<UDFNode*>   theParents;
   std::vector<UDFNode*>   theChildren;
-  ulong                   theVisitId;
+  u_long                  theVisitId;
 
 public:
   UDFNode(user_function* udf)
@@ -109,7 +109,7 @@
   expr     * theExpr;
   UDFMap     theNodes;
   UDFNode  * theRoot;
-  ulong      theVisitId;
+  u_long     theVisitId;
 
 public:
   UDFGraph(expr* e);
@@ -129,9 +129,9 @@
 
   void addEdge(user_function* caller, user_function* callee);
 
-  void optimizeUDFs(CompilerCB* ccb, UDFNode* node, ulong visit);
+  void optimizeUDFs(CompilerCB* ccb, UDFNode* node, u_long visit);
 
-  bool inferDeterminism(UDFNode* node, ulong visit);
+  bool inferDeterminism(UDFNode* node, u_long visit);
 
   void display(std::ostream& o, UDFNode* node);
 };

=== modified file 'src/compiler/translator/prolog_graph.cpp'
--- src/compiler/translator/prolog_graph.cpp	2012-09-19 21:16:15 +0000
+++ src/compiler/translator/prolog_graph.cpp	2012-12-24 23:39:23 +0000
@@ -294,7 +294,7 @@
   std::vector<const var_expr*> topsorted_vars;  // dependencies first
   std::set<const var_expr*> visited;
 
-  std::stack<std::pair<ulong, const var_expr*> > todo;  // format: action code + var_expr
+  std::stack<std::pair<u_long, const var_expr*> > todo;  // format: action code + var_expr
   // need to declare the reverse end iterator here because of a bug in older gcc's
   // (see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11729)
   std::vector<const var_expr*>::const_reverse_iterator  lEnd = theVarDecls.rend();
@@ -302,13 +302,13 @@
        it != lEnd;
        ++it)
   {
-    todo.push(std::pair<ulong, const var_expr*>(1, (*it)));
+    todo.push(std::pair<u_long, const var_expr*>(1, (*it)));
   }
 
   while (! todo.empty())
   {
     const var_expr* var = todo.top().second;
-    ulong action = todo.top().first;
+    u_long action = todo.top().first;
     todo.pop();
 
     switch (action)
@@ -323,7 +323,7 @@
       if (visited.find(var) == visited.end())
       {
         visited.insert(var);
-        todo.push(std::pair<ulong, const var_expr*>(0, var));
+        todo.push(std::pair<u_long, const var_expr*>(0, var));
 
         GraphImpl::const_iterator var_graph_entry = theGraph.find(var);
 
@@ -337,7 +337,7 @@
           {
             if (var_vset_ite->getKind() == PrologGraphVertex::VAR)
             {
-              todo.push(std::pair<ulong, const var_expr*>(1, var_vset_ite->getVarExpr()));
+              todo.push(std::pair<u_long, const var_expr*>(1, var_vset_ite->getVarExpr()));
             }
           }
         }

=== modified file 'src/compiler/translator/translator.cpp'
--- src/compiler/translator/translator.cpp	2012-12-12 08:11:40 +0000
+++ src/compiler/translator/translator.cpp	2012-12-24 23:39:23 +0000
@@ -236,7 +236,7 @@
   bool    theSingleInput;
   bool    theOnlyChildAxes;
   bool    theHaveFilterSteps;
-  ulong   theNumSteps;
+  u_long   theNumSteps;
 
   NodeSortInfo()
     :
@@ -588,7 +588,7 @@
 
   rchandle<namespace_context>            theNSCtx;
 
-  ulong                                  thePrintDepth;
+  u_long                                  thePrintDepth;
   int                                    theScopeDepth;
 
   user_function                        * theUDF;
@@ -1318,7 +1318,7 @@
 ********************************************************************************/
 void bind_fn(
     function_t& f,
-    ulong nargs,
+    u_long nargs,
     const QueryLoc& loc)
 {
   theSctx->bind_fn(f, nargs, loc);
@@ -1336,7 +1336,7 @@
   Lookup in the sctx the function object for a function with a given prefix
   local name and arity. Return NULL if such a function is not found
 ********************************************************************************/
-function* lookup_fn(const QName* qname, ulong arity, const QueryLoc& loc)
+function* lookup_fn(const QName* qname, u_long arity, const QueryLoc& loc)
 {
   store::Item_t qnameItem;
   expand_function_qname(qnameItem, qname, loc);
@@ -2191,7 +2191,7 @@
 
   if (atlist != NULL)
   {
-    for (ulong i = 0; i < atlist->size(); ++i)
+    for (u_long i = 0; i < atlist->size(); ++i)
     {
       // If current uri is relative, turn it to an absolute one, using the
       // base uri from the sctx.
@@ -3057,7 +3057,7 @@
   }
   else
   {
-    for (ulong i = 0; i < atlist->size(); ++i)
+    for (u_long i = 0; i < atlist->size(); ++i)
     {
       compURIs.push_back(theSctx->resolve_relative_uri((*atlist)[i]).str());
     }
@@ -4649,7 +4649,7 @@
 
   TypeManager* tm = CTX_TM;
 
-  ulong numColumns = v.size();
+  u_long numColumns = v.size();
 
   std::vector<expr*> keyExprs(numColumns);
   std::vector<xqtref_t> keyTypes(numColumns);
@@ -5535,7 +5535,7 @@
   if (theCCB->theConfig.optimize_cb != NULL)
     theCCB->theConfig.optimize_cb(body, msg.str());
 
-  ulong nextVarId = 1;
+  u_long nextVarId = 1;
   PlanIter_t icIter = codegen("integrity constraint", body, theCCB, nextVarId);
 
   // Update static context
@@ -8007,8 +8007,8 @@
 
     if (foArg->get_func()->getKind() == FunctionConsts::OP_OR_N)
     {
-      ulong numArgs = foArg->num_args();
-      for (ulong i = 0; i < numArgs; ++i)
+      u_long numArgs = foArg->num_args();
+      for (u_long i = 0; i < numArgs; ++i)
         args.push_back(foArg->get_arg(i));
     }
     else
@@ -8027,8 +8027,8 @@
 
     if (foArg->get_func()->getKind() == FunctionConsts::OP_OR_N)
     {
-      ulong numArgs = foArg->num_args();
-      for (ulong i = 0; i < numArgs; ++i)
+      u_long numArgs = foArg->num_args();
+      for (u_long i = 0; i < numArgs; ++i)
         args.push_back(foArg->get_arg(i));
     }
     else
@@ -11334,7 +11334,7 @@
     std::vector<expr*> foArgs(arity);
     std::vector<var_expr*> udfArgs(arity);
 
-    for (ulong i = 0; i < arity; ++i)
+    for (u_long i = 0; i < arity; ++i)
     {
       var_expr* argVar = create_temp_var(loc, var_expr::arg_var);
 

=== modified file 'src/compiler/xqddf/value_index.cpp'
--- src/compiler/xqddf/value_index.cpp	2012-10-24 11:32:56 +0000
+++ src/compiler/xqddf/value_index.cpp	2012-12-24 23:39:23 +0000
@@ -566,7 +566,7 @@
 
   expr* buildExpr = getBuildExpr(ccb, loc);
 
-  ulong nextVarId = 1;
+  u_long nextVarId = 1;
   theBuildPlan = codegen("index", buildExpr, ccb, nextVarId);
 
   return theBuildPlan.getp();
@@ -625,7 +625,7 @@
   create_var_expr(sctx, udf, dot->get_loc(), var_expr::prolog_var, docVarName);
 
   docVar->set_unique_id(1);
-  ulong nextVarId = 2;
+  u_long nextVarId = 2;
 
   expr* wrapperExpr = theCCB->theEM->
   create_wrapper_expr(sctx, udf, dot->get_loc(), docVar);

=== modified file 'src/context/default_url_resolvers.cpp'
--- src/context/default_url_resolvers.cpp	2012-11-06 10:11:37 +0000
+++ src/context/default_url_resolvers.cpp	2012-12-24 23:39:23 +0000
@@ -113,12 +113,14 @@
   if (lScheme != uri::file) {
     return NULL;
   }
-  zstring lPath = fs::get_normalized_path(aUrl);
+#ifdef ZORBA_WITH_FILE_ACCESS
+  zstring lPath = fs::get_normalized_path(aUrl);  
   if (fs::get_type(lPath) == fs::file) {
     std::ifstream* lStream = new std::ifstream(lPath.c_str());
     return new StreamResource(
         lStream, &fileStreamReleaser, "", true /* seekable */);
   }
+#endif
   return NULL;
 }
 

=== modified file 'src/context/dynamic_context.cpp'
--- src/context/dynamic_context.cpp	2012-12-11 00:22:26 +0000
+++ src/context/dynamic_context.cpp	2012-12-24 23:39:23 +0000
@@ -417,27 +417,27 @@
 /*******************************************************************************
 
 ********************************************************************************/
-void dynamic_context::add_variable(ulong varid, store::Iterator_t& value) 
-{
-  declare_variable(varid);
-  set_variable(varid, NULL, QueryLoc::null, value);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-void dynamic_context::add_variable(ulong varid, store::Item_t& value) 
-{
-  declare_variable(varid);
-  set_variable(varid, NULL, QueryLoc::null, value);
-}
-
-
-/*******************************************************************************
-
-********************************************************************************/
-void dynamic_context::declare_variable(ulong varid)
+void dynamic_context::add_variable(u_long varid, store::Iterator_t& value) 
+{
+  declare_variable(varid);
+  set_variable(varid, NULL, QueryLoc::null, value);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void dynamic_context::add_variable(u_long varid, store::Item_t& value) 
+{
+  declare_variable(varid);
+  set_variable(varid, NULL, QueryLoc::null, value);
+}
+
+
+/*******************************************************************************
+
+********************************************************************************/
+void dynamic_context::declare_variable(u_long varid)
 {
   assert(varid > 0);
 
@@ -453,7 +453,7 @@
 
 ********************************************************************************/
 void dynamic_context::set_variable(
-    ulong varid,
+    u_long varid,
     const store::Item_t& varname,
     const QueryLoc& loc,
     store::Iterator_t& valueIter)
@@ -507,7 +507,7 @@
 
 ********************************************************************************/
 void dynamic_context::set_variable(
-    ulong varid,
+    u_long varid,
     const store::Item_t& varname,
     const QueryLoc& loc,
     store::Item_t& valueItem)
@@ -551,7 +551,7 @@
 
 ********************************************************************************/
 void dynamic_context::unset_variable(
-    ulong varid,
+    u_long varid,
     const store::Item_t& varname,
     const QueryLoc& loc)
 {
@@ -592,7 +592,7 @@
 
 ********************************************************************************/
 void dynamic_context::get_variable(
-    ulong varid,
+    u_long varid,
     const store::Item_t& varname,
     const QueryLoc& loc,
     store::Item_t& itemValue,
@@ -628,7 +628,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-bool dynamic_context::is_set_variable(ulong varid) const
+bool dynamic_context::is_set_variable(u_long varid) const
 {
   if (varid >= theVarValues.size() ||
       theVarValues[varid].theState == VarValue::undeclared ||
@@ -644,7 +644,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-bool dynamic_context::exists_variable(ulong varid) const
+bool dynamic_context::exists_variable(u_long varid) const
 {
   if (varid >= theVarValues.size() ||
       theVarValues[varid].theState == VarValue::undeclared)
@@ -659,7 +659,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-ulong dynamic_context::get_next_var_id() const
+u_long dynamic_context::get_next_var_id() const
 {
   // 0 is reserved as an invalide var id, and 1 is taken by the context item
   // in the main module.

=== modified file 'src/context/dynamic_context.h'
--- src/context/dynamic_context.h	2012-10-22 17:08:12 +0000
+++ src/context/dynamic_context.h	2012-12-24 23:39:23 +0000
@@ -173,42 +173,42 @@
 
   const std::vector<VarValue>& get_variables() const { return theVarValues; }
 
-  void add_variable(ulong varid, store::Item_t& value);
-
-  void add_variable(ulong varid, store::Iterator_t& value);
-
-  void declare_variable(ulong varid);
+  void add_variable(u_long varid, store::Item_t& value);
+
+  void add_variable(u_long varid, store::Iterator_t& value);
+
+  void declare_variable(u_long varid);
 
   void set_variable(
-      ulong varid,
+      u_long varid,
       const store::Item_t& varname,
       const QueryLoc& loc,
       store::Item_t& value);
 
   void set_variable(
-      ulong varid, 
+      u_long varid, 
       const store::Item_t& varname,
       const QueryLoc& loc,
       store::Iterator_t& value);
 
   void unset_variable(
-      ulong varid, 
+      u_long varid, 
       const store::Item_t& varname,
       const QueryLoc& loc);
 
 
   void get_variable(
-        ulong varid,
+        u_long varid,
         const store::Item_t& varname,
         const QueryLoc& loc,
         store::Item_t& itemValue,
         store::TempSeq_t& seqValue) const;
 
-  bool is_set_variable(ulong varid) const;
-
-  bool exists_variable(ulong varid) const;
-
-  ulong get_next_var_id() const;
+  bool is_set_variable(u_long varid) const;
+
+  bool exists_variable(u_long varid) const;
+
+  u_long get_next_var_id() const;
 
   store::Index* getIndex(store::Item* qname) const;
 

=== modified file 'src/context/namespace_context.cpp'
--- src/context/namespace_context.cpp	2012-09-19 21:16:15 +0000
+++ src/context/namespace_context.cpp	2012-12-24 23:39:23 +0000
@@ -128,14 +128,14 @@
   while (parentContext)
   {
     const store::NsBindings& parentBindings = parentContext->m_bindings;
-    ulong parentSize = (ulong)parentBindings.size();
-    ulong currSize = (ulong)bindings.size();
+    u_long parentSize = (u_long)parentBindings.size();
+    u_long currSize = (u_long)bindings.size();
 
     // for each parent binding, add it to the result, if it doesn't have the
     // same prefix as another binding that is already in the result.
-    for (ulong i = 0; i < parentSize; ++i)
+    for (u_long i = 0; i < parentSize; ++i)
     {
-      ulong j;
+      u_long j;
       for (j = 0; j < currSize; ++j)
       {
         if (bindings[j].first == parentBindings[i].first)

=== modified file 'src/context/static_context.cpp'
--- src/context/static_context.cpp	2012-12-11 20:27:40 +0000
+++ src/context/static_context.cpp	2012-12-24 23:39:23 +0000
@@ -2157,7 +2157,7 @@
 
         // Ignore duplicates
         const zstring& prefix = binding.first;
-        ulong numBindings = (ulong)bindings.size();
+        u_long numBindings = (u_long)bindings.size();
         bool found = 0;
         for (unsigned int i = 0; i < numBindings; ++i)
         {
@@ -2382,7 +2382,7 @@
 ********************************************************************************/
 void static_context::bind_fn(
     function_t& f,
-    ulong arity,
+    u_long arity,
     const QueryLoc& loc)
 {
   store::Item* qname = f->getName();
@@ -2394,7 +2394,7 @@
 
   if (theFunctionMap == NULL)
   {
-    ulong size = (is_global_root_sctx() ? 500 : 32);
+    u_long size = (is_global_root_sctx() ? 500 : 32);
     theFunctionMap = new FunctionMap(HashMapItemPointerCmp(0, NULL), size, false);
   }
 
@@ -2456,7 +2456,7 @@
 ********************************************************************************/
 void static_context::unbind_fn(
     const store::Item* qname,
-    ulong arity)
+    u_long arity)
 {
   ZORBA_ASSERT(!is_global_root_sctx());
 
@@ -2525,7 +2525,7 @@
 ********************************************************************************/
 function* static_context::lookup_fn(
     const store::Item* qname,
-    ulong arity,
+    u_long arity,
     bool skipDisabled)
 {
   FunctionInfo fi;
@@ -2580,7 +2580,7 @@
 ********************************************************************************/
 function* static_context::lookup_local_fn(
     const store::Item* qname,
-    ulong arity,
+    u_long arity,
     bool skipDisabled)
 {
   FunctionInfo fi;
@@ -2708,8 +2708,8 @@
       {
         std::vector<FunctionInfo>* fv = (*ite).second;
 
-        ulong numFunctions = (ulong)fv->size();
-        for (ulong i = 0; i < numFunctions; ++i)
+        u_long numFunctions = (u_long)fv->size();
+        for (u_long i = 0; i < numFunctions; ++i)
         {
           function* f = (*fv)[i].theFunction.getp();
 
@@ -2782,8 +2782,8 @@
 
   if (theFunctionArityMap != NULL && theFunctionArityMap->get(qname2, fv))
   {
-    ulong numFunctions = (ulong)fv->size();
-    for (ulong i = 0; i < numFunctions; ++i)
+    u_long numFunctions = (u_long)fv->size();
+    for (u_long i = 0; i < numFunctions; ++i)
     {
       if (!(*fv)[i].theIsDisabled)
         functions.push_back((*fv)[i].theFunction.getp());
@@ -4113,7 +4113,7 @@
     if (theFunctionMap == NULL)
     {
       theFunctionMap = new FunctionMap(HashMapItemPointerCmp(0, NULL),
-                                       (ulong)module->theFunctionMap->capacity(),
+                                       (u_long)module->theFunctionMap->capacity(),
                                        false);
     }
 
@@ -4133,7 +4133,7 @@
     {
       theFunctionArityMap =
       new FunctionArityMap(HashMapItemPointerCmp(0, NULL),
-                           (ulong)module->theFunctionArityMap->capacity(),
+                           (u_long)module->theFunctionArityMap->capacity(),
                            false);
     }
 

=== modified file 'src/context/static_context.h'
--- src/context/static_context.h	2012-12-06 01:17:18 +0000
+++ src/context/static_context.h	2012-12-24 23:39:23 +0000
@@ -160,7 +160,7 @@
 protected:
   store::Item_t  theName;
 
-  ulong          theId;
+  u_long          theId;
 
   int            theKind;
 
@@ -186,9 +186,9 @@
 
   const store::Item_t& getName() const { return theName; }
 
-  ulong getId() const { return theId; }
+  u_long getId() const { return theId; }
 
-  void setId(ulong id) { theId = id; }
+  void setId(u_long id) { theId = id; }
 
   int getKind() const { return theKind; }
 
@@ -891,18 +891,18 @@
   //
   // Functions
   //
-  void bind_fn(function_t& f, ulong arity, const QueryLoc& loc);
+  void bind_fn(function_t& f, u_long arity, const QueryLoc& loc);
 
-  void unbind_fn(const store::Item* qname, ulong arity);
+  void unbind_fn(const store::Item* qname, u_long arity);
 
   function* lookup_fn(
       const store::Item* qname,
-      ulong arity,
+      u_long arity,
       bool skipDisabled = true);
 
   function* lookup_local_fn(
       const store::Item* qname,
-      ulong arity,
+      u_long arity,
       bool skipDisabled = true);
 
   void get_functions(std::vector<function*>& functions) const;

=== modified file 'src/functions/function.cpp'
--- src/functions/function.cpp	2012-09-19 21:16:15 +0000
+++ src/functions/function.cpp	2012-12-24 23:39:23 +0000
@@ -102,7 +102,7 @@
 ********************************************************************************/
 bool function::validate_args(std::vector<PlanIter_t>& argv) const
 {
-  ulong n = theSignature.paramCount();
+  u_long n = theSignature.paramCount();
   return n == VARIADIC_SIG_SIZE || argv.size() == n;
 }
 

=== modified file 'src/functions/function_impl.h'
--- src/functions/function_impl.h	2012-09-19 21:16:15 +0000
+++ src/functions/function_impl.h	2012-12-24 23:39:23 +0000
@@ -46,7 +46,7 @@
   {                                                                     \
     function_t type##_ptr(new type(signature sig, kind));               \
     const store::Item* fname = type##_ptr->getName();                   \
-    ulong cnt = type##_ptr->getSignature().paramCount();                \
+    u_long cnt = type##_ptr->getSignature().paramCount();                \
     DEBUG_FN_DECL(fname, cnt);                                          \
     sctx->bind_fn(type##_ptr, cnt, QueryLoc::null);                     \
     BuiltinFunctionLibrary::theFunctions[type##_ptr->getKind()] = type##_ptr.getp(); \
@@ -57,7 +57,7 @@
   {                                                                     \
     function_t type##_ptr(new type(signature sig));                     \
     const store::Item* fname = type##_ptr->getName();                   \
-    ulong cnt = type##_ptr->getSignature().paramCount();                \
+    u_long cnt = type##_ptr->getSignature().paramCount();                \
     DEBUG_FN_DECL(fname, cnt);                                          \
     sctx->bind_fn(type##_ptr, cnt, QueryLoc::null);                     \
     BuiltinFunctionLibrary::theFunctions[type##_ptr->getKind()] = type##_ptr.getp(); \

=== modified file 'src/functions/udf.cpp'
--- src/functions/udf.cpp	2012-10-20 21:29:37 +0000
+++ src/functions/udf.cpp	2012-12-24 23:39:23 +0000
@@ -539,7 +539,7 @@
       argVarToRefsMap.put((uint64_t)&*theArgVars[i], &theArgVarsRefs[i]);
     }
 
-    ulong nextVarId = 1;
+    u_long nextVarId = 1;
     const store::Item* lName = getName();
     //lName may be null of inlined functions
     thePlan = zorba::codegen((lName == 0 ?

=== modified file 'src/runtime/core/apply_updates.cpp'
--- src/runtime/core/apply_updates.cpp	2012-12-01 00:06:15 +0000
+++ src/runtime/core/apply_updates.cpp	2012-12-24 23:39:23 +0000
@@ -95,7 +95,7 @@
   CompilerCB* ccb = planState.theCompilerCB;
 
   store::Item_t item;
-  ulong numItems = 0;
+  u_long numItems = 0;
   store::PUL_t pul;
 
   ApplyIteratorState* state;
@@ -209,7 +209,7 @@
     {
       indexPul = GENV_ITEMFACTORY->createPendingUpdateList();
 
-      for (ulong i = 0; i < numIndices; ++i)
+      for (u_long i = 0; i < numIndices; ++i)
       {
         IndexDecl* zorbaIndex = zorbaIndexes[i];
 

=== modified file 'src/runtime/core/flwor_iterator.cpp'
--- src/runtime/core/flwor_iterator.cpp	2012-10-08 12:09:36 +0000
+++ src/runtime/core/flwor_iterator.cpp	2012-12-24 23:39:23 +0000
@@ -946,7 +946,7 @@
 ********************************************************************************/
 bool FLWORIterator::nextImpl(store::Item_t& result, PlanState& planState) const
 {
-  ulong curVar = 0;
+  u_long curVar = 0;
   store::Item_t curItem;
 
   FlworState* state;
@@ -1004,7 +1004,7 @@
               }
 
               state->theCurTuplePos = 0;
-              state->theNumTuples = (ulong)state->theTuplesTable.size();
+              state->theNumTuples = (u_long)state->theTuplesTable.size();
 
               while (state->theCurTuplePos < state->theNumTuples)
               {
@@ -1030,7 +1030,7 @@
             else
             {
               state->theCurTuplePos = 0;
-              state->theNumTuples = (ulong)state->theTuplesTable.size();
+              state->theNumTuples = (u_long)state->theTuplesTable.size();
 
               while (state->theCurTuplePos < state->theNumTuples)
               {
@@ -1080,7 +1080,7 @@
             }
 
             state->theCurTuplePos = 0;
-            state->theNumTuples = (ulong)state->theSortTable.size();
+            state->theNumTuples = (u_long)state->theSortTable.size();
 
             while (state->theCurTuplePos < state->theNumTuples)
             {
@@ -1192,7 +1192,7 @@
   false otherwise.
 ********************************************************************************/
 bool FLWORIterator::bindVariable(
-    ulong varNo,
+    u_long varNo,
     FlworState* iterState,
     PlanState& planState) const
 {
@@ -1518,7 +1518,7 @@
   that appear after the groupby clause. 
 ********************************************************************************/
 void FLWORIterator::rebindStreamTuple( 
-    ulong tuplePos,
+    u_long tuplePos,
     FlworState* iterState,
     PlanState& planState) const
 {

=== modified file 'src/runtime/core/flwor_iterator.h'
--- src/runtime/core/flwor_iterator.h	2012-09-19 21:16:15 +0000
+++ src/runtime/core/flwor_iterator.h	2012-12-24 23:39:23 +0000
@@ -375,9 +375,9 @@
 
   ResultTable                    theResultTable;
 
-  ulong                          theNumTuples;
+  u_long                          theNumTuples;
 
-  ulong                          theCurTuplePos;
+  u_long                          theCurTuplePos;
 
   store::Iterator_t              theOrderResultIter; 
 
@@ -470,7 +470,7 @@
 
 private:
   bool bindVariable(
-      ulong varNo,
+      u_long varNo,
       FlworState* flworState,
       PlanState& planState) const;
 
@@ -491,7 +491,7 @@
       PlanState& planState) const;
 
   void rebindStreamTuple(
-      ulong tuplePos, 
+      u_long tuplePos, 
       FlworState* iterState,
       PlanState& planState) const;
 

=== modified file 'src/runtime/core/fncall_iterator.cpp'
--- src/runtime/core/fncall_iterator.cpp	2012-11-26 20:49:01 +0000
+++ src/runtime/core/fncall_iterator.cpp	2012-12-24 23:39:23 +0000
@@ -735,9 +735,9 @@
   ExtFunctionCallIteratorState* state =
   StateTraitsImpl<ExtFunctionCallIteratorState>::getState(planState,
                                                           theStateOffset);
-  ulong n = (ulong)theChildren.size();
+  u_long n = (u_long)theChildren.size();
   state->m_extArgs.resize(n);
-  for(ulong i = 0; i < n; ++i)
+  for(u_long i = 0; i < n; ++i)
   {
     state->m_extArgs[i] = new ExtFuncArgItemSequence(theChildren[i], planState);
     // the iterator does not have exlcusive ownership over the sequences

=== modified file 'src/runtime/core/gflwor/common.h'
--- src/runtime/core/gflwor/common.h	2012-10-08 12:09:36 +0000
+++ src/runtime/core/gflwor/common.h	2012-12-24 23:39:23 +0000
@@ -281,7 +281,7 @@
   size_t numIters = sourceVector.size();
   destVector.resize(numIters);
 
-  for (ulong i = 0; i < numIters; ++i)
+  for (u_long i = 0; i < numIters; ++i)
     destVector[i] = reinterpret_cast<T*>(sourceVector[i].getp());
  }
 

=== modified file 'src/runtime/core/gflwor/groupby_iterator.cpp'
--- src/runtime/core/gflwor/groupby_iterator.cpp	2012-10-08 12:09:36 +0000
+++ src/runtime/core/gflwor/groupby_iterator.cpp	2012-12-24 23:39:23 +0000
@@ -173,16 +173,16 @@
   int32_t size = this->getStateSize();
   size  += theTupleIter->getStateSizeOfSubtree();
 
-  ulong numSpecs = (ulong)theGroupingSpecs.size();
+  u_long numSpecs = (u_long)theGroupingSpecs.size();
 
-  for (ulong i = 0; i < numSpecs; ++i)
+  for (u_long i = 0; i < numSpecs; ++i)
   {
     size += theGroupingSpecs[i].getStateSizeOfSubtree();
   }
 
-  numSpecs = (ulong)theNonGroupingSpecs.size();
+  numSpecs = (u_long)theNonGroupingSpecs.size();
 
-  for (ulong i = 0; i < numSpecs; ++i)
+  for (u_long i = 0; i < numSpecs; ++i)
   {
     size += theNonGroupingSpecs[i].getStateSizeOfSubtree();
   }

=== modified file 'src/runtime/core/gflwor/orderby_iterator.cpp'
--- src/runtime/core/gflwor/orderby_iterator.cpp	2012-09-19 21:16:15 +0000
+++ src/runtime/core/gflwor/orderby_iterator.cpp	2012-12-24 23:39:23 +0000
@@ -160,9 +160,9 @@
 
 void OrderByState::clearSortTable()
 {
-  ulong numTuples = (ulong)theSortTable.size();
+  u_long numTuples = (u_long)theSortTable.size();
 
-  for (ulong i = 0; i < numTuples; ++i)
+  for (u_long i = 0; i < numTuples; ++i)
   {
     theSortTable[i].clear();
   }
@@ -241,15 +241,15 @@
 {
   v.beginVisit(*this);
 
-  ulong numVars = (ulong)theInputForVars.size();
-  for (ulong i = 0; i < numVars; ++i)
+  u_long numVars = (u_long)theInputForVars.size();
+  for (u_long i = 0; i < numVars; ++i)
   {
     v.beginVisitOrderByForVariable(theInputForVars[i], theOutputForVarsRefs[i]);
     v.endVisitOrderByForVariable();
   }
 
-  numVars = (ulong)theInputLetVars.size();
-  for (ulong i = 0; i < numVars; ++i)
+  numVars = (u_long)theInputLetVars.size();
+  for (u_long i = 0; i < numVars; ++i)
   {
     v.beginVisitOrderByLetVariable(theInputLetVars[i], theOutputLetVarsRefs[i]);
     v.endVisitOrderByLetVariable();
@@ -271,8 +271,8 @@
                                                                     theStateOffset);
 
   // Do a manual pass to set the Collator
-  ulong numSpecs = (ulong)theOrderSpecs.size();
-  for (ulong i = 0; i < numSpecs; ++i)
+  u_long numSpecs = (u_long)theOrderSpecs.size();
+  for (u_long i = 0; i < numSpecs; ++i)
   {
     theOrderSpecs[i].open(planState, aOffset);
 
@@ -348,7 +348,7 @@
   }
 
   iterState->theCurTuplePos = 0;
-  iterState->theNumTuples = (ulong)iterState->theSortTable.size();
+  iterState->theNumTuples = (u_long)iterState->theSortTable.size();
 
   while(iterState->theCurTuplePos < iterState->theNumTuples)
   {
@@ -450,14 +450,14 @@
   StreamTuple& streamTuple = 
   iterState->theDataTable[iterState->theSortTable[iterState->theCurTuplePos].theDataPos];
 
-  ulong numForVarsRefs = (ulong)theOutputForVarsRefs.size();
-  for (ulong i = 0; i < numForVarsRefs; ++i)
+  u_long numForVarsRefs = (u_long)theOutputForVarsRefs.size();
+  for (u_long i = 0; i < numForVarsRefs; ++i)
   {
     bindVariables(streamTuple.theItems[i], theOutputForVarsRefs[i], planState);
   }
 
-  ulong numLetVarsRefs = (ulong)theOutputLetVarsRefs.size();
-  for(ulong i = 0; i < numLetVarsRefs; ++i)
+  u_long numLetVarsRefs = (u_long)theOutputLetVarsRefs.size();
+  for(u_long i = 0; i < numLetVarsRefs; ++i)
   {
     bindVariables(streamTuple.theSequences[i], theOutputLetVarsRefs[i], planState);
   }

=== modified file 'src/runtime/core/gflwor/orderby_iterator.h'
--- src/runtime/core/gflwor/orderby_iterator.h	2012-09-19 21:16:15 +0000
+++ src/runtime/core/gflwor/orderby_iterator.h	2012-12-24 23:39:23 +0000
@@ -116,7 +116,7 @@
 {
 public:
   std::vector<store::Item*>   theKeyValues;
-  ulong                       theDataPos;
+  u_long                       theDataPos;
 
 public:
   SortTuple() { }
@@ -125,8 +125,8 @@
 
   void clear()
   {
-    ulong numColumns = (ulong)theKeyValues.size();
-    for (ulong i = 0; i < numColumns; ++i)
+    u_long numColumns = (u_long)theKeyValues.size();
+    for (u_long i = 0; i < numColumns; ++i)
     {
       if (theKeyValues[i] != NULL)
       {
@@ -159,8 +159,8 @@
 protected:
   SortTable    theSortTable;
   DataTable    theDataTable;
-  ulong        theNumTuples;
-  ulong        theCurTuplePos;
+  u_long        theNumTuples;
+  u_long        theCurTuplePos;
 
 public:
   OrderByState();

=== modified file 'src/runtime/core/gflwor/window_iterator.cpp'
--- src/runtime/core/gflwor/window_iterator.cpp	2012-09-19 21:16:15 +0000
+++ src/runtime/core/gflwor/window_iterator.cpp	2012-12-24 23:39:23 +0000
@@ -186,7 +186,7 @@
 void WindowVars::bindIntern(
     PlanState& planState,
     const store::TempSeq_t& inputSeq,
-    const ulong pos) const
+    const u_long pos) const
 {
   store::Item_t item;
 
@@ -234,7 +234,7 @@
 void WindowVars::bindExtern(
     PlanState& planState,
     const store::TempSeq_t& inputSeq,
-    const ulong pos) const
+    const u_long pos) const
 {
   store::Item_t item;
 
@@ -360,7 +360,7 @@
 bool StartClause::evaluate(
     PlanState& planState,
     const store::TempSeq_t& inputSeq,
-    const ulong pos) const
+    const u_long pos) const
 {
   theWindowVars.bindIntern(planState, inputSeq, pos);
 
@@ -376,7 +376,7 @@
 void StartClause::bindExtern(
     PlanState& planState,
     const store::TempSeq_t& inputSeq,
-    const ulong pos) const
+    const u_long pos) const
 {
   theWindowVars.bindExtern(planState, inputSeq, pos);
 }
@@ -388,7 +388,7 @@
 void StartClause::bindIntern(
     PlanState& planState,
     const store::TempSeq_t& inputSeq,
-    const ulong pos) const
+    const u_long pos) const
 {
   theWindowVars.bindIntern(planState, inputSeq, pos);
 }
@@ -512,7 +512,7 @@
 bool EndClause::evaluate(
     PlanState& planState,
     const store::TempSeq_t& inputSeq,
-    const ulong pos) const
+    const u_long pos) const
 {
   theWindowVars.bindIntern(planState, inputSeq, pos);
 
@@ -526,7 +526,7 @@
 void EndClause::bindIntern(
     PlanState& planState,
     const store::TempSeq_t& inputSeq,
-    const ulong pos) const
+    const u_long pos) const
 {
   theWindowVars.bindIntern(planState, inputSeq, pos);
 }
@@ -538,7 +538,7 @@
 void EndClause::bindExtern(
     PlanState& planState,
     const store::TempSeq_t& inputSeq,
-    const ulong pos) const
+    const u_long pos) const
 {
   theWindowVars.bindExtern(planState, inputSeq, pos);
 }
@@ -555,7 +555,7 @@
 {
 }
 
-WindowDef::WindowDef(ulong aStartPos) : theStartPos(aStartPos), theEndPos(0)
+WindowDef::WindowDef(u_long aStartPos) : theStartPos(aStartPos), theEndPos(0)
 {
 }
 
@@ -600,7 +600,7 @@
 //                                                                             //
 /////////////////////////////////////////////////////////////////////////////////
 
-const ulong WindowIterator::MAX_HISTORY = 2147483647; //TODO should be set platform dependent, but somebody hat comment out everything in platform.h!
+const u_long WindowIterator::MAX_HISTORY = 2147483647; //TODO should be set platform dependent, but somebody hat comment out everything in platform.h!
 
 
 /***************************************************************************//**
@@ -617,7 +617,7 @@
     StartClause& startClause,
     EndClause& endClause,
     bool lazyEval,
-    ulong maxNeededHistory)
+    u_long maxNeededHistory)
   :
   Batcher<WindowIterator>(sctx, loc),
   theWindowType(windowType),
@@ -759,8 +759,8 @@
 void WindowIterator::bindVariable(
     PlanState& planState,
     store::TempSeq_t& inputSeq,
-    ulong aStartPos,
-    ulong aEndPos) const
+    u_long aStartPos,
+    u_long aEndPos) const
 {
   xs_integer const lStartPos( aStartPos );
   xs_integer const lEndPos( aEndPos );
@@ -848,7 +848,7 @@
                                       state->theDomainSeq,
                                       state->theCurWindow->theStartPos);
 
-            ulong lCurPos = state->theCurInputPos;
+            u_long lCurPos = state->theCurInputPos;
             if ( theEndClause.evaluate(planState,
                                        state->theDomainSeq,
                                        lCurPos))

=== modified file 'src/runtime/core/gflwor/window_iterator.h'
--- src/runtime/core/gflwor/window_iterator.h	2012-09-19 21:16:15 +0000
+++ src/runtime/core/gflwor/window_iterator.h	2012-12-24 23:39:23 +0000
@@ -98,12 +98,12 @@
   void bindIntern(
       PlanState& planState,
       const store::TempSeq_t& inSeq,
-      ulong pos) const;
+      u_long pos) const;
 
   void bindExtern(
       PlanState& planState,
       const store::TempSeq_t& inSeq,
-      ulong pos) const;
+      u_long pos) const;
 };
 
 
@@ -150,17 +150,17 @@
   bool evaluate(
       PlanState& planState,
       const store::TempSeq_t& inSeq,
-      ulong pos) const;
+      u_long pos) const;
 
   void bindIntern(
       PlanState& planState,
       const store::TempSeq_t& inSeq,
-      ulong pos) const;
+      u_long pos) const;
 
   void bindExtern(
       PlanState& planState,
       const store::TempSeq_t& inSeq,
-      ulong pos) const;
+      u_long pos) const;
 };
 
 
@@ -224,17 +224,17 @@
   bool evaluate(
       PlanState& planState,
       const store::TempSeq_t& inSeq,
-      ulong pos) const;
+      u_long pos) const;
 
   void bindIntern(
       PlanState& planState,
       const store::TempSeq_t& inSeq,
-      ulong pos) const;
+      u_long pos) const;
 
   void bindExtern(
       PlanState& planState,
       const store::TempSeq_t& inSeq,
-      ulong pos) const;
+      u_long pos) const;
 };
 
 
@@ -255,11 +255,11 @@
 class WindowDef
 {
 public:
-	ulong theStartPos;
-	ulong theEndPos;
+	u_long theStartPos;
+	u_long theEndPos;
 
 public:
-	WindowDef(ulong aStartPos);
+	WindowDef(u_long aStartPos);
 
 	~WindowDef();
 };
@@ -281,7 +281,7 @@
 
 protected:
   store::TempSeq_t                 theDomainSeq;
-  ulong                            theCurInputPos;
+  u_long                            theCurInputPos;
   std::vector<WindowDef>           theOpenWindows;
   std::vector<WindowDef>::iterator theCurWindow;
 
@@ -315,7 +315,7 @@
 class WindowIterator : public Batcher<WindowIterator>
 {
 public:
-  static const ulong MAX_HISTORY;
+  static const u_long MAX_HISTORY;
 
   enum WindowType
   {
@@ -336,7 +336,7 @@
   EndClause                  theEndClause;
 
   bool                       theLazyEval;
-  ulong                      theMaxNeededHistory;
+  u_long                      theMaxNeededHistory;
 
 public:
   SERIALIZABLE_CLASS(WindowIterator);
@@ -360,7 +360,7 @@
         StartClause& startClause,
         EndClause& endClause,
         bool lazyEval,
-        ulong maxNeededHistory = MAX_HISTORY);
+        u_long maxNeededHistory = MAX_HISTORY);
 
   ~WindowIterator();
 
@@ -379,8 +379,8 @@
   void bindVariable(
         PlanState& planState,
         store::TempSeq_t& aInputSeq,
-        ulong aStartPos,
-        ulong aEndPos) const;
+        u_long aStartPos,
+        u_long aEndPos) const;
 
   void doGarbageCollection(WindowState* lState) const;
 };

=== modified file 'src/runtime/core/path.cpp'
--- src/runtime/core/path.cpp	2012-09-19 21:16:15 +0000
+++ src/runtime/core/path.cpp	2012-12-24 23:39:23 +0000
@@ -269,8 +269,8 @@
 ********************************************************************************/
 DescendantStepState::~DescendantStepState()
 {
-  ulong len = theCurrentPath.size();
-  for (ulong i = 0; i < len; i++)
+  u_long len = theCurrentPath.size();
+  for (u_long i = 0; i < len; i++)
   {
     delete theCurrentPath[i].second;
   }
@@ -303,8 +303,8 @@
 ********************************************************************************/
 PathIteratorState::~PathIteratorState()
 {
-  ulong numSteps = theStepStates.size();
-  for (ulong i = 0; i < numSteps; i++)
+  u_long numSteps = theStepStates.size();
+  for (u_long i = 0; i < numSteps; i++)
     delete theStepStates[i];
 }
 
@@ -321,7 +321,7 @@
 
   theCurrentStep = 0;
 
-  for (ulong i = 0; i < theNumSteps; i++)
+  for (u_long i = 0; i < theNumSteps; i++)
     theStepStates[i]->reset();
 }
 
@@ -331,8 +331,8 @@
 ********************************************************************************/
 PathIterator::~PathIterator() 
 {
-  ulong numSteps = theAxes.size();
-  for (ulong i = 0; i < numSteps; i++)
+  u_long numSteps = theAxes.size();
+  for (u_long i = 0; i < numSteps; i++)
     delete theNodePreds[i];
 }
 
@@ -351,11 +351,11 @@
   PathIteratorState* state;
   state = StateTraitsImpl<PathIteratorState>::getState(planState, this->stateOffset);
 
-  ulong numSteps = theAxes.size();
+  u_long numSteps = theAxes.size();
   state->theNumSteps = numSteps;
   state->theStepStates.resize(numSteps);
 
-  for (ulong i = 0; i < numSteps; i++)
+  for (u_long i = 0; i < numSteps; i++)
   {
     switch (theAxes[i])
     {
@@ -402,7 +402,7 @@
 
 bool PathIterator::nextImpl(store::Item_t& result, PlanState& planState) const
 {
-  ulong curStep;
+  u_long curStep;
   axis_kind_t curAxis;
   NodePredicate* curPred;
   store::Item* curResult;

=== modified file 'src/runtime/core/path.h'
--- src/runtime/core/path.h	2012-09-19 21:16:15 +0000
+++ src/runtime/core/path.h	2012-12-24 23:39:23 +0000
@@ -194,7 +194,7 @@
 class DescendantStepState : public PathStepState
 {
 public:
-  ulong theTop;
+  u_long theTop;
   std::vector<std::pair<store::Item*, store::ChildrenIterator*> > theCurrentPath;
 
 public:
@@ -266,9 +266,9 @@
 public:
   store::Item_t                theContextNode;   
 
-  ulong                        theCurrentStep;
+  u_long                        theCurrentStep;
 
-  ulong                        theNumSteps;
+  u_long                        theNumSteps;
 
   std::vector<PathStepState*>  theStepStates;
 

=== modified file 'src/runtime/core/path_iterators.cpp'
--- src/runtime/core/path_iterators.cpp	2012-10-12 21:07:51 +0000
+++ src/runtime/core/path_iterators.cpp	2012-12-24 23:39:23 +0000
@@ -1181,8 +1181,8 @@
 ********************************************************************************/
 DescendantAxisState::~DescendantAxisState()
 {
-  ulong len = (ulong)theCurrentPath.size();
-  for (ulong i = 0; i < len; ++i)
+  u_long len = (u_long)theCurrentPath.size();
+  for (u_long i = 0; i < len; ++i)
   {
     delete theCurrentPath[i].second;
   }
@@ -1595,8 +1595,8 @@
   if (theAncestor.second != NULL)
     delete theAncestor.second;
 
-  ulong len = (ulong)theCurrentPath.size();
-  for (ulong i = 0; i < len; ++i)
+  u_long len = (u_long)theCurrentPath.size();
+  for (u_long i = 0; i < len; ++i)
   {
     delete theCurrentPath[i].second;
   }
@@ -1616,7 +1616,7 @@
 {
   AxisState::reset(planState);
 
-  for (ulong i = 0; i < theTop; ++i)
+  for (u_long i = 0; i < theTop; ++i)
   {
     theCurrentPath[i].second->close();
   }

=== modified file 'src/runtime/core/path_iterators.h'
--- src/runtime/core/path_iterators.h	2012-09-19 21:16:15 +0000
+++ src/runtime/core/path_iterators.h	2012-12-24 23:39:23 +0000
@@ -603,7 +603,7 @@
   typedef std::pair<const store::Item*, store::ChildrenIterator*> PathPair;
 
 public:
-  ulong                 theTop;
+  u_long                theTop;
   std::vector<PathPair> theCurrentPath;
 
 public:
@@ -622,7 +622,7 @@
 
   void clear()
   {
-    for (ulong i = 0; i < theTop; ++i)
+    for (u_long i = 0; i < theTop; ++i)
     {
       theCurrentPath[i].second->close();
     }
@@ -788,7 +788,7 @@
   PathPair                  theAncestor;
   const store::Item*        theAncestorChild;
 
-  ulong                     theTop;
+  u_long                    theTop;
   std::vector<PathPair>     theCurrentPath;
 
   PrecedingReverseAxisState();

=== modified file 'src/runtime/core/trycatch.h'
--- src/runtime/core/trycatch.h	2012-09-19 21:16:15 +0000
+++ src/runtime/core/trycatch.h	2012-12-24 23:39:23 +0000
@@ -65,7 +65,7 @@
     };
 
   public:
-    typedef std::map<ulong, std::vector<LetVarIter_t> > VarMap_t;
+    typedef std::map<u_long, std::vector<LetVarIter_t> > VarMap_t;
 
   public:
     std::vector<NodeNameTest_t> node_names;

=== modified file 'src/runtime/core/var_iterators.cpp'
--- src/runtime/core/var_iterators.cpp	2012-10-08 12:09:36 +0000
+++ src/runtime/core/var_iterators.cpp	2012-12-24 23:39:23 +0000
@@ -63,7 +63,7 @@
     static_context* sctx,
     const QueryLoc& loc,
     std::vector<PlanIter_t>& args,
-    ulong varid,
+    u_long varid,
     const store::Item_t& varName,
     bool isExtern,
     bool singleItem)
@@ -267,7 +267,7 @@
 CtxVarIterator::CtxVarIterator(
     static_context* sctx,
     const QueryLoc& loc,
-    ulong varid,
+    u_long varid,
     const store::Item_t& varName,
     bool isLocal)
   :

=== modified file 'src/runtime/core/var_iterators.h'
--- src/runtime/core/var_iterators.h	2012-09-19 21:16:15 +0000
+++ src/runtime/core/var_iterators.h	2012-12-24 23:39:23 +0000
@@ -61,7 +61,7 @@
                                                       PlanIteratorState>
 {
 private:
-  ulong         theVarId;
+  u_long         theVarId;
   store::Item_t theVarName;
   bool          theIsExternal;
   bool          theSingleItem;
@@ -80,12 +80,12 @@
         static_context* sctx,
         const QueryLoc& loc,
         std::vector<PlanIter_t>& args,
-        ulong varid,
+        u_long varid,
         const store::Item_t& varName,
         bool isExtern,
         bool singleItem);
 
-  ulong getVarId() const { return theVarId; }
+  u_long getVarId() const { return theVarId; }
 
   const store::Item* getVarName() const { return theVarName.getp(); }
 
@@ -109,7 +109,7 @@
                                                       PlanIteratorState>
 {
 private:
-  ulong         theVarId;
+  u_long         theVarId;
   store::Item_t theVarName;
   bool          theIsLocal;
   bool          theSingleItem;
@@ -127,7 +127,7 @@
   CtxVarAssignIterator(
         static_context* sctx,
         const QueryLoc& loc,
-        ulong varid,
+        u_long varid,
         const store::Item_t& varName,
         bool isLocal,
         PlanIter_t& arg) 
@@ -140,7 +140,7 @@
   {
   }
 
-  ulong getVarId() const { return theVarId; }
+  u_long getVarId() const { return theVarId; }
 
   const store::Item* getVarName() const { return theVarName.getp(); }
 
@@ -163,7 +163,7 @@
                                                        PlanIteratorState>
 {
 private:
-  ulong         theVarId;
+  u_long         theVarId;
   store::Item_t theVarName;
 
 public:
@@ -179,7 +179,7 @@
   CtxVarIsSetIterator(
         static_context* sctx,
         const QueryLoc& loc,
-        ulong varid,
+        u_long varid,
         const store::Item_t& varName) 
     :
     NoaryBaseIterator<CtxVarIsSetIterator, PlanIteratorState>(sctx, loc),
@@ -188,7 +188,7 @@
   {
   }
 
-  ulong getVarId() const { return theVarId; }
+  u_long getVarId() const { return theVarId; }
 
   const store::Item* getVarName() const { return theVarName.getp(); }
 
@@ -243,7 +243,7 @@
 class CtxVarIterator : public NoaryBaseIterator<CtxVarIterator, CtxVarState>
 {
 protected:
-  ulong          theVarId;
+  u_long          theVarId;
   store::Item_t  theVarName;
   bool           theIsLocal;
 
@@ -265,13 +265,13 @@
   CtxVarIterator(
       static_context* sctx,
       const QueryLoc& loc,
-      ulong varid,
+      u_long varid,
       const store::Item_t& varName,
       bool local);
 
   virtual ~CtxVarIterator() {}
 
-  ulong getVarId() const { return theVarId; }
+  u_long getVarId() const { return theVarId; }
 
   const store::Item* getVarName() const { return theVarName.getp(); }
 

=== modified file 'src/runtime/eval/eval.cpp'
--- src/runtime/eval/eval.cpp	2012-10-24 11:32:56 +0000
+++ src/runtime/eval/eval.cpp	2012-12-24 23:39:23 +0000
@@ -155,7 +155,7 @@
     state->dctx.reset(evalDctx);
 
     // Import the outer environment.
-    ulong maxOuterVarId;
+    u_long maxOuterVarId;
     importOuterEnv(planState, evalCCB, importSctx, evalDctx, maxOuterVarId);
 
     // If we are here after a reset, we must set state->thePlanWrapper to NULL
@@ -219,7 +219,7 @@
     CompilerCB* evalCCB,
     static_context* importSctx,
     dynamic_context* evalDctx,
-    ulong& maxOuterVarId) const
+    u_long& maxOuterVarId) const
 {
   maxOuterVarId = 1;
 
@@ -245,7 +245,7 @@
     if (!outerVar.isSet())
       continue;
 
-    ulong outerVarId = static_cast<ulong>(i);
+    u_long outerVarId = static_cast<u_long>(i);
 
     if (outerVarId > maxOuterVarId)
       maxOuterVarId = outerVarId;
@@ -305,7 +305,7 @@
       VarInfo* outerGlobalVar = outerSctx->lookup_var(theOuterVarNames[i]);
       ZORBA_ASSERT(outerGlobalVar);
 
-      ulong outerGlobalVarId = outerGlobalVar->getId();
+      u_long outerGlobalVarId = outerGlobalVar->getId();
 
       ve->set_unique_id(outerGlobalVarId);
     }
@@ -351,7 +351,7 @@
     if (!innerVar->isExternal())
       continue;
 
-    ulong innerVarId = innerVar->getId();
+    u_long innerVarId = innerVar->getId();
 
     VarInfo* outerVar = importSctx->lookup_var(innerVar->getName());
 
@@ -389,7 +389,7 @@
 PlanIter_t EvalIterator::compile(
     CompilerCB* ccb,
     const zstring& query,
-    ulong maxOuterVarId) const
+    u_long maxOuterVarId) const
 {
   std::stringstream os;
 

=== modified file 'src/runtime/eval/eval.h'
--- src/runtime/eval/eval.h	2012-09-19 21:16:15 +0000
+++ src/runtime/eval/eval.h	2012-12-24 23:39:23 +0000
@@ -128,7 +128,7 @@
       CompilerCB* evalCCB,
       static_context* importSctx,
       dynamic_context* evalDctx,
-      ulong& maxOuterVarId) const;
+      u_long& maxOuterVarId) const;
 
   void setExternalVariables(
       CompilerCB* ccb,
@@ -139,7 +139,7 @@
   PlanIter_t compile(
       CompilerCB* ccb,
       const zstring& query,
-      ulong maxOuterVarId) const;
+      u_long maxOuterVarId) const;
 };
 
 

=== modified file 'src/runtime/indexing/doc_indexer.h'
--- src/runtime/indexing/doc_indexer.h	2012-09-19 21:16:15 +0000
+++ src/runtime/indexing/doc_indexer.h	2012-12-24 23:39:23 +0000
@@ -38,7 +38,7 @@
   PlanIter_t          theIndexerPlan;
 
   store::Item_t       theNodeVarName;
-  ulong               theNodeVarId; 
+  u_long              theNodeVarId; 
 
   dynamic_context   * theDctx;
   store::Iterator_t   thePlanWrapper;

=== modified file 'src/runtime/indexing/index_ddl.cpp'
--- src/runtime/indexing/index_ddl.cpp	2012-09-19 21:16:15 +0000
+++ src/runtime/indexing/index_ddl.cpp	2012-12-24 23:39:23 +0000
@@ -74,7 +74,7 @@
     const QueryLoc& loc,
     TypeManager* tm,
     const IndexDecl* indexDecl,
-    ulong keyNo,
+    u_long keyNo,
     store::Item_t& searchKey)
 {
   RootTypeManager& rtm = GENV_TYPESYSTEM;
@@ -601,13 +601,13 @@
   store::Item_t qnameItem;
   store::Item_t keyItem;
   store::IndexCondition_t cond;
-  ulong numChildren = (ulong)theChildren.size();
-  ulong i;
+  u_long numChildren = (u_long)theChildren.size();
+  u_long i;
   bool status;
   TypeManager* tm = theSctx->get_typemanager();
   RootTypeManager& rtm = GENV_TYPESYSTEM;
   xs_integer lSkip = xs_integer::zero();
-  ulong lAmountNonKeyParams = (theSkip ? 2 : 1);
+  u_long lAmountNonKeyParams = (theSkip ? 2 : 1);
 
   try
   {
@@ -795,7 +795,7 @@
 {
   store::Item_t qnameItem;
   store::Item_t keyItem;
-  ulong numChildren = (ulong)theChildren.size();
+  u_long numChildren = (u_long)theChildren.size();
   bool status;
 
   try
@@ -996,12 +996,12 @@
   store::Item_t qname;
   IndexDecl_t indexDecl;
   store::IndexCondition_t cond;
-  ulong numChildren = (ulong)theChildren.size();
+  u_long numChildren = (u_long)theChildren.size();
   bool status;
   TypeManager* tm = theSctx->get_typemanager();
   RootTypeManager& rtm = GENV_TYPESYSTEM;
   xs_integer lSkip = xs_integer::zero();
-  ulong lAmountNonKeyParams = (theSkip ? 2 : 1);
+  u_long lAmountNonKeyParams = (theSkip ? 2 : 1);
 
   try
   {
@@ -1073,8 +1073,8 @@
         lSkip = xs_integer::zero();
     }
 
-    ulong keyNo;
-    ulong i;
+    u_long keyNo;
+    u_long i;
     for (i = lAmountNonKeyParams, keyNo = 0; i < numChildren; i += 6, ++keyNo) 
     {
       store::Item_t tempLeft;
@@ -1551,7 +1551,7 @@
   TypeManager* tm = theSctx->get_typemanager();
   RootTypeManager& rtm = GENV_TYPESYSTEM;
 
-  ulong childIdx = (haveLower ? 1 : 2);
+  u_long childIdx = (haveLower ? 1 : 2);
 
   assert(!(haveLower && haveUpper));
 

=== modified file 'src/runtime/introspection/pregenerated/sctx.h'
--- src/runtime/introspection/pregenerated/sctx.h	2012-10-08 12:09:36 +0000
+++ src/runtime/introspection/pregenerated/sctx.h	2012-12-24 23:39:23 +0000
@@ -44,7 +44,7 @@
 {
 public:
   store::NsBindings theBindings; //vector of namespace bindings
-  ulong thePosition; //current position
+  u_long thePosition; //current position
 
   StaticNamespacesIteratorState();
 
@@ -328,7 +328,7 @@
 {
 public:
   std::vector < zstring > theDocuments; //vector of document URIs
-  ulong thePosition; //current position
+  u_long thePosition; //current position
 
   StaticallyKnownDocumentsIteratorState();
 
@@ -406,7 +406,7 @@
 {
 public:
   std::vector < std::string > theCollations; //vector of collation uris
-  ulong thePosition; //current position
+  u_long thePosition; //current position
 
   StaticallyKnownCollationsIteratorState();
 
@@ -612,7 +612,7 @@
 {
 public:
   std::vector < function *> theFunctions; //vector of functions
-  ulong thePosition; //current position
+  u_long thePosition; //current position
 
   FunctionNamesIteratorState();
 
@@ -966,7 +966,7 @@
 {
 public:
   const function* theFunction; //the function
-  ulong thePosition; //current position
+  u_long thePosition; //current position
 
   FunctionAnnotationsIteratorState();
 

=== modified file 'src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp'
--- src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp	2012-10-08 12:09:36 +0000
+++ src/runtime/parsing_and_serializing/parsing_and_serializing_impl.cpp	2012-12-24 23:39:23 +0000
@@ -205,7 +205,7 @@
             throw XQUERY_EXCEPTION(
               err::XQDY0027,
               ERROR_PARAMS(lSb.str()),
-              ERROR_LOC( loc ));
+              ERROR_LOC( aLoc ));
           }
 #endif
         }
@@ -220,7 +220,7 @@
       throw XQUERY_EXCEPTION(
         err::XQDY0027,
         ERROR_PARAMS(lSb.str()),
-        ERROR_LOC( loc ));
+        ERROR_LOC( aLoc ));
     }
 #endif
   }

=== modified file 'src/runtime/sequences/SequencesImpl.cpp'
--- src/runtime/sequences/SequencesImpl.cpp	2012-09-19 21:16:15 +0000
+++ src/runtime/sequences/SequencesImpl.cpp	2012-12-24 23:39:23 +0000
@@ -286,7 +286,7 @@
   store::Item*   attr = 0;
   store::Item_t  tmp;
   bool           isMatchingId;
-  ulong i;
+  u_long i;
 
   FnIdIteratorState *state;
   DEFAULT_STACK_INIT(FnIdIteratorState, state, planState);
@@ -420,7 +420,7 @@
   store::Item*   attr = 0;
   store::Item_t  tmp;
   bool           isMatchingId;
-  ulong i;
+  u_long i;
 
   FnElementWithIdIteratorState* state;
   DEFAULT_STACK_INIT(FnElementWithIdIteratorState, state, planState);
@@ -561,7 +561,7 @@
   store::Iterator_t typedValueIte;
 
   bool           isMatchingId;
-  ulong          i;
+  u_long          i;
 
   std::vector<zstring> idrefs;
 

=== modified file 'src/runtime/sequences/sequences_impl.cpp'
--- src/runtime/sequences/sequences_impl.cpp	2012-10-16 14:30:02 +0000
+++ src/runtime/sequences/sequences_impl.cpp	2012-12-24 23:39:23 +0000
@@ -1211,7 +1211,7 @@
 bool FnCountIterator::nextImpl(store::Item_t& result, PlanState& planState) const
 {
   store::Item_t lSequenceItem;
-  ulong lCount = 0;
+  u_long lCount = 0;
 
   PlanIteratorState* state;
   DEFAULT_STACK_INIT(PlanIteratorState, state, planState);

=== modified file 'src/runtime/spec/codegen-cpp.xq'
--- src/runtime/spec/codegen-cpp.xq	2012-09-19 21:16:15 +0000
+++ src/runtime/spec/codegen-cpp.xq	2012-12-24 23:39:23 +0000
@@ -161,7 +161,7 @@
             fn:exists($function/@propagesOne))
         then
           concat (
-            'bool ', $name, '::propagatesInputToOutput ( ulong ', $param, ') const {',
+            'bool ', $name, '::propagatesInputToOutput ( u_long ', $param, ') const {',
             $gen:newline,
             $gen:indent, $body,
             $gen:newline,

=== modified file 'src/runtime/spec/introspection/sctx.xml'
--- src/runtime/spec/introspection/sctx.xml	2012-09-19 21:16:15 +0000
+++ src/runtime/spec/introspection/sctx.xml	2012-12-24 23:39:23 +0000
@@ -37,7 +37,7 @@
     <zorba:state generateReset="false" generateDestructor="false">
       <zorba:member type="store::NsBindings" name="theBindings"
                     brief="vector of namespace bindings"/>
-      <zorba:member type="ulong" name="thePosition" brief="current position"/>
+      <zorba:member type="u_long" name="thePosition" brief="current position"/>
     </zorba:state>
 
 </zorba:iterator>
@@ -193,7 +193,7 @@
   <zorba:state generateReset="false" generateDestructor="false">
     <zorba:member type="std::vector &lt; zstring &gt;" name="theDocuments"
                   brief="vector of document URIs"/>
-    <zorba:member type="ulong" name="thePosition" brief="current position"/>
+    <zorba:member type="u_long" name="thePosition" brief="current position"/>
   </zorba:state>
 
 </zorba:iterator>
@@ -238,7 +238,7 @@
   <zorba:state generateReset="false" generateDestructor="false">
     <zorba:member type="std::vector &lt; std::string &gt;" name="theCollations"
                   brief="vector of collation uris"/>
-    <zorba:member type="ulong" name="thePosition" brief="current position"/>
+    <zorba:member type="u_long" name="thePosition" brief="current position"/>
   </zorba:state>
 
 </zorba:iterator>
@@ -358,7 +358,7 @@
   <zorba:state generateReset="false" generateDestructor="false">
     <zorba:member type="std::vector &lt; function *&gt;" name="theFunctions"
                   brief="vector of functions"/>
-    <zorba:member type="ulong" name="thePosition" brief="current position"/>
+    <zorba:member type="u_long" name="thePosition" brief="current position"/>
   </zorba:state>
 
 </zorba:iterator>
@@ -552,7 +552,7 @@
     <zorba:state generateReset="false" generateDestructor="false">
       <zorba:member type="const function*" name="theFunction"
                   brief="the function"/>
-      <zorba:member type="ulong" name="thePosition" brief="current position"/>
+      <zorba:member type="u_long" name="thePosition" brief="current position"/>
     </zorba:state>
 
 </zorba:iterator>

=== modified file 'src/runtime/store/maps_impl.cpp'
--- src/runtime/store/maps_impl.cpp	2012-10-15 13:35:59 +0000
+++ src/runtime/store/maps_impl.cpp	2012-12-24 23:39:23 +0000
@@ -315,7 +315,7 @@
   store::Item_t              lQName;
   std::vector<store::Item_t> lKey;
   store::Index*              lIndex;
-  ulong i;
+  u_long i;
   store::Item_t              lKeyItem;
   store::IndexSpecification  lSpec;
 
@@ -476,7 +476,7 @@
   store::Item_t              lQName;
   std::vector<store::Item_t> lKey;
   store::Index*              lIndex;
-  ulong i;
+  u_long i;
   store::Item_t              lKeyItem;
   std::auto_ptr<store::PUL>  lPul;
   store::IndexSpecification  lSpec;

=== modified file 'src/runtime/update/update.cpp'
--- src/runtime/update/update.cpp	2012-10-08 12:09:36 +0000
+++ src/runtime/update/update.cpp	2012-12-24 23:39:23 +0000
@@ -121,8 +121,8 @@
   store::Item_t source;
   std::vector<store::Item_t> attrs(16);
   std::vector<store::Item_t> nodes(16);
-  ulong numAttrs = 0;
-  ulong numNodes = 0;
+  u_long numAttrs = 0;
+  u_long numNodes = 0;
   std::auto_ptr<store::PUL> pul;
   store::Item_t temp;
 
@@ -202,7 +202,7 @@
     {
       attrs.resize(numAttrs);
 
-      for (ulong i = 0; i < numAttrs; ++i)
+      for (u_long i = 0; i < numAttrs; ++i)
         attrs[i] = attrs[i]->copy(NULL, lCopyMode);
 
       pul->addInsertAttributes(&loc, parent, attrs);
@@ -212,7 +212,7 @@
     {
       nodes.resize(numNodes);
 
-      for (ulong i = 0; i < numNodes; ++i)
+      for (u_long i = 0; i < numNodes; ++i)
         nodes[i] = nodes[i]->copy(NULL, lCopyMode);
 
       if (theType == store::UpdateConsts::BEFORE)
@@ -277,7 +277,7 @@
     {
       attrs.resize(numAttrs);
 
-      for (ulong i = 0; i < numAttrs; ++i)
+      for (u_long i = 0; i < numAttrs; ++i)
         attrs[i] = attrs[i]->copy(NULL, lCopyMode);
 
       pul->addInsertAttributes(&loc, target, attrs);
@@ -287,7 +287,7 @@
     {
       nodes.resize(numNodes);
 
-      for (ulong i = 0; i < numNodes; ++i)
+      for (u_long i = 0; i < numNodes; ++i)
         nodes[i] = nodes[i]->copy(NULL, lCopyMode);
 
       if (theType == store::UpdateConsts::INTO)
@@ -380,7 +380,7 @@
   store::Item_t lParent;
   store::Item_t temp;
   std::vector<store::Item_t> lNodes(16);
-  ulong lNumNodes = 0;
+  u_long lNumNodes = 0;
   std::auto_ptr<store::PUL> lPul;
 
   store::CopyMode lCopyMode;

=== modified file 'src/runtime/visitors/printer_visitor_impl.cpp'
--- src/runtime/visitors/printer_visitor_impl.cpp	2012-10-08 12:09:36 +0000
+++ src/runtime/visitors/printer_visitor_impl.cpp	2012-12-24 23:39:23 +0000
@@ -775,8 +775,8 @@
   {
     std::ostringstream str;
 
-    ulong numRefs = (ulong)posRefs.size();
-    for (ulong i = 0; i < numRefs; i++)
+    u_long numRefs = (u_long)posRefs.size();
+    for (u_long i = 0; i < numRefs; i++)
     {
       str << posRefs[i].getp();
       if (i < numRefs-1)
@@ -1004,8 +1004,8 @@
 
   std::ostringstream str;
 
-  ulong numRefs = (ulong)varRefs.size();
-  for (ulong i = 0; i < numRefs; i++)
+  u_long numRefs = (u_long)varRefs.size();
+  for (u_long i = 0; i < numRefs; i++)
   {
     str << varRefs[i].getp();
     if (i < numRefs-1)

=== modified file 'src/store/api/item_factory.h'
--- src/store/api/item_factory.h	2012-09-19 21:16:15 +0000
+++ src/store/api/item_factory.h	2012-12-24 23:39:23 +0000
@@ -384,7 +384,7 @@
    * Specification: [http://www.w3.org/TR/xmlschema-2/#dateTime]
    * @param value string representation of the value
    */
-  virtual bool createDateTime(Item_t& result, const char* str, ulong strlen) = 0;
+  virtual bool createDateTime(Item_t& result, const char* str, u_long strlen) = 0;
 
   /**
    * Specification: [http://www.w3.org/TR/xpath-functions/] Section 5.2
@@ -408,7 +408,7 @@
    * Specification: [http://www.w3.org/TR/xmlschema-2/#date]
    * @param value string representation of the value
    */
-  virtual bool createDate(Item_t& result, const char* str, ulong strlen) = 0;
+  virtual bool createDate(Item_t& result, const char* str, u_long strlen) = 0;
 
   /**
    *
@@ -419,7 +419,7 @@
    * Specification: [http://www.w3.org/TR/xmlschema-2/#time]
    * @param value string representation of the value
    */
-  virtual bool createTime(Item_t& result, const char* str, ulong strlen) = 0;
+  virtual bool createTime(Item_t& result, const char* str, u_long strlen) = 0;
 
   /**
    * @param hour
@@ -447,7 +447,7 @@
    * Specification: [http://www.w3.org/TR/xmlschema-2/#gDay]
    * @param value string representation of the value
    */
-  virtual bool createGDay(Item_t& result, const char* str, ulong strlen) = 0;
+  virtual bool createGDay(Item_t& result, const char* str, u_long strlen) = 0;
 
   /**
    * @param day
@@ -460,7 +460,7 @@
    * Specification: [http://www.w3.org/TR/xmlschema-2/#gMonth]
    * @param value string representation of the value
    */
-  virtual bool createGMonth(Item_t& result, const char* str, ulong strlen) = 0;
+  virtual bool createGMonth(Item_t& result, const char* str, u_long strlen) = 0;
 
   /**
    * @param month
@@ -473,7 +473,7 @@
    * Specification: [http://www.w3.org/TR/xmlschema-2/#gMonthDay]
    * @param value string representation of the value
    */
-  virtual bool createGMonthDay(Item_t& result, const char* str, ulong strlen) = 0;
+  virtual bool createGMonthDay(Item_t& result, const char* str, u_long strlen) = 0;
 
   /**
    * @param month
@@ -487,7 +487,7 @@
    * Specification: [http://www.w3.org/TR/xmlschema-2/#gYear]
    * @param value string representation of the value
    */
-  virtual bool createGYear(Item_t& result, const char* str, ulong strlen) = 0;
+  virtual bool createGYear(Item_t& result, const char* str, u_long strlen) = 0;
 
   /**
    * @param year
@@ -500,7 +500,7 @@
    * Specification: [http://www.w3.org/TR/xmlschema-2/#gYearMonth]
    * @param value string representation of the value
    */
-  virtual bool createGYearMonth(Item_t& result, const char* str, ulong strlen) = 0;
+  virtual bool createGYearMonth(Item_t& result, const char* str, u_long strlen) = 0;
 
   /**
    * @param year
@@ -512,17 +512,17 @@
 
   virtual bool createYearMonthDuration(Item_t& result, xs_yearMonthDuration* value ) = 0;
 
-  virtual bool createYearMonthDuration(Item_t& result, const char* str, ulong strlen ) = 0;
+  virtual bool createYearMonthDuration(Item_t& result, const char* str, u_long strlen ) = 0;
 
   virtual bool createDayTimeDuration(Item_t& result, xs_dayTimeDuration* value ) = 0;
 
-  virtual bool createDayTimeDuration(Item_t& result, const char* str, ulong strlen ) = 0;
+  virtual bool createDayTimeDuration(Item_t& result, const char* str, u_long strlen ) = 0;
 
   /**
    * Specification: [http://www.w3.org/TR/xmlschema-2/#duration]
    * @param value string representation of the value
    */
-  virtual bool createDuration(Item_t& result, const char* str, ulong strlen) = 0;
+  virtual bool createDuration(Item_t& result, const char* str, u_long strlen) = 0;
 
   /**
    * @param years

=== modified file 'src/store/api/item_handle.h'
--- src/store/api/item_handle.h	2012-09-19 21:16:15 +0000
+++ src/store/api/item_handle.h	2012-12-24 23:39:23 +0000
@@ -183,14 +183,6 @@
     return tmp;
   }
 
-public:
-	std::string debug() const
-  {
-    std::ostringstream oss;
-    oss << "ItemHandle[refcount=" << p->getRefCount() << ']';
-    return oss.str();
-  }
-
 protected:
   template <class otherT> ItemHandle& assign(const ItemHandle<otherT>& rhs)
   {

=== modified file 'src/store/naive/atomic_items.cpp'
--- src/store/naive/atomic_items.cpp	2012-11-17 01:08:54 +0000
+++ src/store/naive/atomic_items.cpp	2012-12-24 23:39:23 +0000
@@ -1106,7 +1106,7 @@
 ********************************************************************************/
 
 StructuralAnyUriItem::StructuralAnyUriItem(
-    ulong collectionId,
+    u_long collectionId,
     const TreeId& treeId, 
     store::StoreConsts::NodeKind nodeKind,
     const OrdPath& ordPath)
@@ -1129,7 +1129,7 @@
   theEncodedValue.take(value);
   std::istringstream input(theEncodedValue.str());
 
-  ulong prefixlen = (ulong)strlen("zorba:");
+  u_long prefixlen = (u_long)strlen("zorba:");
 
   input.width(prefixlen);
 

=== modified file 'src/store/naive/atomic_items.h'
--- src/store/naive/atomic_items.h	2012-10-08 12:09:36 +0000
+++ src/store/naive/atomic_items.h	2012-12-24 23:39:23 +0000
@@ -704,7 +704,7 @@
 class StructuralAnyUriItem : public AtomicItem
 {
 protected:
-  ulong                        theCollectionId;
+  u_long                       theCollectionId;
   TreeId                       theTreeId;
   store::StoreConsts::NodeKind theNodeKind;
   OrdPath                      theOrdPath;
@@ -837,7 +837,7 @@
   StructuralAnyUriItem(zstring& value);
 
   StructuralAnyUriItem(
-      ulong collectionId,
+      u_long collectionId,
       const TreeId& treeId,
       store::StoreConsts::NodeKind nodeKind,
       const OrdPath& ordPath);

=== modified file 'src/store/naive/collection.cpp'
--- src/store/naive/collection.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/collection.cpp	2012-12-24 23:39:23 +0000
@@ -48,7 +48,7 @@
     const std::vector<store::Item_t>& indexSources = indexSpec.theSources;
     uint64_t numIndexSources = (uint64_t)indexSources.size();
 
-    for (ulong i = 0; i < numIndexSources; ++i)
+    for (u_long i = 0; i < numIndexSources; ++i)
     {
       if (indexSources[i]->equals(name))
       {

=== modified file 'src/store/naive/collection.h'
--- src/store/naive/collection.h	2012-12-05 14:51:50 +0000
+++ src/store/naive/collection.h	2012-12-24 23:39:23 +0000
@@ -98,7 +98,7 @@
 
   /***************************** ID Management ********************************/
 
-  virtual ulong getId() const = 0;
+  virtual u_long getId() const = 0;
 
   virtual TreeId createTreeId() = 0;
 

=== modified file 'src/store/naive/dataguide.cpp'
--- src/store/naive/dataguide.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/dataguide.cpp	2012-12-24 23:39:23 +0000
@@ -33,14 +33,14 @@
 {
   assert(theParent == NULL);
 
-  ulong numChildren = this->numChildren();
-  ulong numAttrs = this->numAttributes();
+  u_long numChildren = this->numChildren();
+  u_long numAttrs = this->numAttributes();
 
   if (numChildren > 0 || numAttrs > 0)
   {
     ElementGuideNode* node = reinterpret_cast<ElementGuideNode*>(this);
 
-    for (ulong i = 0; i < numChildren; i++)
+    for (u_long i = 0; i < numChildren; i++)
     {
       GuideNode* child = node->theChildren[i];
       assert(child->theParent == this);
@@ -48,7 +48,7 @@
       child->deleteTree();
     }
 
-    for (ulong i = 0; i < numAttrs; i++)
+    for (u_long i = 0; i < numAttrs; i++)
     {
       GuideNode* attr = node->theAttributes[i];
       assert(attr->theParent == this);
@@ -129,9 +129,9 @@
 
   unique = true;
 
-  ulong pathLen = (ulong)path.size();
+  u_long pathLen = (u_long)path.size();
 
-  for (ulong i = 0; i < pathLen; i++)
+  for (u_long i = 0; i < pathLen; i++)
   {
     if (attrPath && i == pathLen - 1)
     {
@@ -160,8 +160,8 @@
 ********************************************************************************/
 ElementGuideNode* ElementGuideNode::findChild(const store::Item* name)
 {
-  ulong numChildren = (ulong)theChildren.size();
-  for (ulong i = 0; i < numChildren; i++)
+  u_long numChildren = (u_long)theChildren.size();
+  for (u_long i = 0; i < numChildren; i++)
   {
     if (theChildren[i]->theName->equals(name))
       return theChildren[i];
@@ -176,8 +176,8 @@
 ********************************************************************************/
 AttributeGuideNode* ElementGuideNode::findAttr(const store::Item* name)
 {
-  ulong numAttrs = (ulong)theAttributes.size();
-  for (ulong i = 0; i < numAttrs; i++)
+  u_long numAttrs = (u_long)theAttributes.size();
+  for (u_long i = 0; i < numAttrs; i++)
   {
     if (theAttributes[i]->theName->equals(name))
       return theAttributes[i];
@@ -190,7 +190,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-std::string ElementGuideNode::show(ulong depth) const
+std::string ElementGuideNode::show(u_long depth) const
 {
   std::stringstream str;
 
@@ -202,7 +202,7 @@
 
   depth += 2;
 
-  ulong numChildren = (ulong)theChildren.size();
+  u_long numChildren = (u_long)theChildren.size();
 
   if (theName != NULL)
   {
@@ -218,7 +218,7 @@
     str <<  "<DOC>" << std::endl;
   }
 
-  for (ulong i = 0; i < numChildren; i++)
+  for (u_long i = 0; i < numChildren; i++)
   {
     str << theChildren[i]->show(depth);
   }

=== modified file 'src/store/naive/dataguide.h'
--- src/store/naive/dataguide.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/dataguide.h	2012-12-24 23:39:23 +0000
@@ -60,8 +60,8 @@
   bool getUnique() const       { return theIsUnique; }
   void setUnique(bool v)       { theIsUnique = v; }
 
-  virtual ulong numChildren() const { return 0; }
-  virtual ulong numAttributes() const { return 0; }
+  virtual u_long numChildren() const { return 0; }
+  virtual u_long numAttributes() const { return 0; }
 
   void deleteTree();
 
@@ -72,7 +72,7 @@
         bool&                            found,
         bool&                            unique) = 0;
 
-  virtual std::string show(ulong depth) const = 0;
+  virtual std::string show(u_long depth) const = 0;
 };
 
 
@@ -103,7 +103,7 @@
         bool&                            found,
         bool&                            unique);
 
-  std::string show(ulong depth) const { return "attr"; }
+  std::string show(u_long depth) const { return "attr"; }
 };
 
 
@@ -132,8 +132,8 @@
     return store::StoreConsts::elementNode; 
   }
 
-  ulong numChildren() const { return (ulong)theChildren.size(); }
-  ulong numAttributes() const { return (ulong)theAttributes.size(); }
+  u_long numChildren() const { return (u_long)theChildren.size(); }
+  u_long numAttributes() const { return (u_long)theAttributes.size(); }
 
   void getPathInfo(
         std::vector<const store::Item*>& ctxPath,
@@ -150,7 +150,7 @@
   ElementGuideNode* findChild(const store::Item* name);
   AttributeGuideNode* findAttr(const store::Item* name);
 
-  std::string show(ulong depth) const;
+  std::string show(u_long depth) const;
 };
 
 

=== modified file 'src/store/naive/hashmap_nodep.h'
--- src/store/naive/hashmap_nodep.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/hashmap_nodep.h	2012-12-24 23:39:23 +0000
@@ -57,7 +57,7 @@
                                           NodePointerHashMapCmp>
 {
 public:
-  NodePointerHashMap(ulong size, bool sync) 
+  NodePointerHashMap(u_long size, bool sync) 
     :
     HashMap<const XmlNode*, V, NodePointerHashMapCmp>(size, sync)
   {

=== modified file 'src/store/naive/item_vector.cpp'
--- src/store/naive/item_vector.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/item_vector.cpp	2012-12-24 23:39:23 +0000
@@ -104,7 +104,7 @@
 {
   std::ostringstream res;
   res << "ItemVector size: " << size() + " [";
-	for ( ulong i = 0; i < size(); i++)
+	for ( u_long i = 0; i < size(); i++)
 		res << getItem(i)->show() << ", ";
 	res << "]";
 

=== modified file 'src/store/naive/item_vector.h'
--- src/store/naive/item_vector.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/item_vector.h	2012-12-24 23:39:23 +0000
@@ -48,7 +48,7 @@
 
   void appendStringValue(zstring& buf) const;
 
-  ulong size() const { return (ulong)theItems.size(); }
+  u_long size() const { return (u_long)theItems.size(); }
 
   bool empty() const { return theItems.empty(); }
 
@@ -56,7 +56,7 @@
 
   std::vector<store::Item_t>& getItems() { return theItems; }
 
-  store::Item* getItem(ulong pos) const { return theItems[pos].getp(); }
+  store::Item* getItem(u_long pos) const { return theItems[pos].getp(); }
 	
   zstring show() const;
 };

=== modified file 'src/store/naive/loader.h'
--- src/store/naive/loader.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/loader.h	2012-12-24 23:39:23 +0000
@@ -72,7 +72,7 @@
 class XmlLoader
 {
 protected:
-  static const ulong INPUT_CHUNK_SIZE = 8192;
+  static const u_long INPUT_CHUNK_SIZE = 8192;
 
 protected:
   const store::LoadProperties    & theLoadProperties;

=== modified file 'src/store/naive/loader_dtd.cpp'
--- src/store/naive/loader_dtd.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/loader_dtd.cpp	2012-12-24 23:39:23 +0000
@@ -1098,11 +1098,11 @@
   ZORBA_LOADER_CHECK_ERROR(loader);
 
   zorba::Stack<XmlNode*>& nodeStack = loader.theNodeStack;
-  ulong stackSize = nodeStack.size();
-  ulong firstChildPos;
-  ulong numChildren;
-  ulong numActualChildren;
-  ulong i;
+  u_long stackSize = nodeStack.size();
+  u_long firstChildPos;
+  u_long numChildren;
+  u_long numActualChildren;
+  u_long i;
   DocumentNode* docNode;
   XmlNode* currChild;
 

=== modified file 'src/store/naive/loader_fast.cpp'
--- src/store/naive/loader_fast.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/loader_fast.cpp	2012-12-24 23:39:23 +0000
@@ -469,11 +469,11 @@
   ZORBA_LOADER_CHECK_ERROR(loader);
 
   zorba::Stack<XmlNode*>& nodeStack = loader.theNodeStack;
-  ulong stackSize = nodeStack.size();
-  ulong firstChildPos;
-  ulong numChildren;
-  ulong numActualChildren;
-  ulong i;
+  u_long stackSize = nodeStack.size();
+  u_long firstChildPos;
+  u_long numChildren;
+  u_long numActualChildren;
+  u_long i;
   DocumentNode* docNode;
   XmlNode* currChild;
   

=== modified file 'src/store/naive/node_factory.cpp'
--- src/store/naive/node_factory.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/node_factory.cpp	2012-12-24 23:39:23 +0000
@@ -66,8 +66,8 @@
 
 ElementNode* NodeFactory::createElementNode(
     store::Item_t&  nodeName,
-    ulong           numBindings,
-    ulong           numAttributes)
+    u_long           numBindings,
+    u_long           numAttributes)
 {
   return new ElementNode(nodeName, numBindings, numAttributes);
 }

=== modified file 'src/store/naive/node_factory.h'
--- src/store/naive/node_factory.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/node_factory.h	2012-12-24 23:39:23 +0000
@@ -73,8 +73,8 @@
 
   virtual ElementNode* createElementNode(
         store::Item_t&  nodeName,
-        ulong           numBindings,
-        ulong           numAttributes);
+        u_long           numBindings,
+        u_long           numAttributes);
 
   virtual ElementNode* createElementNode(
         XmlTree*                    tree,

=== modified file 'src/store/naive/node_items.cpp'
--- src/store/naive/node_items.cpp	2012-12-14 13:11:08 +0000
+++ src/store/naive/node_items.cpp	2012-12-24 23:39:23 +0000
@@ -132,7 +132,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-ulong XmlTree::getCollectionId() const
+u_long XmlTree::getCollectionId() const
 {
   if (theCollection != NULL)
     return theCollection->getId();
@@ -1397,7 +1397,7 @@
 ********************************************************************************/
 store::Item_t OrdPathNode::getLevel() const
 { 
-  ulong lNumLevels = 1;
+  u_long lNumLevels = 1;
   store::Item_t lCurrent = this->getParent();
   while (lCurrent)
   {
@@ -2175,7 +2175,7 @@
 
     if (numAttrs() != 0)
     {
-      ulong pos = 0;
+      u_long pos = 0;
       XmlNode* attr = getAttr(pos);
       removeAttr(pos);
       delete attr;
@@ -2185,7 +2185,7 @@
   }
 
   STORE_TRACE1("Constructed element node " << this << " parent = "
-              << std::hex << (parent ? (ulong)parent : 0) << " pos = " << pos
+              << std::hex << (parent ? (u_long)parent : 0) << " pos = " << pos
               << " tree = " << getTree()->getId() << ":" << getTree()
               << " ordpath = " << theOrdPath.show()
               << " name = " << theName->getStringValue()
@@ -2878,7 +2878,7 @@
   nilled = false;
 
   //const char* xsi = "http://www.w3.org/2001/XMLSchema-instance";;
-  //ulong xsilen = strlen(xsi);
+  //u_long xsilen = strlen(xsi);
 
   ite = attrsBegin();
   end = attrsEnd();
@@ -3667,7 +3667,7 @@
   }
 
   STORE_TRACE1("Constructed attribute node " << this << " parent = "
-              << std::hex << (parent ? (ulong)parent : 0) << " pos = " << pos
+              << std::hex << (parent ? (u_long)parent : 0) << " pos = " << pos
               << " tree = " << getTree()->getId() << ":" << getTree()
               << " ordpath = " << theOrdPath.show()
               << " name = " << theName->getStringValue()
@@ -3751,7 +3751,7 @@
 
   STORE_TRACE1("Copied attribute node " << this << " to node " << copyNode
               << " name = " << theName->show() << " parent = "
-              << std::hex << (parent ? (ulong)parent : 0) << " pos = " << pos
+              << std::hex << (parent ? (u_long)parent : 0) << " pos = " << pos
               << " copy mode = " << copymode.toString());
 
   return copyNode;
@@ -4108,13 +4108,13 @@
 
 #ifdef TEXT_ORDPATH
   STORE_TRACE1("Constructed text node " << this << " parent = "
-              << std::hex << (parent ? (ulong)parent : 0) << " pos = " << pos
+              << std::hex << (parent ? (u_long)parent : 0) << " pos = " << pos
               << " tree = " << getTree()->getId() << ":" << getTree()
               << " ordpath = " << theOrdPath.show()
               << " content = " << getText());
 #else
   STORE_TRACE1("Constructed text node " << this << " parent = "
-              << std::hex << (parent ? (ulong)parent : 0) << " pos = " << pos
+              << std::hex << (parent ? (u_long)parent : 0) << " pos = " << pos
               << " tree = " << getTree()->getId() << ":" << getTree()
               << " content = " << getText());
 #endif
@@ -4169,12 +4169,12 @@
 
 #ifdef TEXT_ORDPATH
   STORE_TRACE1("Constructed text node " << this << " parent = "
-              << std::hex << (parent ? (ulong)parent : 0)
+              << std::hex << (parent ? (u_long)parent : 0)
               << " ordpath = " << theOrdPath.show()
               << " content = " << getValue()->getStringValue());
 #else
   STORE_TRACE1("Constructed text node " << this << " parent = "
-              << std::hex << (parent ? (ulong)parent : 0)
+              << std::hex << (parent ? (u_long)parent : 0)
               << " content = " << getValue()->getStringValue());
 #endif
 }
@@ -4286,7 +4286,7 @@
   }
 
   STORE_TRACE1("Copied text node " << this << " to node " << copyNode
-              << " parent = " << std::hex << (parent ? (ulong)parent : 0)
+              << " parent = " << std::hex << (parent ? (u_long)parent : 0)
               << " pos = " << pos);
 
   return copyNode;
@@ -4813,7 +4813,7 @@
   }
 
   STORE_TRACE1("Constructed pi node " << this << " parent = "
-              << std::hex << (parent ? (ulong)parent : 0) << " pos = " << pos
+              << std::hex << (parent ? (u_long)parent : 0) << " pos = " << pos
               << " tree = " << getTree()->getId() << ":" << getTree()
               << " ordpath = " << theOrdPath.show() << " target = " << theTarget);
 }
@@ -4862,7 +4862,7 @@
   }
 
   STORE_TRACE1("Copied pi node " << this << " to node " << copyNode
-              << " parent = " << std::hex << (parent ? (ulong)parent : 0)
+              << " parent = " << std::hex << (parent ? (u_long)parent : 0)
               << " pos = " << pos);
 
   return copyNode;
@@ -4956,7 +4956,7 @@
   }
 
   STORE_TRACE1("Constructed comment node " << this << " parent = "
-              << std::hex << (parent ? (ulong)parent : 0) << " pos = " << pos
+              << std::hex << (parent ? (u_long)parent : 0) << " pos = " << pos
               << " tree = " << getTree()->getId() << ":" << getTree()
               << " ordpath = " << theOrdPath.show() << " content = "
               << theContent);
@@ -5003,7 +5003,7 @@
   }
 
   STORE_TRACE1("Copied coment node " << this << " to node " << copyNode
-              << " parent = " << std::hex << (parent ? (ulong)parent : 0)
+              << " parent = " << std::hex << (parent ? (u_long)parent : 0)
               << " pos = " << pos);
 
   return copyNode;

=== modified file 'src/store/naive/node_items.h'
--- src/store/naive/node_items.h	2012-12-14 13:23:51 +0000
+++ src/store/naive/node_items.h	2012-12-24 23:39:23 +0000
@@ -200,7 +200,7 @@
 
   const TreeId& getId() const { return theId; }
 
-  ulong getCollectionId() const;
+  u_long getCollectionId() const;
 
   const Collection* getCollection() const { return theCollection; }
 
@@ -508,7 +508,7 @@
     getTree()->setCollection(coll, pos);
   }
 
-  ulong getCollectionId() const 
+  u_long getCollectionId() const 
   {
     assert(!isConnectorNode());
     return getTree()->getCollectionId(); 
@@ -1571,8 +1571,8 @@
   if (this == other)
     return 0;
 
-  ulong col1 = this->getCollectionId();
-  ulong col2 = other->getCollectionId();
+  u_long col1 = this->getCollectionId();
+  u_long col2 = other->getCollectionId();
 
   if (col1 < col2)
     return -1;
@@ -1621,8 +1621,8 @@
   if (this == other)
     return 0;
 
-  ulong col1 = this->getCollectionId();
-  ulong col2 = other->getCollectionId();
+  u_long col1 = this->getCollectionId();
+  u_long col2 = other->getCollectionId();
 
   if (col1 < col2)
     return -1;

=== modified file 'src/store/naive/node_updates.cpp'
--- src/store/naive/node_updates.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/node_updates.cpp	2012-12-24 23:39:23 +0000
@@ -279,7 +279,7 @@
       ite = elem->childrenBegin();
       end = elem->childrenEnd();
 
-      for (ulong i = 0; ite != end; ++i, ++ite)
+      for (u_long i = 0; ite != end; ++i, ++ite)
       {
         XmlNode* child = (*ite);
 
@@ -310,7 +310,7 @@
   }
   }
 
-  ulong refcount = oldTree->getRefCount();
+  u_long refcount = oldTree->getRefCount();
   oldTree->getRefCount() = 0;
   oldTree->free();
 
@@ -332,7 +332,7 @@
   {
     ZORBA_ASSERT(theParent != NULL);
 
-    ulong refcount = 0;
+    u_long refcount = 0;
 
     XmlTree* oldTree = getTree();
     XmlTree* newTree = GET_STORE().getNodeFactory().createXmlTree();
@@ -690,8 +690,8 @@
   if (undoList.empty())
     return;
 
-  ulong pos = 0;
-  ulong numNodes = (ulong)undoList.size();
+  u_long pos = 0;
+  u_long numNodes = (u_long)undoList.size();
   XmlNode* currNode = this;
 
   while(currNode != NULL && pos < numNodes)
@@ -840,7 +840,7 @@
     removeType(upd);
 
   // Insert the new children without merging text nodes
-  for (ulong i = 0; i < numNewChildren; ++i)
+  for (u_long i = 0; i < numNewChildren; ++i)
   {
     XmlNode* child = BASE_NODE(upd.theNewChildren[i]);
 

=== modified file 'src/store/naive/nsbindings.cpp'
--- src/store/naive/nsbindings.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/nsbindings.cpp	2012-12-24 23:39:23 +0000
@@ -129,9 +129,9 @@
   while (currentContext != NULL)
   {
     const store::NsBindings& bindings = currentContext->theBindings;
-    ulong numBindings = (ulong)bindings.size();
+    u_long numBindings = (u_long)bindings.size();
 
-    for (ulong i = 0; i < numBindings; ++i)
+    for (u_long i = 0; i < numBindings; ++i)
     {
       if (bindings[i].first == prefix)
       {
@@ -185,9 +185,9 @@
 ********************************************************************************/
 void NsBindingsContext::updateBinding(const zstring& prefix, const zstring& ns)
 {
-  ulong numBindings = (ulong)theBindings.size();
+  u_long numBindings = (u_long)theBindings.size();
 
-  for (ulong i = 0; i < numBindings; ++i)
+  for (u_long i = 0; i < numBindings; ++i)
   {
     if (theBindings[i].first == prefix)
     {
@@ -206,9 +206,9 @@
 ********************************************************************************/
 void NsBindingsContext::removeBinding(const zstring& prefix, const zstring& ns)
 {
-  ulong numBindings = (ulong)theBindings.size();
+  u_long numBindings = (u_long)theBindings.size();
 
-  for (ulong i = 0; i < numBindings; i++)
+  for (u_long i = 0; i < numBindings; i++)
   {
     if (theBindings[i].first == prefix)
     {

=== modified file 'src/store/naive/ordpath.cpp'
--- src/store/naive/ordpath.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/ordpath.cpp	2012-12-24 23:39:23 +0000
@@ -193,7 +193,7 @@
   it is false, interprets it as a hexadecimal representation (with even length)
   of binary data.
 ********************************************************************************/
-OrdPath::OrdPath(const unsigned char* str, ulong strLen, bool isBinary)
+OrdPath::OrdPath(const unsigned char* str, u_long strLen, bool isBinary)
 {
   if (isBinary)
   {
@@ -209,7 +209,7 @@
 /*******************************************************************************
   Inits the instance with binary ORDPATH data.
 ********************************************************************************/
-void OrdPath::initFromData(const unsigned char* buf, ulong byteLen)
+void OrdPath::initFromData(const unsigned char* buf, u_long byteLen)
 {
   memset(theBuffer.local, 0, MAX_EMBEDDED_BYTE_LEN);
 
@@ -230,7 +230,7 @@
   Inits the instance with a string containing a hexadecimal representation of 
   the binary ORDPATH data.
 ********************************************************************************/
-void OrdPath::initFromString(const unsigned char* str, ulong strLen)
+void OrdPath::initFromString(const unsigned char* str, u_long strLen)
 {
   unsigned char* buf;
   bool isLocal;
@@ -238,7 +238,7 @@
   // The string length should always be even (each buffer entry is encoded in two digits)
   ZORBA_FATAL(strLen % 2 == 0, "");
 
-  ulong byteLen = strLen / 2;
+  u_long byteLen = strLen / 2;
 
   if (byteLen > MAX_BYTE_LEN)
   {
@@ -264,7 +264,7 @@
   }
 
   const unsigned char* start = str;
-  ulong i = 0;
+  u_long i = 0;
 
   try
   {
@@ -347,7 +347,7 @@
   }
   else
   {
-    ulong len = other.getRemoteByteLength();
+    u_long len = other.getRemoteByteLength();
 
     ZORBA_ASSERT(len >= MAX_EMBEDDED_BYTE_LEN);
 
@@ -366,7 +366,7 @@
 ********************************************************************************/
 OrdPath& OrdPath::operator=(const OrdPathStack& ops)
 {
-  ulong len = ops.getByteLength();
+  u_long len = ops.getByteLength();
 
   if (len > MAX_EMBEDDED_BYTE_LEN ||
       (len == MAX_EMBEDDED_BYTE_LEN && ops.theBitsAvailable == 0))
@@ -380,7 +380,7 @@
   {
     reset();
 
-    for (ulong i = 0; i < len; ++i)
+    for (u_long i = 0; i < len; ++i)
       theBuffer.local[i] = ops.theBuffer[i];
 
     markLocal();
@@ -392,7 +392,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-ulong OrdPath::getLocalBitLength(ulong& byteLen) const
+u_long OrdPath::getLocalBitLength(u_long& byteLen) const
 {
   ZORBA_ASSERT_WITH_MSG(isLocal(),
                         "OrdPath::getLocalBitLength was called even though" <<
@@ -403,7 +403,7 @@
   if (byteLen == 0)
     return 0;
 
-  ulong bitLen = byteLen * 8;
+  u_long bitLen = byteLen * 8;
 
   unsigned char lastByte = getLocalData()[byteLen - 1];
   if (byteLen == MAX_EMBEDDED_BYTE_LEN)
@@ -426,14 +426,14 @@
 /*******************************************************************************
 
 ********************************************************************************/
-ulong OrdPath::getRemoteBitLength(ulong& byteLen) const
+u_long OrdPath::getRemoteBitLength(u_long& byteLen) const
 {
   byteLen = getRemoteByteLength();
 
   if (byteLen == 0)
     return 0;
 
-  ulong bitLen = byteLen * 8;
+  u_long bitLen = byteLen * 8;
 
   unsigned char lastByte = getRemoteData()[byteLen - 1];
 
@@ -463,7 +463,7 @@
 ********************************************************************************/
 bool OrdPath::operator==(const OrdPath& other) const
 {
-  ulong len = getByteLength();
+  u_long len = getByteLength();
 
   if (len != other.getByteLength())
     return false;
@@ -477,8 +477,8 @@
 ********************************************************************************/
 int OrdPath::operator<(const OrdPath& other) const
 {
-  ulong len1;
-  ulong len2;
+  u_long len1;
+  u_long len2;
   unsigned char* p1 = getDataAndLength(len1);
   unsigned char* p2 = other.getDataAndLength(len2);
 
@@ -524,8 +524,8 @@
 ********************************************************************************/
 int OrdPath::operator>(const OrdPath& other) const
 {
-  ulong len1;
-  ulong len2;
+  u_long len1;
+  u_long len2;
   unsigned char* p1 = getDataAndLength(len1);
   unsigned char* p2 = other.getDataAndLength(len2);
 
@@ -572,8 +572,8 @@
 ********************************************************************************/
 OrdPath::RelativePosition OrdPath::getRelativePosition(const OrdPath& other) const
 {
-  ulong len1;
-  ulong len2;
+  u_long len1;
+  u_long len2;
   unsigned char* data1 = getDataAndLength(len1);
   unsigned char* data2 = other.getDataAndLength(len2);
 
@@ -673,16 +673,16 @@
 OrdPath::RelativePosition OrdPath::getRelativePosition2(const OrdPath& other) const
 {
   int32_t dewey1[MAX_NUM_COMPS], dewey2[MAX_NUM_COMPS];
-  ulong offsets1[MAX_NUM_COMPS], offsets2[MAX_NUM_COMPS];
-  ulong numComps1 = 0, numComps2 = 0;
-  ulong bitLen1 = 0, bitLen2 = 0;
+  u_long offsets1[MAX_NUM_COMPS], offsets2[MAX_NUM_COMPS];
+  u_long numComps1 = 0, numComps2 = 0;
+  u_long bitLen1 = 0, bitLen2 = 0;
   bool thisFirst;
 
   decompress(0, dewey1, offsets1, numComps1, bitLen1);
   other.decompress(0, dewey2, offsets2, numComps2, bitLen2);
 
   // curr will be the first non-shared component
-  ulong curr = 0;
+  u_long curr = 0;
 
   if (numComps1 < numComps2)
   {
@@ -703,15 +703,15 @@
   else
     thisFirst = false;
 
-  ulong extraLevels1 = 0, extraLevels2 = 0;
+  u_long extraLevels1 = 0, extraLevels2 = 0;
 
-  for (ulong i = curr; i < numComps1; ++i)
+  for (u_long i = curr; i < numComps1; ++i)
   {
     if (dewey1[i] % 2 == 1)
       ++extraLevels1;
   }
 
-  for (ulong i = curr; i < numComps2; ++i)
+  for (u_long i = curr; i < numComps2; ++i)
   {
     if (dewey2[i] % 2 == 1)
       ++extraLevels2;
@@ -755,10 +755,10 @@
 {
   reset();
 
-  ulong bitLen = 0;
+  u_long bitLen = 0;
 
-  ulong numComps = (ulong)dewey.size();
-  for (ulong i = 0; i < numComps; ++i)
+  u_long numComps = (u_long)dewey.size();
+  for (u_long i = 0; i < numComps; ++i)
   {
     if (! pushComp(getLocalData(), MAX_EMBEDDED_BIT_LEN, dewey[i], bitLen))
       return false;
@@ -777,7 +777,7 @@
 {
   reset();
 
-  ulong bitLen = 0;
+  u_long bitLen = 0;
 
   unsigned char* databuf = new unsigned char[MAX_BYTE_LEN];
 
@@ -785,14 +785,14 @@
   {
     memset(databuf, 0, MAX_BYTE_LEN);
 
-    ulong numComps = (ulong)dewey.size();
-    for (ulong i = 0; i < numComps; ++i)
+    u_long numComps = (u_long)dewey.size();
+    for (u_long i = 0; i < numComps; ++i)
     {
       bool success = pushComp(databuf, MAX_BIT_LEN, dewey[i], bitLen);
       ZORBA_ASSERT(success);
     }
 
-    ulong byteLen = (bitLen + 7) / 8;
+    u_long byteLen = (bitLen + 7) / 8;
 
     initRemote(byteLen);
     memcpy(getRemoteData(), databuf, byteLen);
@@ -854,15 +854,15 @@
     const OrdPath& sibling,
     OrdPath&       result)
 {
-  ulong numComps = 0;
+  u_long numComps = 0;
   int32_t dewey[MAX_NUM_COMPS];
-  ulong offsets[MAX_NUM_COMPS];
-  ulong bitLen;
-  ulong byteLen;
+  u_long offsets[MAX_NUM_COMPS];
+  u_long bitLen;
+  u_long byteLen;
   unsigned char* data;
 
-  ulong parentByteLen;
-  ulong parentBitLen = parent.getBitLength(parentByteLen);
+  u_long parentByteLen;
+  u_long parentBitLen = parent.getBitLength(parentByteLen);
 
   // Decompress the last level-component of sibling.
   sibling.decompress(parentBitLen, dewey, offsets, numComps, bitLen);
@@ -892,13 +892,13 @@
     newcomp += 2;
   }
 
-  ulong newBits;
+  u_long newBits;
   uint32_t dummy;
   uint64_t dummy2;
   bitsNeeded(newcomp, newBits, dummy, dummy2);
 
-  ulong commonBitLen = offsets[numComps-1];
-  ulong commonByteLen = (commonBitLen + 7) / 8;
+  u_long commonBitLen = offsets[numComps-1];
+  u_long commonByteLen = (commonBitLen + 7) / 8;
 
   bitLen = commonBitLen + newBits;
   byteLen = (bitLen + 7) / 8;
@@ -944,18 +944,18 @@
 {
   assert(sib1 < sib2);
 
-  ulong parentByteLen;
-  ulong parentBitLen = parent.getBitLength(parentByteLen);
+  u_long parentByteLen;
+  u_long parentBitLen = parent.getBitLength(parentByteLen);
 
-  ulong numComps1 = 0;
-  ulong bitLen1 = 0;
+  u_long numComps1 = 0;
+  u_long bitLen1 = 0;
   int32_t dewey1[MAX_NUM_COMPS];
-  ulong offsets1[MAX_NUM_COMPS];
+  u_long offsets1[MAX_NUM_COMPS];
 
-  ulong numComps2 = 0;
-  ulong bitLen2 = 0;
+  u_long numComps2 = 0;
+  u_long bitLen2 = 0;
   int32_t dewey2[MAX_BYTE_LEN];
-  ulong offsets2[MAX_BYTE_LEN];
+  u_long offsets2[MAX_BYTE_LEN];
 
   // decompress the last level-comp of sib1
   sib1.decompress(parentBitLen, dewey1, offsets1, numComps1, bitLen1);
@@ -964,7 +964,7 @@
   sib2.decompress(parentBitLen, dewey2, offsets2, numComps2, bitLen2);
 
   // Within the last level-component, find the 1st pair of differing comps.
-  ulong compPos = 0;
+  u_long compPos = 0;
   while (dewey1[compPos] == dewey2[compPos])
   {
     ++compPos;
@@ -992,12 +992,12 @@
                     << "comp2: " << comp2 << ", "                       \
                     << "compPos: " << compPos << ".");
 
-  ulong diff = comp2 - comp1;
+  u_long diff = comp2 - comp1;
 
   int32_t newcomp1;
   int32_t newcomp2 = 0;
-  ulong commonBitLen;
-  ulong newBits;
+  u_long commonBitLen;
+  u_long newBits;
   uint32_t dummy;
   uint64_t dummy2;
 
@@ -1097,9 +1097,9 @@
     ZORBA_ASSERT(0);
   }
 
-  ulong commonByteLen = (commonBitLen + 7) / 8;
-  ulong bitLen = commonBitLen + newBits;
-  ulong byteLen = (bitLen + 7) / 8;
+  u_long commonByteLen = (commonBitLen + 7) / 8;
+  u_long bitLen = commonBitLen + newBits;
+  u_long byteLen = (bitLen + 7) / 8;
   unsigned char* data;
 
   bool isLocal = (bitLen <= MAX_EMBEDDED_BIT_LEN);
@@ -1165,22 +1165,22 @@
 ********************************************************************************/
 bool OrdPath::pushComp(
     unsigned char* data,
-    ulong maxBitLen,
+    u_long maxBitLen,
     int32_t value,
-    ulong& bitLen)
+    u_long& bitLen)
 {
   assert(maxBitLen >= bitLen);
 
   uint32_t eval;
   uint64_t eval2;
-  ulong bitsNeeded;
+  u_long bitsNeeded;
 
   OrdPath::bitsNeeded(value, bitsNeeded, eval, eval2);
 
-  ulong byteIndex = bitLen / 8;
-  ulong bitsAvailable = 8 - bitLen % 8; // # bits available in the "current" byte.
+  u_long byteIndex = bitLen / 8;
+  u_long bitsAvailable = 8 - bitLen % 8; // # bits available in the "current" byte.
 
-  ulong bytesNeeded = byteIndex + (bitsNeeded + 15 - bitsAvailable) / 8;
+  u_long bytesNeeded = byteIndex + (bitsNeeded + 15 - bitsAvailable) / 8;
   if (bytesNeeded > MAX_BYTE_LEN)
   {
     throw ZORBA_EXCEPTION(
@@ -1245,11 +1245,11 @@
   uint32_t eval;
   uint64_t eval2;
 
-  ulong byteLen;
-  ulong bitLen;
-  ulong byteIndex;
-  ulong bitsAvailable = 0;
-  ulong bitsNeeded;
+  u_long byteLen;
+  u_long bitLen;
+  u_long byteIndex;
+  u_long bitsAvailable = 0;
+  u_long bitsNeeded;
   unsigned char* data;
 
   bool isLocal = this->isLocal();
@@ -1261,7 +1261,7 @@
 
   OrdPath::bitsNeeded(value, bitsNeeded, eval, eval2);
 
-  ulong bytesNeeded = byteIndex + (bitsNeeded + 15 - bitsAvailable) / 8;
+  u_long bytesNeeded = byteIndex + (bitsNeeded + 15 - bitsAvailable) / 8;
   if (bytesNeeded > MAX_BYTE_LEN)
   {
     throw ZORBA_EXCEPTION(
@@ -1356,15 +1356,15 @@
 ********************************************************************************/
 void OrdPath::appendEncodedComp(
     uint32_t eval,
-    ulong bitsNeeded,
-    ulong byteIndex,
-    ulong bitsAvailable,
+    u_long bitsNeeded,
+    u_long byteIndex,
+    u_long bitsAvailable,
     unsigned char* data)
 {
   do
   {
     // Number of bits to consume in the current iteration
-    ulong bitsToUse = (bitsNeeded < bitsAvailable ?
+    u_long bitsToUse = (bitsNeeded < bitsAvailable ?
                        bitsNeeded : bitsAvailable);
 
     unsigned char byte = (unsigned char)
@@ -1389,7 +1389,7 @@
 ********************************************************************************/
 void OrdPath::bitsNeeded(
     int32_t value,
-    ulong& bitsNeeded,
+    u_long& bitsNeeded,
     uint32_t& eval,
     uint64_t& eval2)
 {
@@ -1531,7 +1531,7 @@
 
   str << "";
 
-  ulong len;
+  u_long len;
   unsigned char* buf = getDataAndLength(len);
 
   if (len == 0)
@@ -1542,7 +1542,7 @@
   if (local && len == MAX_EMBEDDED_BYTE_LEN)
     buf[MAX_EMBEDDED_BYTE] &= 0xFE;
 
-  for (ulong i = 0; i < len; ++i)
+  for (u_long i = 0; i < len; ++i)
   {
     // bugfix: Add a leading 0 if one-digit
     // Each output should always be two-digit
@@ -1579,13 +1579,13 @@
 
   str << "";
 
-  ulong len;
+  u_long len;
   unsigned char* buf = getDataAndLength(len);
 
   if (len == 0)
     return str.str().c_str();
 
-  for (ulong i = 0; i < len; i++)
+  for (u_long i = 0; i < len; i++)
   {
     // bugfix Add a leading 0 if one-digit
     // Each output should always be two-digit
@@ -1596,14 +1596,14 @@
 
   str << " ";
 
-  ulong numComps = 0;
-  ulong bitSize = 0;
+  u_long numComps = 0;
+  u_long bitSize = 0;
   int32_t deweyid[MAX_NUM_COMPS];
-  ulong offsets[MAX_NUM_COMPS];
+  u_long offsets[MAX_NUM_COMPS];
 
   decompress(0, deweyid, offsets, numComps, bitSize);
 
-  for (ulong i = 0; i < numComps; ++i)
+  for (u_long i = 0; i < numComps; ++i)
   {
     str << std::dec << deweyid[i];
     if (i < numComps-1)
@@ -1617,18 +1617,18 @@
 /*******************************************************************************
 
 ********************************************************************************/
-ulong OrdPath::getLevel() const
+u_long OrdPath::getLevel() const
 {
   int32_t dewey[MAX_NUM_COMPS];
-  ulong offsets[MAX_NUM_COMPS];
-  ulong numComps = 0;
-  ulong bitLen = 0;
+  u_long offsets[MAX_NUM_COMPS];
+  u_long numComps = 0;
+  u_long bitLen = 0;
 
   decompress(0, dewey, offsets, numComps, bitLen);
 
-  ulong level = 0;
+  u_long level = 0;
 
-  for (ulong i = 0; i < numComps; ++i)
+  for (u_long i = 0; i < numComps; ++i)
   {
     if (dewey[i] % 2 == 1)
       ++level;
@@ -1644,18 +1644,18 @@
   the start of some component).
 ********************************************************************************/
 void OrdPath::decompress(
-    ulong startOffset,
+    u_long startOffset,
     int32_t* deweyid,
-    ulong* compOffsets,
-    ulong& numComps,
-    ulong& bitLen) const
+    u_long* compOffsets,
+    u_long& numComps,
+    u_long& bitLen) const
 {
   unsigned char tmpbuf[MAX_EMBEDDED_BYTE_LEN];
 
-  ulong byteIndex = startOffset / 8;
-  ulong bitIndex = startOffset % 8;
+  u_long byteIndex = startOffset / 8;
+  u_long bitIndex = startOffset % 8;
 
-  ulong byteLen;
+  u_long byteLen;
   unsigned char* data;
   bool isLocal = this->isLocal();
 
@@ -1713,13 +1713,13 @@
 ********************************************************************************/
 void OrdPath::decodeByte(
     unsigned char* data,
-    ulong&         bitLen,
-    ulong&         byteIndex,
-    ulong&         bitIndex,
+    u_long&         bitLen,
+    u_long&         byteIndex,
+    u_long&         bitIndex,
     unsigned char  byte,
     int32_t*       deweyid,
-    ulong*         compOffsets,
-    ulong&         numComps)
+    u_long*         compOffsets,
+    u_long&         numComps)
 {
   compOffsets[numComps] = bitLen;
 
@@ -4092,10 +4092,10 @@
 ********************************************************************************/
 void OrdPath::extractValue(
     unsigned char* data,
-    ulong& bitLen,
-    ulong& byteIndex,
-    ulong& bitIndex,
-    ulong numBits,
+    u_long& bitLen,
+    u_long& byteIndex,
+    u_long& bitIndex,
+    u_long numBits,
     int32_t baseValue,
     int32_t& result)
 {
@@ -4117,9 +4117,9 @@
   numBits -= (8 - bitIndex);
   byteIndex++;
 
-  ulong numBytes = numBits / 8;
+  u_long numBytes = numBits / 8;
 
-  for (ulong i = 0; i < numBytes; ++i)
+  for (u_long i = 0; i < numBytes; ++i)
   {
     result <<= 8;
     result |= data[byteIndex];
@@ -4180,7 +4180,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-ulong OrdPathStack::getByteLength() const
+u_long OrdPathStack::getByteLength() const
 {
   return theByteIndex + 1;
 }
@@ -4246,8 +4246,8 @@
   theDeweyId[theNumComps - 1] += 2;
 
   // Pop the last 2 compressed components
-  ulong numBits = theCompLens[theNumComps] + theCompLens[theNumComps-1];
-  ulong numBytes = (numBits + theBitsAvailable) / 8;
+  u_long numBits = theCompLens[theNumComps] + theCompLens[theNumComps-1];
+  u_long numBytes = (numBits + theBitsAvailable) / 8;
   theByteIndex -= numBytes;
   theBitsAvailable = (numBits + theBitsAvailable) % 8;
 
@@ -4280,8 +4280,8 @@
   theDeweyId[theNumComps - 1] += 2;
 
   // Pop the last compressed component
-  ulong numBits = theCompLens[theNumComps-1];
-  ulong numBytes = (numBits + theBitsAvailable) / 8;
+  u_long numBits = theCompLens[theNumComps-1];
+  u_long numBytes = (numBits + theBitsAvailable) / 8;
   theByteIndex -= numBytes;
   theBitsAvailable = (numBits + theBitsAvailable) % 8;
 
@@ -4298,11 +4298,11 @@
 /*******************************************************************************
 
 ********************************************************************************/
-void OrdPathStack::compressComp(ulong comp, int32_t value)
+void OrdPathStack::compressComp(u_long comp, int32_t value)
 {
   uint32_t eval;
   bool overflow = false;
-  ulong bitsNeeded;
+  u_long bitsNeeded;
 
   if (value < 0)
   {
@@ -4361,7 +4361,7 @@
     }
   }
 
-  ulong bytesNeeded = theByteIndex +
+  u_long bytesNeeded = theByteIndex +
                       (bitsNeeded + 15 - theBitsAvailable) / 8;
 
   if (bytesNeeded > OrdPath::MAX_BYTE_LEN)
@@ -4398,7 +4398,7 @@
 
   do
   {
-    ulong bitsUsed = (bitsNeeded < theBitsAvailable ?
+    u_long bitsUsed = (bitsNeeded < theBitsAvailable ?
                       bitsNeeded : theBitsAvailable);
 
     unsigned char byte = (unsigned char)
@@ -4428,7 +4428,7 @@
 {
   std::stringstream str;
 
-  for (ulong i = 0; i < theNumComps; i++)
+  for (u_long i = 0; i < theNumComps; i++)
   {
     str << theDeweyId[i];
     if (i < theNumComps-1)
@@ -4437,9 +4437,9 @@
 #if 1
   str << " ";
 
-  ulong len = getByteLength();
+  u_long len = getByteLength();
 
-  for (ulong i = 0; i < len; i++)
+  for (u_long i = 0; i < len; i++)
   {
     str << std::hex << (unsigned short)theBuffer[i] << '|';
   }

=== modified file 'src/store/naive/ordpath.h'
--- src/store/naive/ordpath.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/ordpath.h	2012-12-24 23:39:23 +0000
@@ -66,12 +66,12 @@
   };
 
 protected:
-  static const ulong MAX_EMBEDDED_BYTE_LEN = 8;
-  static const ulong MAX_EMBEDDED_BIT_LEN = MAX_EMBEDDED_BYTE_LEN * 8 - 1;
-
-  static const ulong MAX_EMBEDDED_BYTE = MAX_EMBEDDED_BYTE_LEN - 1;
-
-  static const ulong MAX_NUM_COMPS = MAX_BYTE_LEN * 4;
+  static const u_long MAX_EMBEDDED_BYTE_LEN = 8;
+  static const u_long MAX_EMBEDDED_BIT_LEN = MAX_EMBEDDED_BYTE_LEN * 8 - 1;
+
+  static const u_long MAX_EMBEDDED_BYTE = MAX_EMBEDDED_BYTE_LEN - 1;
+
+  static const u_long MAX_NUM_COMPS = MAX_BYTE_LEN * 4;
 
   // decompression
   static const unsigned char theByteMasks[8][2];
@@ -113,21 +113,21 @@
 protected:
   static bool pushComp(
         unsigned char* buf,
-        ulong          maxBitSize,
+        u_long          maxBitSize,
         int32_t        value,
-        ulong&         bitSize);
+        u_long&         bitSize);
 
   static void bitsNeeded(
         int32_t    value, 
-        ulong&     bitsNeeded,
+        u_long&     bitsNeeded,
         uint32_t&  eval,
         uint64_t&  eval2);
 
   static void appendEncodedComp(
         uint32_t       eval,
-        ulong          bitsNeeded,
-        ulong          byteIndex,
-        ulong          bitsAvailable,
+        u_long          bitsNeeded,
+        u_long          byteIndex,
+        u_long          bitsAvailable,
         unsigned char* data);
 
   static void insertBeforeOrAfter(
@@ -138,20 +138,20 @@
 
   static void decodeByte(
         unsigned char* data,
-        ulong&         bitSize,
-        ulong&         byteIndex,
-        ulong&         bitIndex,
+        u_long&         bitSize,
+        u_long&         byteIndex,
+        u_long&         bitIndex,
         unsigned char  byte,
         int32_t*       deweyid,
-        ulong*         compOffsets,
-        ulong&         numComps);
+        u_long*         compOffsets,
+        u_long&         numComps);
 
   static void extractValue(
         unsigned char* data,
-        ulong&         bitLen,
-        ulong&         byteIndex,
-        ulong&         bitIndex,
-        ulong          numBits,
+        u_long&         bitLen,
+        u_long&         byteIndex,
+        u_long&         bitIndex,
+        u_long          numBits,
         int32_t        baseValue,
         int32_t&       result);
 
@@ -165,7 +165,7 @@
 
   OrdPath(
       const unsigned char* buf,
-      ulong byteLen,
+      u_long byteLen,
       bool isBinary = false);
 
   ~OrdPath() 
@@ -174,9 +174,9 @@
       delete [] getRemoteBuffer();
   }
 
-  void initFromData(const unsigned char* buf, ulong byteLen);
+  void initFromData(const unsigned char* buf, u_long byteLen);
 
-  void initFromString(const unsigned char* buf, ulong byteLen);
+  void initFromString(const unsigned char* buf, u_long byteLen);
 
   bool isValid() const { return getByteLength() != 0; }
 
@@ -197,7 +197,7 @@
 
   RelativePosition getRelativePosition2(const OrdPath& other) const;
 
-  ulong getLevel() const;
+  u_long getLevel() const;
 
   void compress(const DeweyID& dewey);
 
@@ -239,7 +239,7 @@
   }
 
 
-  void initRemote(ulong byteLen)
+  void initRemote(u_long byteLen)
   {
     if (!isLocal())
       delete [] getRemoteBuffer();
@@ -252,7 +252,7 @@
   }
 
 
-  unsigned char* getDataAndLength(ulong& len) const
+  unsigned char* getDataAndLength(u_long& len) const
   {
     if (isLocal())
     {
@@ -286,13 +286,13 @@
   }
 
 
-  ulong getByteLength() const
+  u_long getByteLength() const
   {
     return (isLocal() ? getLocalByteLength() : getRemoteByteLength());
   }
 
 
-  ulong getLocalByteLength() const
+  u_long getLocalByteLength() const
   {
     if (theBuffer.local[MAX_EMBEDDED_BYTE] != 1)
       return MAX_EMBEDDED_BYTE_LEN;
@@ -307,31 +307,31 @@
   }
 
 
-  ulong getRemoteByteLength() const
+  u_long getRemoteByteLength() const
   {
     return getRemoteBuffer()[0];
   }
 
 
-  ulong getBitLength(ulong& byteLen) const
+  u_long getBitLength(u_long& byteLen) const
   {
     return (isLocal() ? getLocalBitLength(byteLen) : getRemoteBitLength(byteLen));
   }
 
-  ulong getLocalBitLength(ulong& byteLen) const;
+  u_long getLocalBitLength(u_long& byteLen) const;
 
-  ulong getRemoteBitLength(ulong& byteLen) const;
+  u_long getRemoteBitLength(u_long& byteLen) const;
 
   bool compressLocal(const DeweyID& dewey);
 
   void compressRemote(const DeweyID& dewey);
 
   void decompress(
-        ulong startOffset,
+        u_long startOffset,
         int32_t* deweyid,
-        ulong* compOffsets,
-        ulong& numComps,
-        ulong& bitSize) const;
+        u_long* compOffsets,
+        u_long& numComps,
+        u_long& bitSize) const;
 };
 
 
@@ -351,15 +351,15 @@
   friend class OrdPath;
 
 protected:
-  ulong         theNumComps;
+  u_long         theNumComps;
 
   int32_t       theDeweyId[OrdPath::MAX_NUM_COMPS];
 
   unsigned char theCompLens[OrdPath::MAX_NUM_COMPS];
 
   unsigned char theBuffer[OrdPath::MAX_BYTE_LEN];
-  ulong         theByteIndex;
-  ulong         theBitsAvailable;
+  u_long         theByteIndex;
+  u_long         theBitsAvailable;
 
 public:
   OrdPathStack();
@@ -368,9 +368,9 @@
 
   void init();
 
-  ulong getNumComps() const { return theNumComps; }
+  u_long getNumComps() const { return theNumComps; }
   
-  ulong getByteLength() const;
+  u_long getByteLength() const;
 
   void pushChild();
   void popChild();
@@ -382,7 +382,7 @@
   OrdPathStack(const OrdPathStack& other);
   OrdPathStack& operator=(const OrdPathStack& other);
 
-  void compressComp(ulong comp, int32_t value);
+  void compressComp(u_long comp, int32_t value);
 };
 
 

=== modified file 'src/store/naive/pul_primitives.h'
--- src/store/naive/pul_primitives.h	2012-12-10 16:02:05 +0000
+++ src/store/naive/pul_primitives.h	2012-12-24 23:39:23 +0000
@@ -262,7 +262,7 @@
 protected:
   std::vector<store::Item_t>  theNewAttrs;
 
-  ulong                       theNumApplied;
+  u_long                      theNumApplied;
   std::vector<store::Item*>   theNewBindings;
 
   UpdInsertAttributes(
@@ -297,9 +297,9 @@
   store::Item_t               theAttr;
   std::vector<store::Item_t>  theNewAttrs;
 
-  ulong                       theNumApplied;
+  u_long                       theNumApplied;
   std::vector<store::Item*>   theNewBindings;
-  ulong                       thePos;
+  u_long                       thePos;
 
   UpdReplaceAttribute(
         CollectionPul* pul,
@@ -335,7 +335,7 @@
   store::Item_t               theChild;
   std::vector<store::Item_t>  theNewChildren;
 
-  ulong                       theNumApplied;
+  u_long                       theNumApplied;
 
   csize                       thePos;
 
@@ -535,7 +535,7 @@
   zstring            theNewContent;
 
   store::Item_t      theOldNode;
-  ulong              theOldPos;
+  u_long              theOldPos;
   TextNodeContent    theOldContent;
   bool               theIsTyped;
 
@@ -930,7 +930,7 @@
 
   csize numNodes() const { return theNodes.size(); }
 
-  store::Item* getNode(ulong i) const { return theNodes[i].getp(); }
+  store::Item* getNode(u_long i) const { return theNodes[i].getp(); }
 
   bool dynamicCollection() const { return theIsDynamic; }
 };
@@ -1012,7 +1012,7 @@
   friend class PULPrimitiveFactory;
 
 protected:
-  ulong theNumApplied;
+  u_long theNumApplied;
 
   UpdInsertIntoCollection(
         CollectionPul* pul,
@@ -1045,7 +1045,7 @@
   friend class PULPrimitiveFactory;
 
 protected:
-  ulong theNumApplied;
+  u_long theNumApplied;
 
   UpdInsertFirstIntoCollection(
       CollectionPul* pul,
@@ -1078,7 +1078,7 @@
   friend class PULPrimitiveFactory;
 
 protected:
-  ulong theNumApplied;
+  u_long theNumApplied;
 
   UpdInsertLastIntoCollection(
         CollectionPul* pul,
@@ -1181,7 +1181,7 @@
 protected:
   bool                    theIsLast;
 
-  ulong                   theNumApplied;
+  u_long                  theNumApplied;
   std::vector<bool>       theFound;
   std::vector<xs_integer> thePositions;
 

=== modified file 'src/store/naive/qname_pool.cpp'
--- src/store/naive/qname_pool.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/qname_pool.cpp	2012-12-24 23:39:23 +0000
@@ -35,7 +35,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-QNamePool::QNamePool(ulong size, StringPool* nspool) 
+QNamePool::QNamePool(u_long size, StringPool* nspool) 
   :
   theCache(new QNameItem[size]),
   theCacheSize(size),
@@ -260,7 +260,7 @@
   zstring pooledNs;
   theNamespacePool->insertc(ns, pooledNs);
 
-  ulong hval = hashfun::h32(pre, hashfun::h32(ln, hashfun::h32(ns)));
+  u_long hval = hashfun::h32(pre, hashfun::h32(ln, hashfun::h32(ns)));
 
   try
   {
@@ -347,7 +347,7 @@
   zstring pooledNs;
   theNamespacePool->insert(ns, pooledNs);
 
-  ulong hval = hashfun::h32(pre.c_str(),
+  u_long hval = hashfun::h32(pre.c_str(),
                             hashfun::h32(ln.c_str(),
                                          hashfun::h32(ns.c_str())));
   try
@@ -437,7 +437,7 @@
 
   if (qn->isValid())
   {
-    ulong hval = CompareFunction::hash(qn);
+    u_long hval = CompareFunction::hash(qn);
     theHashSet.eraseNoSync(qn, hval);
     qn->invalidate(true, &normVictim);
   }

=== modified file 'src/store/naive/qname_pool.h'
--- src/store/naive/qname_pool.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/qname_pool.h	2012-12-24 23:39:23 +0000
@@ -87,7 +87,7 @@
     friend class QNamePool;
 
   public:
-    QNamePoolHashSet(ulong size) 
+    QNamePoolHashSet(u_long size) 
       :
       HashSet<QNameItem*, CompareFunction>(size, true)
     {
@@ -98,20 +98,20 @@
  typedef HashEntry<QNameItem*, DummyHashValue> QNHashEntry;
 
 public:
-  static const ulong MAX_CACHE_SIZE = 32768;
+  static const u_long MAX_CACHE_SIZE = 32768;
 
 protected:
   QNameItem         * theCache;
-  ulong               theCacheSize;
-	ulong               theFirstFree;
-  ulong               theNumFree;
+  u_long               theCacheSize;
+  u_long               theFirstFree;
+  u_long               theNumFree;
 
   QNamePoolHashSet    theHashSet;
 
   StringPool        * theNamespacePool;
 
 public:
-  QNamePool(ulong size, StringPool* nspool);
+  QNamePool(u_long size, StringPool* nspool);
 
   ~QNamePool();
 

=== modified file 'src/store/naive/query_context.h'
--- src/store/naive/query_context.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/query_context.h	2012-12-24 23:39:23 +0000
@@ -76,13 +76,13 @@
 class QueryContextContainer
 {
 protected:
-  std::map<ulong, QueryContext> theContainer;
+  std::map<u_long, QueryContext> theContainer;
   SYNC_CODE(Mutex               theMutex;)
 
 public:
-  QueryContext& getContext(ulong queryId);
+  QueryContext& getContext(u_long queryId);
 
-  void removeContext(ulong queryId);
+  void removeContext(u_long queryId);
 };
 
 

=== modified file 'src/store/naive/simple_collection.h'
--- src/store/naive/simple_collection.h	2012-12-05 14:51:50 +0000
+++ src/store/naive/simple_collection.h	2012-12-24 23:39:23 +0000
@@ -72,7 +72,7 @@
 
 
 protected:
-  ulong                                  theId;
+  u_long                                  theId;
   store::Item_t                          theName;
   checked_vector<store::Item_t>          theXmlTrees;
   bool                                   theIsDynamic;
@@ -101,7 +101,7 @@
   /********************** All these methods implement the **********************
   ***************** zorba::simplestore::Collection interface ******************/
 
-  ulong getId() const { return theId; }
+  u_long getId() const { return theId; }
 
   const store::Item* getName() const { return theName.getp(); }
 

=== modified file 'src/store/naive/simple_collection_set.cpp'
--- src/store/naive/simple_collection_set.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/simple_collection_set.cpp	2012-12-24 23:39:23 +0000
@@ -93,7 +93,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-const ulong SimpleCollectionSet::DEFAULT_COLLECTION_MAP_SIZE = 32;
+const u_long SimpleCollectionSet::DEFAULT_COLLECTION_MAP_SIZE = 32;
 
 
 SimpleCollectionSet::SimpleCollectionSet()

=== modified file 'src/store/naive/simple_collection_set.h'
--- src/store/naive/simple_collection_set.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/simple_collection_set.h	2012-12-24 23:39:23 +0000
@@ -36,7 +36,7 @@
 public:
   ITEM_PTR_HASH_MAP(zorba::store::Collection_t, Set);
   
-  static const ulong DEFAULT_COLLECTION_MAP_SIZE;
+  static const u_long DEFAULT_COLLECTION_MAP_SIZE;
     
 protected:
   Set  theCollections;

=== modified file 'src/store/naive/simple_index.cpp'
--- src/store/naive/simple_index.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/simple_index.cpp	2012-12-24 23:39:23 +0000
@@ -422,11 +422,11 @@
 ********************************************************************************/
 bool IndexPointCondition::test(const store::IndexKey& key) const
 {
-  ulong numCols = theKey.size();
+  u_long numCols = theKey.size();
 
   ZORBA_ASSERT(numCols == theIndex->getNumColumns());
 
-  for (ulong i = 0; i < numCols; i++)
+  for (u_long i = 0; i < numCols; i++)
   {
     if (! theKey[i]->equals(key[i],
                             theIndex->getSpecification().theTimezone,
@@ -488,7 +488,7 @@
     bool lowerIncl,
     bool upperIncl)
 {
-  ulong size = theLowerBounds.size();
+  u_long size = theLowerBounds.size();
   theLowerBounds.resize(size + 1);
   theUpperBounds.resize(size + 1);
   theRangeFlags.resize(size + 1);
@@ -507,13 +507,13 @@
 ********************************************************************************/
 bool IndexBoxValueCondition::test(const store::IndexKey& key) const
 {
-  ulong numCols = theLowerBounds.size();
+  u_long numCols = theLowerBounds.size();
 
   ZORBA_ASSERT(numCols <= theIndex->getNumColumns());
 
   long timezone = theIndex->getSpecification().theTimezone;
 
-  for (ulong i = 0; i < numCols; i++)
+  for (u_long i = 0; i < numCols; i++)
   {
     const XQPCollator* collator = theIndex->getCollator(i);
 
@@ -543,11 +543,11 @@
 ********************************************************************************/
 std::ostream& operator<<(std::ostream& os, const IndexBoxValueCondition& cond)
 {
-  ulong numCols = cond.theLowerBounds.size();
+  u_long numCols = cond.theLowerBounds.size();
 
   os << "{ ";
 
-  for (ulong i = 0; i < numCols; i++)
+  for (u_long i = 0; i < numCols; i++)
   {
     if (!cond.theRangeFlags[i].theHaveLowerBound)
     {

=== modified file 'src/store/naive/simple_index_general.h'
--- src/store/naive/simple_index_general.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/simple_index_general.h	2012-12-24 23:39:23 +0000
@@ -228,7 +228,7 @@
   protected:
     IndexMap::iterator     theIterator;
     IndexMap* const*       theMaps;
-    ulong                  theCurType;
+    u_long                 theCurType;
   public:
     KeyIterator(IndexMap* const* aMaps);
     ~KeyIterator();

=== modified file 'src/store/naive/simple_item_factory.cpp'
--- src/store/naive/simple_item_factory.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/simple_item_factory.cpp	2012-12-24 23:39:23 +0000
@@ -130,7 +130,7 @@
 
 bool BasicItemFactory::createStructuralAnyURI(
     store::Item_t& result,
-    ulong collectionId,
+    u_long collectionId,
     const TreeId& treeId,
     store::StoreConsts::NodeKind nodeKind,
     const OrdPath& ordPath)
@@ -515,7 +515,7 @@
 bool BasicItemFactory::createDateTime(
     store::Item_t& result,
     const char* str,
-    ulong strlen)
+    u_long strlen)
 {
   DateTime dt;
 
@@ -586,7 +586,7 @@
 bool BasicItemFactory::createDate(
     store::Item_t& result,
     const char* str,
-    ulong strlen)
+    u_long strlen)
 {
   DateTime dt;
 
@@ -613,7 +613,7 @@
 bool BasicItemFactory::createTime(
     store::Item_t& result,
     const char* str,
-    ulong strlen)
+    u_long strlen)
 {
   DateTime dt;
 
@@ -685,7 +685,7 @@
 bool BasicItemFactory::createGDay(
     store::Item_t& result,
     const char* str,
-    ulong strlen)
+    u_long strlen)
 {
   DateTime dt;
 
@@ -729,7 +729,7 @@
 bool BasicItemFactory::createGMonth(
     store::Item_t& result,
     const char* str,
-    ulong strlen)
+    u_long strlen)
 {
   DateTime dt;
 
@@ -775,7 +775,7 @@
 bool BasicItemFactory::createGMonthDay(
     store::Item_t& result,
     const char* str,
-    ulong strlen)
+    u_long strlen)
 {
   DateTime dt;
 
@@ -817,7 +817,7 @@
 bool BasicItemFactory::createGYear(
     store::Item_t& result,
     const char* str,
-    ulong strlen)
+    u_long strlen)
 {
   DateTime dt;
 
@@ -863,7 +863,7 @@
 bool BasicItemFactory::createGYearMonth(
     store::Item_t& result,
     const char* str,
-    ulong strlen)
+    u_long strlen)
 {
   DateTime dt;
 
@@ -912,7 +912,7 @@
 bool BasicItemFactory::createDuration(
     store::Item_t& result,
     const char* str,
-    ulong strlen)
+    u_long strlen)
 {
   Duration d;
   if (Duration::parseDuration(str, strlen, d) == 0)
@@ -952,7 +952,7 @@
 bool BasicItemFactory::createYearMonthDuration(
     store::Item_t& result,
     const char* str,
-    ulong strlen)
+    u_long strlen)
 {
   Duration d;
   if (Duration::parseYearMonthDuration(str, strlen, d) == 0)
@@ -978,7 +978,7 @@
 bool BasicItemFactory::createDayTimeDuration(
     store::Item_t& result,
     const char* str,
-    ulong strlen)
+    u_long strlen)
 {
   Duration d;
   if (Duration::parseDayTimeDuration(str, strlen, d) == 0)
@@ -1145,7 +1145,7 @@
 bool BasicItemFactory::createElementNode(
     store::Item_t&              result,
     store::Item*                parent,
-    ulong                       pos,
+    u_long                      pos,
     store::Item_t&              nodeName,
     store::Item_t&              typeName,
     bool                        haveTypedValue,
@@ -1307,7 +1307,7 @@
 bool BasicItemFactory::createAttributeNode(
     store::Item_t&  result,
     store::Item*    parent,
-    ulong           pos,
+    u_long          pos,
     store::Item_t&  nodeName,
     store::Item_t&  typeName,
     store::Item_t&  typedValue)
@@ -1434,7 +1434,7 @@
 bool BasicItemFactory::createAttributeNode(
     store::Item_t&              result,
     store::Item*                parent,
-    ulong                       pos,
+    u_long                      pos,
     store::Item_t&              nodeName,
     store::Item_t&              typeName,
     std::vector<store::Item_t>& typedValueV)
@@ -1561,7 +1561,7 @@
 bool BasicItemFactory::createTextNode(
     store::Item_t&  result,
     store::Item*    parent,
-    ulong           pos,
+    u_long          pos,
     zstring&        content)
 {
   NodeFactory& factory = GET_NODE_FACTORY();
@@ -1771,7 +1771,7 @@
 bool BasicItemFactory::createPiNode(
     store::Item_t& result,
     store::Item*   parent,
-    ulong          pos,
+    u_long          pos,
     zstring&       target,
     zstring&       content,
     zstring&       baseUri)
@@ -1869,7 +1869,7 @@
 bool BasicItemFactory::createCommentNode(
     store::Item_t& result,
     store::Item*   parent,
-    ulong          pos,
+    u_long         pos,
     zstring&       content)
 {
   XmlTree* xmlTree = NULL;

=== modified file 'src/store/naive/simple_item_factory.h'
--- src/store/naive/simple_item_factory.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/simple_item_factory.h	2012-12-24 23:39:23 +0000
@@ -94,7 +94,7 @@
 
   bool createStructuralAnyURI(
       store::Item_t& result,
-      ulong collectionId,
+      u_long collectionId,
       const TreeId& treeId,
       store::StoreConsts::NodeKind nodeKind,
       const OrdPath& ordPath);
@@ -171,7 +171,7 @@
 
   bool createDateTime(store::Item_t& result, short year , short month, short day, short hour, short minute, double second, short timeZone_hours);
 
-  bool createDateTime(store::Item_t& result, const char* str, ulong strlen);
+  bool createDateTime(store::Item_t& result, const char* str, u_long strlen);
 
   bool createDateTime(store::Item_t& result, const store::Item_t&, const store::Item_t&);
 
@@ -179,11 +179,11 @@
 
   bool createDate(store::Item_t& result, short year, short month, short day);
 
-  bool createDate(store::Item_t& result, const char* str, ulong strlen);
+  bool createDate(store::Item_t& result, const char* str, u_long strlen);
 
   bool createTime(store::Item_t& result, const xs_time* value);
 
-  bool createTime(store::Item_t& result, const char* str, ulong strlen);
+  bool createTime(store::Item_t& result, const char* str, u_long strlen);
 
   bool createTime(store::Item_t& result, short hour, short minute, double second );
 
@@ -191,47 +191,47 @@
 
   bool createGDay(store::Item_t& result, const xs_gDay* value);
 
-  bool createGDay(store::Item_t& result, const char* str, ulong strlen);
+  bool createGDay(store::Item_t& result, const char* str, u_long strlen);
 
   bool createGDay(store::Item_t& result, short day);
 
   bool createGMonth(store::Item_t& result, const xs_gMonth* value);
 
-  bool createGMonth(store::Item_t& result, const char* str, ulong strlen);
+  bool createGMonth(store::Item_t& result, const char* str, u_long strlen);
 
   bool createGMonth(store::Item_t& result, short month);
 
   bool createGMonthDay (store::Item_t& result, const xs_gMonthDay* value);
 
-  bool createGMonthDay (store::Item_t& result,  const char* str, ulong strlen);
+  bool createGMonthDay (store::Item_t& result,  const char* str, u_long strlen);
 
   bool createGMonthDay (store::Item_t& result,  short month, short day);
 
   bool createGYear (store::Item_t& result, const xs_gYear* value);
 
-  bool createGYear (store::Item_t& result,  const char* str, ulong strlen);
+  bool createGYear (store::Item_t& result,  const char* str, u_long strlen);
 
   bool createGYear (store::Item_t& result,  short year);
 
   bool createGYearMonth (store::Item_t& result, const xs_gYearMonth* value);
 
-  bool createGYearMonth (store::Item_t& result,  const char* str, ulong strlen);
+  bool createGYearMonth (store::Item_t& result,  const char* str, u_long strlen);
 
   bool createGYearMonth (store::Item_t& result,  short year, short month);
 
   bool createDuration(store::Item_t& result, xs_duration* value);
 
-  bool createDuration(store::Item_t& result, const char* str, ulong strlen);
+  bool createDuration(store::Item_t& result, const char* str, u_long strlen);
 
   bool createDuration(store::Item_t& result, short years, short months, short days, short hours, short minutes, double seconds);
 
-  bool createYearMonthDuration(store::Item_t& result, const char* str, ulong strlen );
+  bool createYearMonthDuration(store::Item_t& result, const char* str, u_long strlen );
 
   bool createYearMonthDuration(store::Item_t& result, xs_yearMonthDuration* value );
 
   bool createDayTimeDuration(store::Item_t& result, xs_dayTimeDuration* value );
 
-  bool createDayTimeDuration(store::Item_t& result, const char* str, ulong strlen );
+  bool createDayTimeDuration(store::Item_t& result, const char* str, u_long strlen );
 
   bool createENTITIES(store::Item_t& result, zstring& value);
 
@@ -289,7 +289,7 @@
   bool createElementNode(
         store::Item_t&              result,
         store::Item*                parent,
-        ulong                       pos,
+        u_long                      pos,
         store::Item_t&              nodeName,
         store::Item_t&              typeName,
         bool                        haveTypedValue,
@@ -316,7 +316,7 @@
   bool createAttributeNode(
         store::Item_t&              result,
         store::Item*                parent,
-        ulong                       pos,
+        u_long                       pos,
         store::Item_t&              nodeName,
         store::Item_t&              typeName,
         store::Item_t&              typedValue);
@@ -324,7 +324,7 @@
   bool createAttributeNode(
         store::Item_t&              result,
         store::Item*                parent,
-        ulong                       pos,
+        u_long                       pos,
         store::Item_t&              nodeName,
         store::Item_t&              typeName,
         std::vector<store::Item_t>& typedValueV);
@@ -337,7 +337,7 @@
   bool createTextNode(
         store::Item_t&    result,
         store::Item*      parent,
-        ulong             pos,
+        u_long            pos,
         zstring&          content);
 
   bool createTextNode(
@@ -360,7 +360,7 @@
   bool createPiNode (
         store::Item_t& result,
         store::Item*   parent,
-        ulong          pos,
+        u_long         pos,
         zstring&       target,
         zstring&       content,
         zstring&       baseUri);
@@ -373,7 +373,7 @@
   bool createCommentNode (
         store::Item_t& result,
         store::Item*   parent,
-        ulong          pos,
+        u_long         pos,
         zstring&       content);
 
 

=== modified file 'src/store/naive/simple_pul.h'
--- src/store/naive/simple_pul.h	2012-12-10 16:02:05 +0000
+++ src/store/naive/simple_pul.h	2012-12-24 23:39:23 +0000
@@ -143,10 +143,10 @@
   struct TextNodeMerge
   {
     InternalNode         * theParent;
-    ulong                  thePos;
+    u_long                 thePos;
     std::vector<XmlNode_t> theMergedNodes;
 
-    TextNodeMerge(InternalNode* aParent, ulong aPos)
+    TextNodeMerge(InternalNode* aParent, u_long aPos)
       :
       theParent(aParent),
       thePos(aPos)

=== modified file 'src/store/naive/simple_store.cpp'
--- src/store/naive/simple_store.cpp	2012-11-29 00:47:32 +0000
+++ src/store/naive/simple_store.cpp	2012-12-24 23:39:23 +0000
@@ -226,7 +226,7 @@
 /*******************************************************************************
   Create an id for a new collection
 ********************************************************************************/
-ulong SimpleStore::createCollectionId()
+u_long SimpleStore::createCollectionId()
 {
   SYNC_CODE(AutoMutex lock(&theCollectionCounterMutex);)
   return theCollectionCounter++;

=== modified file 'src/store/naive/simple_store.h'
--- src/store/naive/simple_store.h	2012-11-29 00:47:32 +0000
+++ src/store/naive/simple_store.h	2012-12-24 23:39:23 +0000
@@ -50,14 +50,14 @@
   typedef NodePointerHashMap<zstring> NodeRefMap;
 
 private:
-  ulong                         theCollectionCounter;
+  u_long                         theCollectionCounter;
   SYNC_CODE(Mutex               theCollectionCounterMutex;)
 
   RefNodeMap                    theReferencesToNodeMap;
   NodeRefMap                    theNodeToReferencesMap;
 
 public:
-  ulong createCollectionId();
+  u_long createCollectionId();
 
   store::Collection_t createCollection(
       const store::Item_t& aName,

=== modified file 'src/store/naive/store.cpp'
--- src/store/naive/store.cpp	2012-11-21 03:17:34 +0000
+++ src/store/naive/store.cpp	2012-12-24 23:39:23 +0000
@@ -77,18 +77,18 @@
 /*******************************************************************************
   Store static data
 ********************************************************************************/
-const ulong Store::NAMESPACE_POOL_SIZE = 128;
-const ulong Store::DEFAULT_DOCUMENT_SET_SIZE = 32;
-const ulong Store::DEFAULT_URI_COLLECTION_SET_SIZE = 32;
-const ulong Store::DEFAULT_INDICES_SET_SIZE = 32;
-const ulong Store::DEFAULT_INTEGRITY_CONSTRAINT_SET_SIZE = 32;
+const u_long Store::NAMESPACE_POOL_SIZE = 128;
+const u_long Store::DEFAULT_DOCUMENT_SET_SIZE = 32;
+const u_long Store::DEFAULT_URI_COLLECTION_SET_SIZE = 32;
+const u_long Store::DEFAULT_INDICES_SET_SIZE = 32;
+const u_long Store::DEFAULT_INTEGRITY_CONSTRAINT_SET_SIZE = 32;
 
 const char* Store::XS_URI = "http://www.w3.org/2001/XMLSchema";;
 const char* Store::XML_URI = "http://www.w3.org/2001/XML/1998/namespace";;
 const char* Store::ZXSE_URI = "http://www.zorba-xquery.com/zorba/schema-extensions";;
 const char* Store::JS_URI = "http://jsoniq.org/types";;
 
-const ulong Store::XML_URI_LEN = sizeof(Store::XML_URI);
+const u_long Store::XML_URI_LEN = sizeof(Store::XML_URI);
 
 
 /*******************************************************************************
@@ -249,7 +249,7 @@
   theSchemaTypeNames[store::XS_HEXBINARY] = theQNamePool->insert(ns, "xs", "hexBinary");
   theSchemaTypeNames[store::XS_BOOLEAN] = theQNamePool->insert(ns, "xs", "boolean");
 
-  for (ulong i = 0; i < store::XS_LAST; ++i)
+  for (u_long i = 0; i < store::XS_LAST; ++i)
   {
     theSchemaTypeCodes[theSchemaTypeNames[i].getp()] = 
     static_cast<store::SchemaTypeCode>(i);
@@ -524,7 +524,7 @@
 void Store::populateValueIndex(
     const store::Index_t& idx,
     store::Iterator* sourceIter,
-    ulong numColumns)
+    u_long numColumns)
 {
   if (!sourceIter)
     return;
@@ -553,7 +553,7 @@
       if (key2 == key)
         key = new store::IndexKey(numColumns);
 
-      for (ulong i = 0; i < numColumns; ++i)
+      for (u_long i = 0; i < numColumns; ++i)
       {
         if (!sourceIter->next((*key)[i]))
         {
@@ -591,7 +591,7 @@
 void Store::populateGeneralIndex(
     const store::Index_t& idx,
     store::Iterator* sourceIter,
-    ulong numColumns)
+    u_long numColumns)
 {
   store::Item_t domainNode;
   store::Item_t firstKeyItem;

=== modified file 'src/store/naive/store.h'
--- src/store/naive/store.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/store.h	2012-12-24 23:39:23 +0000
@@ -138,14 +138,14 @@
   static const char* ZXSE_URI;
   static const char* JS_URI;
 
-  static const ulong XML_URI_LEN;
+  static const u_long XML_URI_LEN;
 
 protected:
-  static const ulong NAMESPACE_POOL_SIZE;
-  static const ulong DEFAULT_DOCUMENT_SET_SIZE;
-  static const ulong DEFAULT_URI_COLLECTION_SET_SIZE;
-  static const ulong DEFAULT_INDICES_SET_SIZE;
-  static const ulong DEFAULT_INTEGRITY_CONSTRAINT_SET_SIZE;
+  static const u_long NAMESPACE_POOL_SIZE;
+  static const u_long DEFAULT_DOCUMENT_SET_SIZE;
+  static const u_long DEFAULT_URI_COLLECTION_SET_SIZE;
+  static const u_long DEFAULT_INDICES_SET_SIZE;
+  static const u_long DEFAULT_INTEGRITY_CONSTRAINT_SET_SIZE;
 
 public:
   zstring                       theEmptyNs;
@@ -165,7 +165,7 @@
 #endif
 
 protected:
-  ulong                         theNumUsers;
+  u_long                         theNumUsers;
 
   StringPool                  * theNamespacePool;
   QNamePool                   * theQNamePool;
@@ -268,7 +268,7 @@
 
 /*---------------------------- Collections -----------------------------------*/
 public:
-  virtual ulong createCollectionId() = 0;
+  virtual u_long createCollectionId() = 0;
 
   virtual TreeId createTreeId();
 
@@ -312,12 +312,12 @@
   virtual void populateValueIndex(
       const store::Index_t& index,
       store::Iterator* sourceIter,
-      ulong numColumns);
+      u_long numColumns);
 
   virtual void populateGeneralIndex(
       const store::Index_t& index,
       store::Iterator* sourceIter,
-      ulong numColumns);
+      u_long numColumns);
 
 /*------------------------- Integrity constraints ----------------------------*/
 public:

=== modified file 'src/store/naive/string_pool.cpp'
--- src/store/naive/string_pool.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/string_pool.cpp	2012-12-24 23:39:23 +0000
@@ -59,7 +59,7 @@
 
   zstring::size_type len = strlen(str);
 
-  ulong hval = hashfun::h32(str, len, FNV_32_INIT) % bucket_count();
+  u_long hval = hashfun::h32(str, len, FNV_32_INIT) % bucket_count();
 
   {
     SYNC_CODE(AutoMutex lock(&theMutex);)

=== modified file 'src/store/naive/string_pool.h'
--- src/store/naive/string_pool.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/string_pool.h	2012-12-24 23:39:23 +0000
@@ -49,7 +49,7 @@
 class StringPool : public HashSet<zstring, StringPoolCompareFunction>
 {
 public:
- StringPool(ulong size) 
+ StringPool(u_long size) 
     :
     HashSet<zstring, StringPoolCompareFunction>(size, true) {}
 

=== modified file 'src/store/naive/tree_id.h'
--- src/store/naive/tree_id.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/tree_id.h	2012-12-24 23:39:23 +0000
@@ -33,7 +33,7 @@
 
 */
 
-typedef ulong TreeId;
+typedef u_long TreeId;
 
 } // simplestore
 } // zorba

=== modified file 'src/store/naive/tree_id_generator.cpp'
--- src/store/naive/tree_id_generator.cpp	2012-09-19 21:16:15 +0000
+++ src/store/naive/tree_id_generator.cpp	2012-12-24 23:39:23 +0000
@@ -40,7 +40,7 @@
 
 *******************************************************************************/
 TreeIdGenerator* SimpleTreeIdGeneratorFactory::createTreeGenerator(
-    ulong aCollectionId)
+    u_long aCollectionId)
 {
   return new SimpleTreeIdGenerator();
 }

=== modified file 'src/store/naive/tree_id_generator.h'
--- src/store/naive/tree_id_generator.h	2012-09-19 21:16:15 +0000
+++ src/store/naive/tree_id_generator.h	2012-12-24 23:39:23 +0000
@@ -45,7 +45,7 @@
 class SimpleTreeIdGenerator : public TreeIdGenerator 
 {
 private:
-  ulong theNextId;
+  u_long theNextId;
   SYNC_CODE(Mutex theCounterMutex;)
 
 public:
@@ -64,7 +64,7 @@
 public:
   virtual ~TreeIdGeneratorFactory() {}
   
-  virtual TreeIdGenerator* createTreeGenerator(ulong aCollectionId) = 0;
+  virtual TreeIdGenerator* createTreeGenerator(u_long aCollectionId) = 0;
 
   virtual TreeIdGenerator& getDefaultTreeIdGenerator() = 0;
 };
@@ -79,7 +79,7 @@
   SimpleTreeIdGenerator theDefaultGenerator;
 
 public:
-  virtual TreeIdGenerator* createTreeGenerator(ulong aCollectionId);
+  virtual TreeIdGenerator* createTreeGenerator(u_long aCollectionId);
 
   virtual TreeIdGenerator& getDefaultTreeIdGenerator();
 };

=== modified file 'src/store/util/hashmap_stringbuf.h'
--- src/store/util/hashmap_stringbuf.h	2012-09-19 21:16:15 +0000
+++ src/store/util/hashmap_stringbuf.h	2012-12-24 23:39:23 +0000
@@ -61,7 +61,7 @@
   HashMap<zstring_b, V, CompareFunction> theMap;
 
 public:
-  StringBufHashMap(ulong size, bool sync) : theMap(size, sync) {};
+  StringBufHashMap(u_long size, bool sync) : theMap(size, sync) {};
 
   ~StringBufHashMap() { };
 

=== modified file 'src/store/util/item_vector.cpp'
--- src/store/util/item_vector.cpp	2012-09-19 21:16:15 +0000
+++ src/store/util/item_vector.cpp	2012-12-24 23:39:23 +0000
@@ -40,11 +40,11 @@
 ********************************************************************************/
 std::ostream& operator<<(std::ostream& os, const ItemVector& key)
 {
-  ulong size = (ulong)key.theItems.size();
+  u_long size = (u_long)key.theItems.size();
 
   os << "[";
 
-  for (ulong i = 0; i < size; i++)
+  for (u_long i = 0; i < size; i++)
   {
     if (key.theItems[i] == NULL)
       os << "NULL";

=== modified file 'src/types/typemanagerimpl.cpp'
--- src/types/typemanagerimpl.cpp	2012-10-08 12:09:36 +0000
+++ src/types/typemanagerimpl.cpp	2012-12-24 23:39:23 +0000
@@ -1093,7 +1093,7 @@
 
   case IdentTypes::EMPTY_TYPE:
     return create_empty_type();
-
+#ifndef ZORBA_NO_XMLSCHEMA
   case IdentTypes::SCHEMA_ELEMENT_TYPE:
   {
     store::Item_t ename;
@@ -1119,7 +1119,7 @@
                                         q,
                                         QueryLoc::null);
   }
-
+#endif
   default:
     break;
   }

=== modified file 'src/unit_tests/CMakeLists.txt'
--- src/unit_tests/CMakeLists.txt	2012-11-12 21:17:32 +0000
+++ src/unit_tests/CMakeLists.txt	2012-12-24 23:39:23 +0000
@@ -18,16 +18,24 @@
   test_base64_streambuf.cpp
   test_fs_iterator.cpp
   test_json_parser.cpp
-  test_string.cpp
   test_uri.cpp
   test_uuid.cpp
   unit_tests.cpp
   test_uri.cpp
   test_json_parser.cpp
   test_fs_iterator.cpp
-  test_hashmaps.cpp
 )
 
+IF (NOT EMSCRIPTEN)
+  LIST (APPEND UNIT_TEST_SRCS
+    test_hashmaps.cpp)
+ENDIF (NOT EMSCRIPTEN)
+
+IF (NOT ZORBA_NO_ICU)
+  LIST (APPEND UNIT_TEST_SRCS
+    test_string.cpp)
+ENDIF (NOT ZORBA_NO_ICU)
+
 IF (NOT ZORBA_NO_FULL_TEXT)
   LIST (APPEND UNIT_TEST_SRCS
     test_stemmer.cpp

=== modified file 'src/unit_tests/test_fs_iterator.cpp'
--- src/unit_tests/test_fs_iterator.cpp	2012-04-22 15:49:55 +0000
+++ src/unit_tests/test_fs_iterator.cpp	2012-12-24 23:39:23 +0000
@@ -31,6 +31,7 @@
 
 int test_fs_iterator( int argc, char *argv[] ) {
   int result = 0;
+#ifdef ZORBA_WITH_FILE_ACCESS
   try {
 #ifndef WIN32
     fs::iterator dir_iter( "/" );
@@ -44,7 +45,7 @@
     cerr << e << endl;
     result = 2;
   }
-
+#endif
   return result;
 }
 

=== modified file 'src/util/cxx_util.h'
--- src/util/cxx_util.h	2012-09-19 21:16:15 +0000
+++ src/util/cxx_util.h	2012-12-24 23:39:23 +0000
@@ -55,12 +55,13 @@
 template<>     struct zorba_static_assert<true> { };
 template<int>  struct zorba_static_assert_type { };
 
+#ifndef EMSCRIPTEN
 #define static_assert(expr,msg)                   \
   typedef ::zorba_static_assert_type<             \
     sizeof( ::zorba_static_assert<(expr) != 0> )  \
   > zorba_static_assert_type_##__LINE__
-
 #endif /* ZORBA_CXX_STATIC_ASSERT */
+#endif /* EMSCRIPTEN */
 
 ///////////////////////////////////////////////////////////////////////////////
 

=== modified file 'src/util/dynamic_bitset.cpp'
--- src/util/dynamic_bitset.cpp	2012-09-19 21:16:15 +0000
+++ src/util/dynamic_bitset.cpp	2012-12-24 23:39:23 +0000
@@ -25,7 +25,7 @@
 std::ostream& operator <<(std::ostream& s, const DynamicBitset& set)
 {
   s << "BitSet[" << set.size() << "] = {";
-  for(ulong i = 0; i < set.size(); ++i) 
+  for(u_long i = 0; i < set.size(); ++i) 
   {
     if (set.get(i)) {
       s << i << ", ";

=== modified file 'src/util/dynamic_bitset.h'
--- src/util/dynamic_bitset.h	2012-09-19 21:16:15 +0000
+++ src/util/dynamic_bitset.h	2012-12-24 23:39:23 +0000
@@ -30,13 +30,13 @@
   typedef std::vector<uint8_t> bits_t;
 
 private:
-  ulong    m_num_bits;
+  u_long    m_num_bits;
   bits_t m_bits;
 
 public:
   DynamicBitset() { }
 
-  DynamicBitset(ulong size)
+  DynamicBitset(u_long size)
     :
     m_num_bits(size),
     m_bits((size >> 3) + ((size & 7) ? 1 : 0)) 
@@ -45,20 +45,20 @@
 
   ~DynamicBitset() { }
 
-  ulong size() const
+  u_long size() const
   {
     return m_num_bits;
   }
 
-  void getSet(std::vector<ulong>& set) const
+  void getSet(std::vector<u_long>& set) const
   {
-    ulong numBytes = (ulong)m_bits.size();
-    for (ulong i = 0; i < numBytes; ++i)
+    u_long numBytes = (u_long)m_bits.size();
+    for (u_long i = 0; i < numBytes; ++i)
     {
       if (m_bits[i] == 0)
         continue;
 
-      for (ulong j = 0; j < 8; ++j) 
+      for (u_long j = 0; j < 8; ++j) 
       {
         if ((m_bits[i] & (128 >> j)) != 0) // 128 = 1000 0000
           set.push_back(i * 8 + j);
@@ -77,16 +77,16 @@
     return (byte & (128 >> getBitWithinByte(bit))) != 0;
   }
 
-  void set(ulong bit, bool value)
+  void set(u_long bit, bool value)
   {
-    ulong off = getByteIndex(bit);
+    u_long off = getByteIndex(bit);
     if (!value && m_bits.size() <= (unsigned)off)
       return;
 
     if (m_bits.size() <= (unsigned)off)
       m_bits.resize(off + 1);
  
-    ulong bitnum = getBitWithinByte(bit);
+    u_long bitnum = getBitWithinByte(bit);
     if (value) 
     {
       m_bits[off] |= (128 >> bitnum);
@@ -108,7 +108,7 @@
   
   DynamicBitset& set_union(const DynamicBitset& rhs)
   {
-    ulong idx = 0;
+    u_long idx = 0;
     while(idx < m_bits.size() && idx < rhs.m_bits.size()) 
     {
       m_bits[idx] |= rhs.m_bits[idx];
@@ -128,7 +128,7 @@
   
   DynamicBitset& set_intersect(const DynamicBitset& rhs)
   {
-    ulong idx = 0;
+    u_long idx = 0;
     while(idx < m_bits.size() && idx < rhs.m_bits.size()) 
     {
       m_bits[idx] &= rhs.m_bits[idx];
@@ -143,12 +143,12 @@
 
 
 private:
-  static ulong getByteIndex(ulong bit)
+  static u_long getByteIndex(u_long bit)
   {
     return bit >> 3;
   }
   
-  static ulong getBitWithinByte(ulong bit)
+  static u_long getBitWithinByte(u_long bit)
   {
     // bit = 8 ==> bit & 7 = 0,
     // bit = 9 ==> bit & 7 = 1, etc

=== modified file 'src/util/file.cpp'
--- src/util/file.cpp	2012-09-19 21:16:15 +0000
+++ src/util/file.cpp	2012-12-24 23:39:23 +0000
@@ -319,6 +319,7 @@
 
 #ifndef _WIN32_WCE
 void file::chdir() {
+#ifdef ZORBA_WITH_FILE_ACCESS
   if ( is_directory() ) {
     try {
       fs::chdir( c_str() );
@@ -327,6 +328,7 @@
       throw ZORBA_IO_EXCEPTION( e.function(), e.path() );
     }
   }
+#endif
 }
 #endif
 

=== modified file 'src/util/regex_xquery.cpp'
--- src/util/regex_xquery.cpp	2012-09-19 21:16:15 +0000
+++ src/util/regex_xquery.cpp	2012-12-24 23:39:23 +0000
@@ -21,9 +21,11 @@
 #include "regex_xquery.h"
 #include <string.h>
 #include "zorbatypes/chartype.h"
+#include "util/utf8_util_base.h"
 #include "util/unicode_categories.h"
 #include "util/ascii_util.h"
 #include "util/utf8_string.h"
+#include "util/utf8_util.h"
 
 namespace zorba {
   namespace regex_xquery{

=== modified file 'src/util/unicode_util.cpp'
--- src/util/unicode_util.cpp	2012-09-19 21:16:15 +0000
+++ src/util/unicode_util.cpp	2012-12-24 23:39:23 +0000
@@ -18,11 +18,13 @@
 #include <algorithm>
 #include <cassert>
 #include <cstdlib>
-#include <cwchar>
 #include <functional>                   /* for binary_function */
 #include <utility>                      /* for pair */
 
+#include <zorba/config.h>
+
 #ifndef ZORBA_NO_ICU
+# include <cwchar>
 # include <unicode/normlzr.h>
 # include <unicode/uchar.h>
 # include <unicode/ustring.h>

=== modified file 'src/util/unicode_util.h'
--- src/util/unicode_util.h	2012-09-19 21:16:15 +0000
+++ src/util/unicode_util.h	2012-12-24 23:39:23 +0000
@@ -21,7 +21,6 @@
 
 #include <cctype>
 #include <cstring>
-#include <cwchar>
 
 #include <zorba/internal/ztd.h>
 

=== modified file 'src/util/utf8_util.cpp'
--- src/util/utf8_util.cpp	2012-09-19 21:16:15 +0000
+++ src/util/utf8_util.cpp	2012-12-24 23:39:23 +0000
@@ -15,6 +15,8 @@
  */
 #include "stdafx.h"
 
+#include <zorba/config.h>
+
 #ifndef ZORBA_NO_ICU
 #include <unicode/ustring.h>
 #endif /* ZORBA_NO_ICU */

=== modified file 'src/util/utf8_util.h'
--- src/util/utf8_util.h	2012-09-19 21:16:15 +0000
+++ src/util/utf8_util.h	2012-12-24 23:39:23 +0000
@@ -18,7 +18,6 @@
 #define ZORBA_UTF8_UTIL_H
 
 #include <algorithm>
-#include <cwchar>
 #include <string>
 
 #include "ascii_util.h"
@@ -799,9 +798,9 @@
 #endif
   {
     const char* str = s.data();
-    ulong len = (ulong)s.size();
+    u_long len = (u_long)s.size();
     uint32_t hash = 5381;
-    ulong i = 0;
+    u_long i = 0;
     int c;
     while (i < len && (c = *str++))
     {

=== modified file 'src/zorbaserialization/serialize_basic_types.cpp'
--- src/zorbaserialization/serialize_basic_types.cpp	2012-10-10 21:15:05 +0000
+++ src/zorbaserialization/serialize_basic_types.cpp	2012-12-24 23:39:23 +0000
@@ -238,7 +238,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-void operator&(Archiver& ar, ulong& obj)
+void operator&(Archiver& ar, u_long& obj)
 {
   if (ar.is_serializing_out())
   {
@@ -250,7 +250,7 @@
     uint64_t uint64v;
     ar.read_next_simple_temp_field(TYPE_UINT64, &uint64v);
 
-    obj = static_cast<ulong>(uint64v);
+    obj = static_cast<u_long>(uint64v);
   }
 }
 

=== modified file 'src/zorbaserialization/serialize_basic_types.h'
--- src/zorbaserialization/serialize_basic_types.h	2012-09-19 21:16:15 +0000
+++ src/zorbaserialization/serialize_basic_types.h	2012-12-24 23:39:23 +0000
@@ -49,7 +49,7 @@
 
 void operator&(Archiver& ar, long& obj);
 
-void operator&(Archiver& ar, ulong& obj);
+void operator&(Archiver& ar, u_long& obj);
 
 void operator&(Archiver& ar, long long& obj);
 

=== modified file 'src/zorbaserialization/serialize_template_types.h'
--- src/zorbaserialization/serialize_template_types.h	2012-09-19 21:16:15 +0000
+++ src/zorbaserialization/serialize_template_types.h	2012-12-24 23:39:23 +0000
@@ -180,7 +180,7 @@
       if (cls_factory == NULL)
       {
         throw ZORBA_EXCEPTION(zerr::ZCSE0003_UNRECOGNIZED_CLASS_FIELD, 
-        ERROR_PARAMS(BUILD_STRING((ulong)type)));
+        ERROR_PARAMS(BUILD_STRING((u_long)type)));
       }
 
       new_obj = cls_factory->create_new(ar);
@@ -193,7 +193,7 @@
         obj = NULL;
 
         throw ZORBA_EXCEPTION(zerr::ZCSE0002_INCOMPATIBLE_INPUT_FIELD,
-        ERROR_PARAMS(id, BUILD_STRING((ulong)type), typeid(T).name()));
+        ERROR_PARAMS(id, BUILD_STRING((u_long)type), typeid(T).name()));
       }
 
       ar.register_reference(id, field_kind, new_obj);

=== modified file 'src/zorbatypes/URI.cpp'
--- src/zorbatypes/URI.cpp	2012-09-19 21:16:15 +0000
+++ src/zorbatypes/URI.cpp	2012-12-24 23:39:23 +0000
@@ -191,7 +191,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-bool URI::is_well_formed_address(const char* addr, ulong addrLen)
+bool URI::is_well_formed_address(const char* addr, u_long addrLen)
 {
   if (addrLen == 0) 
   {
@@ -238,9 +238,9 @@
       return false;
     }
 
-    ulong lLabelCharCount = 0;
+    u_long lLabelCharCount = 0;
 
-    for (ulong i = 0; i < addrLen; ++i) 
+    for (u_long i = 0; i < addrLen; ++i) 
     {
       char c1 = addr[i];
 
@@ -273,12 +273,12 @@
 /*******************************************************************************
 
 ********************************************************************************/
-bool URI::is_well_formed_ipv4_address(const char* addr, ulong length)
+bool URI::is_well_formed_ipv4_address(const char* addr, u_long length)
 {
-  ulong numDots = 0;
-  ulong numDigits = 0;
+  u_long numDots = 0;
+  u_long numDigits = 0;
 
-  for (ulong i = 0; i < length; ++i)
+  for (u_long i = 0; i < length; ++i)
   {
     char c = addr[i];
 
@@ -314,7 +314,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-bool URI::is_well_formed_ipv6_reference(const char* addr, ulong length)
+bool URI::is_well_formed_ipv6_reference(const char* addr, u_long length)
 {
   long lIndex = 1;
   long lEnd = length-1;
@@ -582,7 +582,7 @@
   zstring::size_type lTrimmedURILength = lTrimmedURI.size();
 
   // index of the current processing state used in this function
-  ulong lIndex = 0;
+  u_long lIndex = 0;
 
   zstring::size_type lColonIdx    = lTrimmedURI.find(":");
   zstring::size_type lSlashIdx    = lTrimmedURI.find("/");
@@ -628,7 +628,7 @@
   {
     initializeScheme(lTrimmedURI);
 
-    lIndex = (ulong)theScheme.size() + 1;
+    lIndex = (u_long)theScheme.size() + 1;
   }
 
   /**
@@ -650,7 +650,7 @@
     }
     else
     {
-      ulong lStartPos = lIndex;
+      u_long lStartPos = lIndex;
 
       // get authority
       // (everything up to path, query, fragment or the end of the URI)
@@ -871,7 +871,7 @@
     const zstring& user_info,
     bool user_info_found)
 {
-  if ( !is_well_formed_address(host.c_str(), (ulong)host.size()) )  
+  if ( !is_well_formed_address(host.c_str(), (u_long)host.size()) )  
   {
     return false;
   }
@@ -914,9 +914,9 @@
   checked_vector<uint32_t> lCodepoints;
   utf8::to_codepoints(uri, &lCodepoints);
 
-  ulong lIndex = 0;
-  ulong lStart = 0;
-  ulong lEnd = (ulong)lCodepoints.size();
+  u_long lIndex = 0;
+  u_long lStart = 0;
+  u_long lEnd = (u_long)lCodepoints.size();
   uint32_t lCp = 0;
 
   if (uri.empty())
@@ -1520,7 +1520,7 @@
     return false;
 #endif
 
-  for (ulong i = 0; i < scheme.size(); ++i) 
+  for (u_long i = 0; i < scheme.size(); ++i) 
   {
     char c = scheme[i];
 

=== modified file 'src/zorbatypes/URI.h'
--- src/zorbatypes/URI.h	2012-09-19 21:16:15 +0000
+++ src/zorbatypes/URI.h	2012-12-24 23:39:23 +0000
@@ -41,11 +41,11 @@
 
   static std::string encode_file_URI(const std::string& filepath);
 
-  static bool is_well_formed_address(const char* addr, ulong length);
-
-  static bool is_well_formed_ipv6_reference(const char* addr, ulong length);
-
-  static bool is_well_formed_ipv4_address(const char* addr, ulong length);
+  static bool is_well_formed_address(const char* addr, u_long length);
+
+  static bool is_well_formed_ipv6_reference(const char* addr, u_long length);
+
+  static bool is_well_formed_ipv4_address(const char* addr, u_long length);
 
   static long scanHexSequence(const char* addr, long idx, long end, long& counter);
 

=== modified file 'src/zorbatypes/datetime/datetimetype.cpp'
--- src/zorbatypes/datetime/datetimetype.cpp	2012-11-17 01:08:54 +0000
+++ src/zorbatypes/datetime/datetimetype.cpp	2012-12-24 23:39:23 +0000
@@ -492,7 +492,7 @@
   temp += "-01";
 
   if (parse_date(temp.c_str(),
-                 (ulong)temp.size(),
+                 (u_long)temp.size(),
                  temp_pos,
                  dt.data[YEAR_DATA],
                  dt.data[MONTH_DATA],
@@ -545,7 +545,7 @@
   temp += "-01-01";
 
   if (parse_date(temp.c_str(),
-                 (ulong)temp.size(),
+                 (u_long)temp.size(),
                  temp_pos,
                  dt.data[YEAR_DATA],
                  dt.data[MONTH_DATA],
@@ -593,7 +593,7 @@
   temp += "-01";
 
   if (parse_date(temp.c_str(),
-                 (ulong)temp.size(),
+                 (u_long)temp.size(),
                  temp_pos,
                  dt.data[YEAR_DATA],
                  dt.data[MONTH_DATA],
@@ -640,7 +640,7 @@
   temp.append(str + pos, 6); // Year 4 to make it a leap year, to allow the MonthDay of 29 February
 
   if (parse_date(temp.c_str(),
-                 (ulong)temp.size(),
+                 (u_long)temp.size(),
                  temp_pos,
                  dt.data[YEAR_DATA],
                  dt.data[MONTH_DATA],
@@ -691,7 +691,7 @@
   temp.append(str + pos, 3);
 
   if (parse_date(temp.c_str(),
-                 (ulong)temp.size(),
+                 (u_long)temp.size(),
                  temp_pos,
                  dt.data[YEAR_DATA],
                  dt.data[MONTH_DATA],

=== modified file 'src/zorbatypes/datetime/duration.cpp'
--- src/zorbatypes/datetime/duration.cpp	2012-09-19 21:16:15 +0000
+++ src/zorbatypes/datetime/duration.cpp	2012-12-24 23:39:23 +0000
@@ -237,7 +237,7 @@
   // Check month or year
   if (ym_pos != zstring::npos)
   {
-    if ((err = parseYearMonthDuration(str, (ulong)ym_pos+1, d)) != 0)
+    if ((err = parseYearMonthDuration(str, (u_long)ym_pos+1, d)) != 0)
       return err;
 
     ascii::size_type pos = ym_pos+1;

=== modified file 'src/zorbautils/hashmap.h'
--- src/zorbautils/hashmap.h	2012-12-20 22:22:31 +0000
+++ src/zorbautils/hashmap.h	2012-12-24 23:39:23 +0000
@@ -547,7 +547,7 @@
 ********************************************************************************/
 bool exists(const T& item) const
 {
-  ulong hval = hash(item);
+  u_long hval = hash(item);
 
   SYNC_CODE(AutoMutex lock(theMutexp);)
 
@@ -578,7 +578,7 @@
 ********************************************************************************/
 iterator find(const T& item)
 {
-  ulong hval = hash(item);
+  u_long hval = hash(item);
 
   SYNC_CODE(AutoMutex lock(theMutexp);)
 
@@ -608,7 +608,7 @@
 ********************************************************************************/
 bool get(const T& item, V& value) const
 {
-  ulong hval = hash(item);
+  u_long hval = hash(item);
 
   SYNC_CODE(AutoMutex lock(theMutexp);)
 
@@ -643,7 +643,7 @@
 bool insert(const std::pair<const T, V>& pair)
 {
   bool found;
-  ulong hval = hash(pair.first);
+  u_long hval = hash(pair.first);
 
   SYNC_CODE(AutoMutex lock(theMutexp);)
 
@@ -668,7 +668,7 @@
 bool insert(const T& item, V& value)
 {
   bool found;
-  ulong hval = hash(item);
+  u_long hval = hash(item);
 
   SYNC_CODE(AutoMutex lock(theMutexp);)
 
@@ -696,7 +696,7 @@
 bool update(const T& item, const V& value)
 {
   bool found = false;
-  ulong hval = hash(item);
+  u_long hval = hash(item);
 
   SYNC_CODE(AutoMutex lock(theMutexp);)
 
@@ -748,7 +748,7 @@
   {
     const T& item = theHashTab[ite.thePos].key();
 
-    ulong hval = hash(item);
+    u_long hval = hash(item);
 
     eraseNoSync(item, hval);
   }
@@ -763,7 +763,7 @@
 ********************************************************************************/
 bool erase(const T& item)
 {
-  ulong hval = hash(item);
+  u_long hval = hash(item);
 
   SYNC_CODE(AutoMutex lock(theMutexp);)
 
@@ -773,13 +773,13 @@
 
 bool eraseNoSync(const T& item)
 {
-  ulong hval = hash(item);
+  u_long hval = hash(item);
 
   return eraseNoSync(item, hval);
 }
 
 
-bool eraseNoSync(const T& item, ulong hval)
+bool eraseNoSync(const T& item, u_long hval)
 {
   HashEntry<T, V>* entry = bucket(hval);
 
@@ -831,7 +831,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-ulong hash(const T& item) const
+u_long hash(const T& item) const
 {
   return theCompareFunction.hash(item);
 }
@@ -846,7 +846,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-HashEntry<T, V>* bucket(ulong hvalue)
+HashEntry<T, V>* bucket(u_long hvalue)
 {
   return &theHashTab[hvalue % theNumBuckets];
 }
@@ -855,7 +855,7 @@
 /*******************************************************************************
 
 ********************************************************************************/
-const HashEntry<T, V>* bucket(ulong hvalue) const
+const HashEntry<T, V>* bucket(u_long hvalue) const
 {
   return &theHashTab[hvalue % theNumBuckets];
 }
@@ -921,7 +921,7 @@
 ********************************************************************************/
 HashEntry<T, V>* hashInsert(
     const T&   item,
-    ulong      hvalue,
+    u_long      hvalue,
     bool&      found)
 {
 retry:

=== modified file 'src/zorbautils/hashmap_itemh.h'
--- src/zorbautils/hashmap_itemh.h	2012-09-19 21:16:15 +0000
+++ src/zorbautils/hashmap_itemh.h	2012-12-24 23:39:23 +0000
@@ -84,7 +84,7 @@
   ItemHandleHashMap(
         long timezone,
         XQPCollator* collation,
-        ulong size,
+        u_long size,
         bool sync) 
     :
     theMap(ItemHandleHashMapCmp(timezone, collation), size, sync)

=== modified file 'src/zorbautils/hashset.h'
--- src/zorbautils/hashset.h	2012-09-19 21:16:15 +0000
+++ src/zorbautils/hashset.h	2012-12-24 23:39:23 +0000
@@ -45,14 +45,14 @@
 typedef typename HashMap<T, DummyHashValue, C>::iterator iterator;
 
 
-HashSet(const C& compFunction, ulong size, bool sync)
+HashSet(const C& compFunction, u_long size, bool sync)
   :
   HashMap<T, DummyHashValue, C>(compFunction, size, sync) 
 {
 }
 
 
-HashSet(ulong size, bool sync)
+HashSet(u_long size, bool sync)
   :
   HashMap<T, DummyHashValue, C>(size, sync) 
 {

=== modified file 'src/zorbautils/lock.h'
--- src/zorbautils/lock.h	2012-09-19 21:16:15 +0000
+++ src/zorbautils/lock.h	2012-12-24 23:39:23 +0000
@@ -44,7 +44,7 @@
     friend class Lock;
 
     Lock::Mode    theMode;
-    ulong         theCount;
+    u_long         theCount;
     bool          theUpgrade;
     ThreadId      theThread;
 
@@ -64,7 +64,7 @@
 
   Mode                      theMode;
   bool                      theHaveUpgradeReq;
-  ulong                     theNumWaiters;
+  u_long                     theNumWaiters;
   std::vector<LockRequest>  theHolders;
 
 public:

=== modified file 'src/zorbautils/stack.h'
--- src/zorbautils/stack.h	2012-09-19 21:16:15 +0000
+++ src/zorbautils/stack.h	2012-12-24 23:39:23 +0000
@@ -29,11 +29,11 @@
 class  ZORBA_DLL_PUBLIC Stack
 {
 protected:
-  ulong          theTop;
+  u_long          theTop;
   std::vector<T> theStack;
 
 public:
-  Stack(ulong initSize = 0) : theTop(0)
+  Stack(u_long initSize = 0) : theTop(0)
   {
     if (initSize > 0)
       theStack.reserve(initSize);
@@ -46,7 +46,7 @@
     return theTop == 0;
   }
 
-  ulong size() const
+  u_long size() const
   {
     return theTop;
   }
@@ -69,7 +69,7 @@
     return theStack[theTop-1];
   }
 
-  void pop(ulong num = 1)
+  void pop(u_long num = 1)
   {
     assert(theTop >= num);
     theTop -= num;
@@ -86,7 +86,7 @@
     theTop++;
   }
 
-  const T& operator[](ulong i) const
+  const T& operator[](u_long i) const
   {
     assert(i < theTop);
     return theStack[i];

=== modified file 'src/zorbautils/string_util.cpp'
--- src/zorbautils/string_util.cpp	2012-09-19 21:16:15 +0000
+++ src/zorbautils/string_util.cpp	2012-12-24 23:39:23 +0000
@@ -16,7 +16,12 @@
 #include "stdafx.h"
 
 #include <cstring>
+
+#include <zorba/config.h>
+
+#ifndef ZORBA_NO_ICU
 #include <unicode/stsearch.h>
+#endif
 
 #include "util/unicode_util.h"
 #include "zorbautils/string_util.h"

=== modified file 'test/update/specification.h'
--- test/update/specification.h	2012-09-19 21:16:15 +0000
+++ test/update/specification.h	2012-12-24 23:39:23 +0000
@@ -400,8 +400,8 @@
       std::cout << "  HasCompare: " << (*lIter)->hasCompare << std::endl; 
       if ((*lIter)->hasCompare) 
       {
-        ulong numCompares = (ulong)(*lIter)->theCompares.size();
-        for (ulong i = 0; i < numCompares; i++)
+        u_long numCompares = (u_long)(*lIter)->theCompares.size();
+        for (u_long i = 0; i < numCompares; i++)
         {
           std::cout << "  Compare: " << (*lIter)->theCompares[i] << std::endl; 
           std::cout << "  CompareType: " << State::compareTypeStr((*lIter)->theCompareTypes[i]) << std::endl; 

=== modified file 'test/update/updtestdriver.cpp'
--- test/update/updtestdriver.cpp	2012-09-19 21:16:15 +0000
+++ test/update/updtestdriver.cpp	2012-12-24 23:39:23 +0000
@@ -269,12 +269,12 @@
 
   std::vector<zorba::XQuery_t> lQueries;
 
-  ulong numQueries = (ulong)lSpec.theStates.size();
+  u_long numQueries = (u_long)lSpec.theStates.size();
 
   //
   // For each query in the spec file
   //
-  for(ulong curQuery = 0; curQuery < numQueries; ++curQuery)
+  for(u_long curQuery = 0; curQuery < numQueries; ++curQuery)
   {
     State* lState = lSpec.theStates[curQuery];
 
@@ -423,9 +423,9 @@
       {
         bool lRes = false;
         bool anyMatch = false;
-        ulong numRefs = (ulong)lState->theCompares.size();
+        u_long numRefs = (u_long)lState->theCompares.size();
         
-        for (ulong i = 0; i < numRefs && !lRes; i++) 
+        for (u_long i = 0; i < numRefs && !lRes; i++) 
         {
           std::string lRefFileTmpString = lRefPath;
           


Follow ups