You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by rl...@apache.org on 2020/08/20 18:42:15 UTC

[xalan-c] branch master updated: XALANC-812: Replace use of !NDEBUG with XALAN_DEBUG

This is an automated email from the ASF dual-hosted git repository.

rleigh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/xalan-c.git


The following commit(s) were added to refs/heads/master by this push:
     new 23d5d9e  XALANC-812: Replace use of !NDEBUG with XALAN_DEBUG
     new 5f5c6d2  Merge pull request #34 from rleigh-codelibre/XALANC-812_remove_NDEBUG_usage
23d5d9e is described below

commit 23d5d9ed7e9f3dfbe29a41c2c228ed0308476d2b
Author: Roger Leigh <rl...@codelibre.net>
AuthorDate: Thu Aug 20 00:15:48 2020 +0100

    XALANC-812: Replace use of !NDEBUG with XALAN_DEBUG
---
 CMakeLists.txt                                     |  1 +
 Tests/C-API/c-api.c                                |  9 +-----
 Tests/Compare/compare.cpp                          |  9 +-----
 Tests/Conf/conf.cpp                                |  8 +----
 Tests/Dom2Dom/dom2dom.cpp                          |  7 +----
 Tests/Errortests/Errortests.cpp                    |  8 +----
 Tests/Extensions/extensions.cpp                    |  9 +-----
 Tests/InputSource/inputsource.cpp                  |  8 +----
 Tests/Memory/Stressmem.cpp                         |  9 +-----
 Tests/Memory/TestBlock.cpp                         | 22 +++++--------
 Tests/Params/Params.cpp                            |  7 +----
 Tests/PerfT/perft.cpp                              |  7 +----
 Tests/Threads/ThreadTest.cpp                       |  8 +----
 Tests/Transformer/TestXalanTransformer.cpp         |  7 +----
 cmake/XalanDebug.cmake                             | 36 ++++++++++++++++++++++
 .../TransformToXercesDOM/TransformToXercesDOM.cpp  |  7 +----
 samples/XPathWrapper/TestDriver.cpp                |  8 +----
 src/xalanc/Harness/XalanFileUtility.cpp            |  4 ---
 src/xalanc/Include/PlatformDefinitions.hpp.in      |  7 +++++
 src/xalanc/Include/XalanList.hpp                   | 10 ++----
 src/xalanc/Include/XalanVector.hpp                 |  7 -----
 src/xalanc/PlatformSupport/ArenaBlock.hpp          |  5 +--
 .../PlatformSupport/XalanDOMStringHashTable.cpp    |  6 ++--
 .../PlatformSupport/XalanICUMessageLoader.cpp      | 21 -------------
 .../XalanReferenceCountedObject.cpp                |  3 --
 src/xalanc/TestXPath/TestXPath.cpp                 |  8 +----
 src/xalanc/TestXSLT/process.cpp                    |  8 +----
 src/xalanc/Utils/MsgCreator/MsgCreator.cpp         |  6 ++--
 src/xalanc/XMLSupport/XalanUTF8Writer.hpp          |  2 +-
 src/xalanc/XPath/NodeRefList.cpp                   |  4 +--
 src/xalanc/XPath/NodeRefList.hpp                   |  2 +-
 src/xalanc/XPath/XPathExpression.cpp               |  5 +--
 .../XalanDocumentFragmentNodeRefListBaseProxy.cpp  |  5 +--
 src/xalanc/XSLT/VariablesStack.cpp                 |  4 +--
 src/xalanc/XalanDOM/XalanDOMString.hpp             |  2 --
 src/xalanc/XalanDOM/XalanNode.hpp                  |  6 ----
 src/xalanc/XalanExe/XalanExe.cpp                   | 10 ++----
 37 files changed, 84 insertions(+), 211 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 456e86c..2c5eea1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,6 +60,7 @@ enable_testing()
 find_package(Threads REQUIRED)
 include(Doxygen)
 include(GNUInstallDirs)
+include(XalanDebug)
 include(XalanDLL)
 include(XalanWarnings)
 include(XalanFunctions)
diff --git a/Tests/C-API/c-api.c b/Tests/C-API/c-api.c
index f38da92..59fe44a 100644
--- a/Tests/C-API/c-api.c
+++ b/Tests/C-API/c-api.c
@@ -25,13 +25,6 @@
 
 
 
-// This is here for memory leak testing.
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
-
-
 void
 Usage()
 {
@@ -68,7 +61,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
 
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
diff --git a/Tests/Compare/compare.cpp b/Tests/Compare/compare.cpp
index 7c39856..ba80340 100644
--- a/Tests/Compare/compare.cpp
+++ b/Tests/Compare/compare.cpp
@@ -61,13 +61,6 @@ using std::endl;
 
 
 
-// This is here for memory leak testing.
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
-
-
 using xalanc::XalanFileUtility;
 
 
@@ -219,7 +212,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
diff --git a/Tests/Conf/conf.cpp b/Tests/Conf/conf.cpp
index c228a1d..b328c06 100644
--- a/Tests/Conf/conf.cpp
+++ b/Tests/Conf/conf.cpp
@@ -76,12 +76,6 @@ using namespace xalanc;
 
 
 
-// This is here for memory leak testing. 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
-
 
 using xercesc::MemoryManager;
 
@@ -619,7 +613,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
diff --git a/Tests/Dom2Dom/dom2dom.cpp b/Tests/Dom2Dom/dom2dom.cpp
index f9b7055..5e14310 100644
--- a/Tests/Dom2Dom/dom2dom.cpp
+++ b/Tests/Dom2Dom/dom2dom.cpp
@@ -32,11 +32,6 @@
 #include <unistd.h>
 #endif
 
-// This is here for memory leak testing. 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
 
 
 #include <xercesc/dom/DOMDocument.hpp>
@@ -387,7 +382,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
diff --git a/Tests/Errortests/Errortests.cpp b/Tests/Errortests/Errortests.cpp
index e77eb23..5ad0f69 100644
--- a/Tests/Errortests/Errortests.cpp
+++ b/Tests/Errortests/Errortests.cpp
@@ -56,12 +56,6 @@ using std::endl;
 #include <xalanc/Harness/XalanFileUtility.hpp>
 
 
-
-// This is here for memory leak testing. 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
 const char* const   excludeStylesheets[] =
 {
     0
@@ -310,7 +304,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
diff --git a/Tests/Extensions/extensions.cpp b/Tests/Extensions/extensions.cpp
index f38cfe8..799e374 100644
--- a/Tests/Extensions/extensions.cpp
+++ b/Tests/Extensions/extensions.cpp
@@ -27,13 +27,6 @@
 
 
 
-// This is here for memory leak testing. 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
-
-
 #include <xercesc/util/PlatformUtils.hpp>
 
 
@@ -422,7 +415,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
diff --git a/Tests/InputSource/inputsource.cpp b/Tests/InputSource/inputsource.cpp
index a047f5c..2979445 100644
--- a/Tests/InputSource/inputsource.cpp
+++ b/Tests/InputSource/inputsource.cpp
@@ -26,12 +26,6 @@
 
 
 
-// This is here for memory leak testing. 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
-
 
 // XERCES HEADERS...
 #include <xercesc/util/PlatformUtils.hpp>
@@ -416,7 +410,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
diff --git a/Tests/Memory/Stressmem.cpp b/Tests/Memory/Stressmem.cpp
index f3205bd..c78964c 100644
--- a/Tests/Memory/Stressmem.cpp
+++ b/Tests/Memory/Stressmem.cpp
@@ -25,13 +25,6 @@
 
 
 
-// This is here for memory leak testing. 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
-
-
 #include <xercesc/util/PlatformUtils.hpp>
 
 
@@ -230,7 +223,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
diff --git a/Tests/Memory/TestBlock.cpp b/Tests/Memory/TestBlock.cpp
index 36a0184..7aa96ea 100644
--- a/Tests/Memory/TestBlock.cpp
+++ b/Tests/Memory/TestBlock.cpp
@@ -17,15 +17,7 @@
  */
 
 #if defined(_MSC_VER)
-
 #pragma warning(disable: 4127 4251 4511 4512 4514 4702 4710 4711 4786 4097; error: 4150 4172 4238 4239 4715)
-
-#if defined(_DEBUG)
-
-#include <crtdbg.h>
-
-#endif
-
 #endif
 
 
@@ -118,7 +110,7 @@ main(
 
             clock_t theStartClock = 0;
 
-#if defined(_MSC_VER) && defined(_DEBUG)
+#if defined(XALAN_CRT_DEBUG)
             // Send all reports to STDOUT
             _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
             _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
@@ -132,7 +124,7 @@ main(
             {
                 theStartClock = clock();
 
-#if defined(_MSC_VER) && defined(_DEBUG)
+#if defined(XALAN_CRT_DEBUG)
                 _CrtMemState    theStartState;
 
                 _CrtMemCheckpoint(&theStartState);
@@ -145,7 +137,7 @@ main(
                     theStringVector.push_back(m_allocator.create("Test string"));
                 }
 
-#if defined(_MSC_VER) && defined(_DEBUG)
+#if defined(XALAN_CRT_DEBUG)
                 _CrtMemState    theEndState;
 
                 _CrtMemCheckpoint(&theEndState);
@@ -180,7 +172,7 @@ main(
             theStringVector.clear();
 
             {
-#if defined(_MSC_VER) && defined(_DEBUG)
+#if defined(XALAN_CRT_DEBUG)
                 _CrtMemState    theStartState;
 
                 _CrtMemCheckpoint(&theStartState);
@@ -195,7 +187,7 @@ main(
                     theStringVector.push_back(m_allocator.create("Test string"));
                 }
 
-#if defined(_MSC_VER) && defined(_DEBUG)
+#if defined(XALAN_CRT_DEBUG)
                 _CrtMemState    theEndState;
 
                 _CrtMemCheckpoint(&theEndState);
@@ -237,7 +229,7 @@ main(
             {
                 theStartClock = clock();
 
-#if defined(_MSC_VER) && defined(_DEBUG)
+#if defined(XALAN_CRT_DEBUG)
                 _CrtMemState    theStartState;
 
                 _CrtMemCheckpoint(&theStartState);
@@ -248,7 +240,7 @@ main(
                     theStringVector.push_back(new string("Test string"));
                 }
 
-#if defined(_MSC_VER) && defined(_DEBUG)
+#if defined(XALAN_CRT_DEBUG)
                 _CrtMemState    theEndState;
 
                 _CrtMemCheckpoint(&theEndState);
diff --git a/Tests/Params/Params.cpp b/Tests/Params/Params.cpp
index 7cb288f..abb87fa 100644
--- a/Tests/Params/Params.cpp
+++ b/Tests/Params/Params.cpp
@@ -24,11 +24,6 @@
 
 #include <iostream>
 
-// This is here for memory leak testing. 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
 
 
 #include <xercesc/util/PlatformUtils.hpp>
@@ -279,7 +274,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
diff --git a/Tests/PerfT/perft.cpp b/Tests/PerfT/perft.cpp
index bbed2a4..d6a5a3d 100644
--- a/Tests/PerfT/perft.cpp
+++ b/Tests/PerfT/perft.cpp
@@ -36,11 +36,6 @@
 #include <xalanc/Harness/XalanFileUtility.hpp>
 
 
-// This is here for memory leak testing.
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
 
 
 using std::cerr;
@@ -387,7 +382,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
diff --git a/Tests/Threads/ThreadTest.cpp b/Tests/Threads/ThreadTest.cpp
index f5b5a67..cc53a7c 100644
--- a/Tests/Threads/ThreadTest.cpp
+++ b/Tests/Threads/ThreadTest.cpp
@@ -86,12 +86,6 @@ using std::endl;
 using std::atoi;
 using std::strcmp;
 
-    
-    
-    // This is here for memory leak testing.
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
 
 
 
@@ -661,7 +655,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
 
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
diff --git a/Tests/Transformer/TestXalanTransformer.cpp b/Tests/Transformer/TestXalanTransformer.cpp
index d9155fa..618fb4b 100644
--- a/Tests/Transformer/TestXalanTransformer.cpp
+++ b/Tests/Transformer/TestXalanTransformer.cpp
@@ -23,11 +23,6 @@
 #define TEST_XALAN_CPP
 
 
-// This is here for memory leak testing.
-#if defined(_DEBUG)
-#include <crtdbg.h>
-#endif
-
 
 
 #include <xercesc/util/PlatformUtils.hpp>
@@ -306,7 +301,7 @@ main(
             int     /* argc */,
             char*   /* argv */ [])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
diff --git a/cmake/XalanDebug.cmake b/cmake/XalanDebug.cmake
new file mode 100644
index 0000000..b2bdbf6
--- /dev/null
+++ b/cmake/XalanDebug.cmake
@@ -0,0 +1,36 @@
+# CMake build for xalan-c
+#
+# Written by Roger Leigh <rl...@codelibre.net>
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Option for selection of shared or static libraries, exported as
+# cache variable
+
+set(xalan_debug_default OFF)
+if(CMAKE_BUILD_TYPE MATCHES Debug)
+  set(xalan_debug_default ON)
+endif()
+
+set(XALAN_DEBUG ${xalan_debug_default} CACHE BOOL "Build with additional debug checks")
+
+
+set(xalan_crt_debug_default OFF)
+if(xalan_debug_default AND MSVC)
+  set(xalan_crt_debug_default ON)
+endif()
+
+set(XALAN_CRT_DEBUG ${xalan_crt_debug_default} CACHE BOOL "Build with additional MSVC CRT debug checks (Windows only)")
diff --git a/samples/TransformToXercesDOM/TransformToXercesDOM.cpp b/samples/TransformToXercesDOM/TransformToXercesDOM.cpp
index c4082a6..89238b6 100644
--- a/samples/TransformToXercesDOM/TransformToXercesDOM.cpp
+++ b/samples/TransformToXercesDOM/TransformToXercesDOM.cpp
@@ -26,11 +26,6 @@
 
 
 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
-
 
 #include <xercesc/dom/DOMDocument.hpp>
 #include <xercesc/dom/DOMImplementation.hpp>
@@ -155,7 +150,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
 
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
diff --git a/samples/XPathWrapper/TestDriver.cpp b/samples/XPathWrapper/TestDriver.cpp
index efba36f..c4a4afb 100644
--- a/samples/XPathWrapper/TestDriver.cpp
+++ b/samples/XPathWrapper/TestDriver.cpp
@@ -34,19 +34,13 @@
 
 
 
-// This is here for memory leak testing. 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
-
 
 int
 main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
     _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
diff --git a/src/xalanc/Harness/XalanFileUtility.cpp b/src/xalanc/Harness/XalanFileUtility.cpp
index 3a82ecc..91f87dd 100644
--- a/src/xalanc/Harness/XalanFileUtility.cpp
+++ b/src/xalanc/Harness/XalanFileUtility.cpp
@@ -47,10 +47,6 @@
 #include <iostream>
 #include <strstream>
 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
 
 
 using std::fclose;
diff --git a/src/xalanc/Include/PlatformDefinitions.hpp.in b/src/xalanc/Include/PlatformDefinitions.hpp.in
index 706959c..74cc5e6 100644
--- a/src/xalanc/Include/PlatformDefinitions.hpp.in
+++ b/src/xalanc/Include/PlatformDefinitions.hpp.in
@@ -91,6 +91,13 @@
 
 #cmakedefine XALAN_NON_ASCII_PLATFORM 1
 
+#cmakedefine XALAN_DEBUG 1
+#cmakedefine XALAN_CRT_DEBUG 1
+
+#if defined(XALAN_CRT_DEBUG)
+#include <crtdbg.h>
+#endif
+
 #include <xalanc/Include/XalanVersion.hpp>
 
 #if defined(__cplusplus)
diff --git a/src/xalanc/Include/XalanList.hpp b/src/xalanc/Include/XalanList.hpp
index cf72f46..f31950d 100644
--- a/src/xalanc/Include/XalanList.hpp
+++ b/src/xalanc/Include/XalanList.hpp
@@ -359,14 +359,11 @@ public:
     void 
     splice(
             iterator    pos,
-#if defined(NDEBUG)
-            ThisType&   /* list */,
-#else
             ThisType&   list,
-#endif
             iterator    toInsert)
     {
         assert(m_memoryManager == list.m_memoryManager);
+        (void) list; // unused if assert is disabled
 
         if (pos != toInsert)
         {
@@ -387,15 +384,12 @@ public:
     void
     splice(
             iterator    pos,
-#if defined(NDEBUG)
-            ThisType&   /* list */,
-#else
             ThisType&   list,
-#endif
             iterator    toInsertFirst,
             iterator    toInsertLast)
     {
         assert(m_memoryManager == list.m_memoryManager);
+        (void) list; // unused if assert is disabled
 
         if (toInsertFirst != toInsertLast)
         {
diff --git a/src/xalanc/Include/XalanVector.hpp b/src/xalanc/Include/XalanVector.hpp
index b8ed46d..7571dff 100644
--- a/src/xalanc/Include/XalanVector.hpp
+++ b/src/xalanc/Include/XalanVector.hpp
@@ -868,12 +868,6 @@ public:
 
 private:
 
-#if defined(NDEBUG)
-    void
-    invariants() const
-    {
-    }
-#else
     void
     invariants() const
     {
@@ -882,7 +876,6 @@ private:
             (m_data == 0 && m_allocation == 0) ||
             (m_data != 0 && m_allocation != 0));
     }
-#endif
 
     size_type
     local_distance(
diff --git a/src/xalanc/PlatformSupport/ArenaBlock.hpp b/src/xalanc/PlatformSupport/ArenaBlock.hpp
index eb464a4..6760807 100644
--- a/src/xalanc/PlatformSupport/ArenaBlock.hpp
+++ b/src/xalanc/PlatformSupport/ArenaBlock.hpp
@@ -111,14 +111,11 @@ public:
      * @param theBlock the address that was returned by allocateBlock()
      */
     void
-#if defined (NDEBUG)
-    commitAllocation(ObjectType*    /* theBlock */)
-#else
     commitAllocation(ObjectType*    theBlock)
-#endif
     {
         assert(theBlock == this->m_objectBlock + this->m_objectCount);
         assert(this->m_objectCount < this->m_blockSize);
+        (void) theBlock; // unused if assert is disabled
 
         ++this->m_objectCount;
     }
diff --git a/src/xalanc/PlatformSupport/XalanDOMStringHashTable.cpp b/src/xalanc/PlatformSupport/XalanDOMStringHashTable.cpp
index ee33813..559ffd1 100644
--- a/src/xalanc/PlatformSupport/XalanDOMStringHashTable.cpp
+++ b/src/xalanc/PlatformSupport/XalanDOMStringHashTable.cpp
@@ -57,7 +57,7 @@ XalanDOMStringHashTable::clear()
         m_buckets[i].clear();
     }
 
-#if !defined(NDEBUG)
+#if defined(XALAN_DEBUG)
     m_collisions = 0;
 #endif
     m_count = 0;
@@ -181,7 +181,7 @@ XalanDOMStringHashTable::insert(const XalanDOMString&   theString)
 
     BucketType& theBucket = m_buckets[theBucketIndex];
 
-#if !defined(NDEBUG)
+#if defined(XALAN_DEBUG)
     if (theBucket.empty() == false)
     {
         ++m_collisions;
@@ -207,7 +207,7 @@ XalanDOMStringHashTable::insert(
 
     BucketType&     theBucket = m_buckets[theBucketIndex];
 
-#if !defined(NDEBUG)
+#if defined(XALAN_DEBUG)
     if (theBucket.empty() == false)
     {
         ++m_collisions;
diff --git a/src/xalanc/PlatformSupport/XalanICUMessageLoader.cpp b/src/xalanc/PlatformSupport/XalanICUMessageLoader.cpp
index 6dd2e67..aa18d1b 100644
--- a/src/xalanc/PlatformSupport/XalanICUMessageLoader.cpp
+++ b/src/xalanc/PlatformSupport/XalanICUMessageLoader.cpp
@@ -49,30 +49,9 @@
 
 #if defined(XALAN_WINDOWS)
 
-#if _MSC_VER >= 1400
-
 #define ENTRY_POINT_SUFFIX _dat
 #define PACKAGE_NAME_SUFFIX
 
-#else
-#ifdef  NDEBUG_SYMBOLS // release with symbols
-
-#define ENTRY_POINT_SUFFIX S_dat
-#define PACKAGE_NAME_SUFFIX S
-
-#elif NDEBUG // release
-
-#define ENTRY_POINT_SUFFIX _dat
-#define PACKAGE_NAME_SUFFIX
-
-#elif _DEBUG // debug only 
-
-#define ENTRY_POINT_SUFFIX D_dat
-#define PACKAGE_NAME_SUFFIX D
-
-#endif // NDEBUG_SYMBOLS
-#endif // _MSC_VER >= 1400
-
 #define PACKAGE_NAME INVK_CAT3_RAW_NUMERIC(XALAN_MESSAGES_NAME_W_UNDERSCORE,\
                                     INVK_CAT2_RAW_NUMERIC_SEP_UNDERSCORE(XALAN_VERSION_MAJOR,XALAN_VERSION_MINOR),\
                                     PACKAGE_NAME_SUFFIX)
diff --git a/src/xalanc/PlatformSupport/XalanReferenceCountedObject.cpp b/src/xalanc/PlatformSupport/XalanReferenceCountedObject.cpp
index c020f1a..7f6d09b 100644
--- a/src/xalanc/PlatformSupport/XalanReferenceCountedObject.cpp
+++ b/src/xalanc/PlatformSupport/XalanReferenceCountedObject.cpp
@@ -22,10 +22,7 @@
 
 
 #include <cassert>
-
-#if !defined(NDEBUG)
 #include <climits>
-#endif
 
 
 
diff --git a/src/xalanc/TestXPath/TestXPath.cpp b/src/xalanc/TestXPath/TestXPath.cpp
index 721c3b3..5c7f262 100644
--- a/src/xalanc/TestXPath/TestXPath.cpp
+++ b/src/xalanc/TestXPath/TestXPath.cpp
@@ -31,12 +31,6 @@
 
 
 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
-
-
 #include <xercesc/framework/URLInputSource.hpp>
 #include <xercesc/util/PlatformUtils.hpp>
 
@@ -1339,7 +1333,7 @@ main(
 {
     using std::cout;
 
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
 
    _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
diff --git a/src/xalanc/TestXSLT/process.cpp b/src/xalanc/TestXSLT/process.cpp
index 026afb6..da9d132 100644
--- a/src/xalanc/TestXSLT/process.cpp
+++ b/src/xalanc/TestXSLT/process.cpp
@@ -28,12 +28,6 @@
 
 
 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
-
-
 #include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/sax/SAXParseException.hpp>
 
@@ -1092,7 +1086,7 @@ main(
             int     argc,
             char*   argv[])
 {
-#if !defined(NDEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
 
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
diff --git a/src/xalanc/Utils/MsgCreator/MsgCreator.cpp b/src/xalanc/Utils/MsgCreator/MsgCreator.cpp
index c742389..0f84010 100644
--- a/src/xalanc/Utils/MsgCreator/MsgCreator.cpp
+++ b/src/xalanc/Utils/MsgCreator/MsgCreator.cpp
@@ -29,9 +29,7 @@
 #include <xercesc/util/TransService.hpp>
 
 #include <cassert>
-#if defined(_DEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
+
 
 
 using std::cerr;
@@ -327,7 +325,7 @@ buildIndexFileName(
 int main(int argC, char* argV[])
 {
     
-#if defined(_DEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
     
     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
diff --git a/src/xalanc/XMLSupport/XalanUTF8Writer.hpp b/src/xalanc/XMLSupport/XalanUTF8Writer.hpp
index 15ece47..65888fe 100644
--- a/src/xalanc/XMLSupport/XalanUTF8Writer.hpp
+++ b/src/xalanc/XMLSupport/XalanUTF8Writer.hpp
@@ -201,7 +201,7 @@ public:
             const value_type*   theChars,
             size_type           theLength)
     {
-    #if defined(NDEBUG)
+    #if !defined(XALAN_DEBUG)
         if (theLength > sizeof(m_buffer))
         {
             flushBuffer();
diff --git a/src/xalanc/XPath/NodeRefList.cpp b/src/xalanc/XPath/NodeRefList.cpp
index a71cb66..a35a2be 100644
--- a/src/xalanc/XPath/NodeRefList.cpp
+++ b/src/xalanc/XPath/NodeRefList.cpp
@@ -23,9 +23,7 @@
 #include <cassert>
 #include <algorithm>
 
-#if !defined(NDEBUG)
 #include <xalanc/Include/XalanSet.hpp>
-#endif
 
 
 
@@ -151,7 +149,7 @@ NodeRefList::indexOf(const XalanNode*   theNode) const
 
 
 
-#if !defined(NDEBUG)
+#if defined(XALAN_DEBUG)
 bool
 NodeRefList::checkForDuplicates(MemoryManager& theManager) const
 {
diff --git a/src/xalanc/XPath/NodeRefList.hpp b/src/xalanc/XPath/NodeRefList.hpp
index 058e182..0f6fd39 100644
--- a/src/xalanc/XPath/NodeRefList.hpp
+++ b/src/xalanc/XPath/NodeRefList.hpp
@@ -99,7 +99,7 @@ public:
     virtual size_type
     indexOf(const XalanNode*    theNode) const;
 
-#if !defined(NDEBUG)
+#if defined(XALAN_DEBUG)
     bool
     checkForDuplicates(MemoryManager& theManager) const;
 #endif
diff --git a/src/xalanc/XPath/XPathExpression.cpp b/src/xalanc/XPath/XPathExpression.cpp
index 6d05b23..ab5eb66 100644
--- a/src/xalanc/XPath/XPathExpression.cpp
+++ b/src/xalanc/XPath/XPathExpression.cpp
@@ -629,11 +629,7 @@ XPathExpression::insertOpCode(
 void
 XPathExpression::updateShiftedOpCodeLength(
             OpCodeMapValueType  theOpCode,
-#if defined(NDEBUG)
-            OpCodeMapSizeType   /* theOriginalIndex */,
-#else
             OpCodeMapSizeType   theOriginalIndex,
-#endif
             OpCodeMapSizeType   theNewIndex)
 {
     // There must be some other expressions in
@@ -641,6 +637,7 @@ XPathExpression::updateShiftedOpCodeLength(
     assert(opCodeMapSize() > theNewIndex + 1);
 
     assert(theNewIndex > theOriginalIndex);
+    (void) theOriginalIndex; // unused if assert is disabled
 
     const OpCodeMapValueType    theOpCodeLength = getOpCodeLength(theOpCode);
 
diff --git a/src/xalanc/XPath/XalanDocumentFragmentNodeRefListBaseProxy.cpp b/src/xalanc/XPath/XalanDocumentFragmentNodeRefListBaseProxy.cpp
index da55213..6bfaf28 100644
--- a/src/xalanc/XPath/XalanDocumentFragmentNodeRefListBaseProxy.cpp
+++ b/src/xalanc/XPath/XalanDocumentFragmentNodeRefListBaseProxy.cpp
@@ -56,13 +56,10 @@ XalanDocumentFragmentNodeRefListBaseProxy::~XalanDocumentFragmentNodeRefListBase
 
 
 XalanNode*
-#if defined(NDEBUG)
-XalanDocumentFragmentNodeRefListBaseProxy::item(size_type) const
-#else
 XalanDocumentFragmentNodeRefListBaseProxy::item(size_type   index) const
-#endif
 {
     assert(index == 0);
+    (void) index; // unused if assert is disabled
 
     return const_cast<XalanDocumentFragment*>(&m_value);
 }
diff --git a/src/xalanc/XSLT/VariablesStack.cpp b/src/xalanc/XSLT/VariablesStack.cpp
index 222658e..cd6fa70 100644
--- a/src/xalanc/XSLT/VariablesStack.cpp
+++ b/src/xalanc/XSLT/VariablesStack.cpp
@@ -523,7 +523,7 @@ VariablesStack::pushElementFrame(const ElemTemplateElement* elem)
 {
     push(StackEntry(elem));
 
-#if !defined(NDEBUG)
+#if defined(XALAN_DEBUG)
     m_elementFrameStack.push_back(elem);
 #endif
 }
@@ -575,7 +575,7 @@ VariablesStack::popElementFrame()
         }
         else if (theEntry.getType() == StackEntry::eElementFrameMarker)
         {
-#if !defined(NDEBUG)
+#if defined(XALAN_DEBUG)
             const ElemTemplateElement* const    theElement =
                 theEntry.getElement();
 
diff --git a/src/xalanc/XalanDOM/XalanDOMString.hpp b/src/xalanc/XalanDOM/XalanDOMString.hpp
index 270b931..f1b18b8 100644
--- a/src/xalanc/XalanDOM/XalanDOMString.hpp
+++ b/src/xalanc/XalanDOM/XalanDOMString.hpp
@@ -772,10 +772,8 @@ protected:
     void
     invariants() const
     {
-#if !defined(NDEBUG)
         assert((m_data.empty() == true && m_size == 0) || m_size == m_data.size() - 1);
         assert(m_data.empty() == true || m_data.back() == 0);
-#endif
     }
 
     /*
diff --git a/src/xalanc/XalanDOM/XalanNode.hpp b/src/xalanc/XalanDOM/XalanNode.hpp
index befb40b..61552b2 100644
--- a/src/xalanc/XalanDOM/XalanNode.hpp
+++ b/src/xalanc/XalanDOM/XalanNode.hpp
@@ -187,12 +187,6 @@ protected:
 
     bool
     operator==(const XalanNode&     theRHS) const;
-
-private:
-
-#if !defined(NDEBUG)
-    static size_t   s_instanceCount;
-#endif
 };
 
 
diff --git a/src/xalanc/XalanExe/XalanExe.cpp b/src/xalanc/XalanExe/XalanExe.cpp
index 90823ce..ad96a06 100644
--- a/src/xalanc/XalanExe/XalanExe.cpp
+++ b/src/xalanc/XalanExe/XalanExe.cpp
@@ -26,12 +26,6 @@
 
 
 
-#if !defined(NDEBUG) && defined(_MSC_VER)
-#include <crtdbg.h>
-#endif
-
-
-
 #include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/util/OutOfMemoryException.hpp>
 
@@ -896,7 +890,7 @@ xsltMain(
 
     using xercesc::XMLPlatformUtils;
 
-#if defined(XALAN_WINDOWS) && defined(NDEBUG)
+#if defined(XALAN_WINDOWS) && !defined(XALAN_DEBUG)
     WindowsMemoryManager  theMemoryManager;
 
     // Call the static initializer for Xerces...
@@ -969,7 +963,7 @@ main(
             int     argc,
             char*   argv[])
  {
-#if defined(_DEBUG) && defined(_MSC_VER)
+#if defined(XALAN_CRT_DEBUG)
     _CrtSetDbgFlag(
         _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xalan.apache.org
For additional commands, e-mail: commits-help@xalan.apache.org