From e1b82f180a508f2d1046ff045aac73dfd8cc2829 Mon Sep 17 00:00:00 2001
From: Tinny Ng <tng@apache.org>
Date: Fri, 1 Mar 2002 16:44:20 +0000
Subject: [PATCH] NodeIDMap informational message about growing only be printed
 if debug is on. Besides the throw message should be encap in the
 XMLErrList_EN_US.Xml, not hardcoded in the code.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@173554 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/NLS/EN_US/XMLErrList_EN_US.Xml    |  1 +
 src/xercesc/dom/NodeIDMap.cpp                 | 43 ++++++++++---------
 src/xercesc/idom/IDNodeIDMap.cpp              |  9 ++--
 .../MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp  |  3 +-
 .../MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg |  1 +
 src/xercesc/util/Platforms/Win32/Version.rc   |  1 +
 src/xercesc/util/XMLExceptMsgs.hpp            |  7 +--
 7 files changed, 38 insertions(+), 27 deletions(-)

diff --git a/src/xercesc/NLS/EN_US/XMLErrList_EN_US.Xml b/src/xercesc/NLS/EN_US/XMLErrList_EN_US.Xml
index bca596782..c963f4a74 100644
--- a/src/xercesc/NLS/EN_US/XMLErrList_EN_US.Xml
+++ b/src/xercesc/NLS/EN_US/XMLErrList_EN_US.Xml
@@ -758,6 +758,7 @@
             <Message Id="PD_RecurseUnordered" Text="RecurseUnordered: There is not a complete functional mapping between the particles"/>
             <Message Id="PD_MapAndSum" Text="MapAndSum: There is not a complete functional mapping between the particles"/>
             <Message Id="PD_InvalidContentType" Text="Particle derivation: Invalid content spec node type"/>
+            <Message Id="NodeIDMap_GrowErr" Text="NodeIDMap overflows and exceeds the largest available size"/>
         </FatalError>
     </MsgDomain>
     <MsgDomain Domain="http://apache.org/xml/messages/XML4JErrors">
diff --git a/src/xercesc/dom/NodeIDMap.cpp b/src/xercesc/dom/NodeIDMap.cpp
index 44a0025b8..1d7ba020b 100644
--- a/src/xercesc/dom/NodeIDMap.cpp
+++ b/src/xercesc/dom/NodeIDMap.cpp
@@ -1,37 +1,37 @@
 /*
  * The Apache Software License, Version 1.1
- * 
- * Copyright (c) 1999-2000 The Apache Software Foundation.  All rights
+ *
+ * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
  * reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
- * 
+ *
  * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer. 
- * 
+ *    notice, this list of conditions and the following disclaimer.
+ *
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in
  *    the documentation and/or other materials provided with the
  *    distribution.
- * 
+ *
  * 3. The end-user documentation included with the redistribution,
- *    if any, must include the following acknowledgment:  
+ *    if any, must include the following acknowledgment:
  *       "This product includes software developed by the
  *        Apache Software Foundation (http://www.apache.org/)."
  *    Alternately, this acknowledgment may appear in the software itself,
  *    if and wherever such third-party acknowledgments normally appear.
- * 
+ *
  * 4. The names "Xerces" and "Apache Software Foundation" must
  *    not be used to endorse or promote products derived from this
- *    software without prior written permission. For written 
+ *    software without prior written permission. For written
  *    permission, please contact apache\@apache.org.
- * 
+ *
  * 5. Products derived from this software may not be called "Apache",
  *    nor may "Apache" appear in their name, without prior written
  *    permission of the Apache Software Foundation.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
@@ -45,7 +45,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * ====================================================================
- * 
+ *
  * This software consists of voluntary contributions made by many
  * individuals on behalf of the Apache Software Foundation, and was
  * originally based on software copyright (c) 1999, International
@@ -58,6 +58,7 @@
 #include "AttrImpl.hpp"
 #include "NodeIDMap.hpp"
 #include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/RuntimeException.hpp>
 #include <stdio.h>
 
 static const int gPrimes[] = {997, 9973, 99991, 999983, 0 };  // To do - add a few more.
@@ -65,7 +66,7 @@ static const int gPrimes[] = {997, 9973, 99991, 999983, 0 };  // To do - add a f
 static const float gMaxFill = 0.8f;   // The maximum fraction of the total
                                     // table entries to consume before exanding.
 
-NodeIDMap::NodeIDMap(int initialSize) 
+NodeIDMap::NodeIDMap(int initialSize)
 {
     for (fSizeIndex = 0; gPrimes[fSizeIndex] < initialSize; fSizeIndex++)
     {
@@ -74,10 +75,10 @@ NodeIDMap::NodeIDMap(int initialSize)
             // We need a bigger size than the largest available one.
             //   Big trouble.
             fSizeIndex--;
-            throw "NodeIDMap::NodeIDMap - big trouble.";
+            ThrowXML(RuntimeException, XMLExcepts::NodeIDMap_GrowErr);
         }
     }
-    
+
     fSize = gPrimes[fSizeIndex];
     fNumEntries = 0;
     fMaxEntries = (unsigned long)(float(fSize) * gMaxFill);
@@ -120,7 +121,7 @@ void NodeIDMap::add(AttrImpl *attr)
 
 	//
 	// Loop looking for an empty slot for this ID.
-	//   Don't even bother checking to see if the ID is already there - 
+	//   Don't even bother checking to see if the ID is already there -
 	//   the table is only filled by the parser from valid documents, which
 	//   can not have duplicates.  Behavior of invalid docs is not defined.
 	//
@@ -231,7 +232,9 @@ void NodeIDMap::growTable()
     //
     //  Figure the new table size.
     //
+#if defined(XERCES_DEBUG)
     fprintf(stderr, "growing...\n");
+#endif
     fSizeIndex++;
     fSize = gPrimes[fSizeIndex];
     if (fSize == 0)
@@ -239,7 +242,7 @@ void NodeIDMap::growTable()
         // We need to grow bigger than the largest available size.
         //   Big trouble.
         fSizeIndex--;
-        throw "NodeIDMap::growTable - big trouble.";
+        ThrowXML(RuntimeException, XMLExcepts::NodeIDMap_GrowErr);
     }
 
     //
@@ -260,9 +263,9 @@ void NodeIDMap::growTable()
         if ((oldTable[i] != 0)  &&  (oldTable[i] != (AttrImpl *)-1))
             add(oldTable[i]);
     }
-    
+
     delete [] oldTable;
-    
+
 };
 
 
diff --git a/src/xercesc/idom/IDNodeIDMap.cpp b/src/xercesc/idom/IDNodeIDMap.cpp
index a49068536..92b9a534c 100644
--- a/src/xercesc/idom/IDNodeIDMap.cpp
+++ b/src/xercesc/idom/IDNodeIDMap.cpp
@@ -1,7 +1,7 @@
 /*
  * The Apache Software License, Version 1.1
  *
- * Copyright (c) 2001 The Apache Software Foundation.  All rights
+ * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
  * reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -62,6 +62,7 @@
 #include "IDDocumentImpl.hpp"
 #include "IDNodeIDMap.hpp"
 #include <xercesc/util/XMLString.hpp>
+#include <xercesc/util/RuntimeException.hpp>
 #include <stdio.h>
 
 static const int gPrimes[] = {997, 9973, 99991, 999983, 0 };  // To do - add a few more.
@@ -80,7 +81,7 @@ IDNodeIDMap::IDNodeIDMap(int initialSize, IDOM_Document *doc)
             // We need a bigger size than the largest available one.
             //   Big trouble.
             fSizeIndex--;
-            throw "IDNodeIDMap::IDNodeIDMap - big trouble.";
+            ThrowXML(RuntimeException, XMLExcepts::NodeIDMap_GrowErr);
         }
     }
 
@@ -238,7 +239,9 @@ void IDNodeIDMap::growTable()
     //
     //  Figure the new table size.
     //
+#if defined(XERCES_DEBUG)
     fprintf(stderr, "growing...\n");
+#endif
     fSizeIndex++;
     fSize = gPrimes[fSizeIndex];
     if (fSize == 0)
@@ -246,7 +249,7 @@ void IDNodeIDMap::growTable()
         // We need to grow bigger than the largest available size.
         //   Big trouble.
         fSizeIndex--;
-        throw "IDNodeIDMap::growTable - big trouble.";
+        ThrowXML(RuntimeException, XMLExcepts::NodeIDMap_GrowErr);
     }
 
     //
diff --git a/src/xercesc/util/MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp b/src/xercesc/util/MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp
index f310f43fa..ff8c7ca2d 100644
--- a/src/xercesc/util/MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp
+++ b/src/xercesc/util/MsgLoaders/InMemory/CppErrMsgs_EN_US.hpp
@@ -764,8 +764,9 @@ const XMLCh gXMLExceptArray[][128] =
   , { 0x0052,0x0065,0x0063,0x0075,0x0072,0x0073,0x0065,0x0055,0x006E,0x006F,0x0072,0x0064,0x0065,0x0072,0x0065,0x0064,0x003A,0x0020,0x0054,0x0068,0x0065,0x0072,0x0065,0x0020,0x0069,0x0073,0x0020,0x006E,0x006F,0x0074,0x0020,0x0061,0x0020,0x0063,0x006F,0x006D,0x0070,0x006C,0x0065,0x0074,0x0065,0x0020,0x0066,0x0075,0x006E,0x0063,0x0074,0x0069,0x006F,0x006E,0x0061,0x006C,0x0020,0x006D,0x0061,0x0070,0x0070,0x0069,0x006E,0x0067,0x0020,0x0062,0x0065,0x0074,0x0077,0x0065,0x0065,0x006E,0x0020,0x0074,0x0068,0x0065,0x0020,0x0070,0x0061,0x0072,0x0074,0x0069,0x0063,0x006C,0x0065,0x0073,0x00 }
   , { 0x004D,0x0061,0x0070,0x0041,0x006E,0x0064,0x0053,0x0075,0x006D,0x003A,0x0020,0x0054,0x0068,0x0065,0x0072,0x0065,0x0020,0x0069,0x0073,0x0020,0x006E,0x006F,0x0074,0x0020,0x0061,0x0020,0x0063,0x006F,0x006D,0x0070,0x006C,0x0065,0x0074,0x0065,0x0020,0x0066,0x0075,0x006E,0x0063,0x0074,0x0069,0x006F,0x006E,0x0061,0x006C,0x0020,0x006D,0x0061,0x0070,0x0070,0x0069,0x006E,0x0067,0x0020,0x0062,0x0065,0x0074,0x0077,0x0065,0x0065,0x006E,0x0020,0x0074,0x0068,0x0065,0x0020,0x0070,0x0061,0x0072,0x0074,0x0069,0x0063,0x006C,0x0065,0x0073,0x00 }
   , { 0x0050,0x0061,0x0072,0x0074,0x0069,0x0063,0x006C,0x0065,0x0020,0x0064,0x0065,0x0072,0x0069,0x0076,0x0061,0x0074,0x0069,0x006F,0x006E,0x003A,0x0020,0x0049,0x006E,0x0076,0x0061,0x006C,0x0069,0x0064,0x0020,0x0063,0x006F,0x006E,0x0074,0x0065,0x006E,0x0074,0x0020,0x0073,0x0070,0x0065,0x0063,0x0020,0x006E,0x006F,0x0064,0x0065,0x0020,0x0074,0x0079,0x0070,0x0065,0x00 }
+  , { 0x004E,0x006F,0x0064,0x0065,0x0049,0x0044,0x004D,0x0061,0x0070,0x0020,0x006F,0x0076,0x0065,0x0072,0x0066,0x006C,0x006F,0x0077,0x0073,0x0020,0x0061,0x006E,0x0064,0x0020,0x0065,0x0078,0x0063,0x0065,0x0065,0x0064,0x0073,0x0020,0x0074,0x0068,0x0065,0x0020,0x006C,0x0061,0x0072,0x0067,0x0065,0x0073,0x0074,0x0020,0x0061,0x0076,0x0061,0x0069,0x006C,0x0061,0x0062,0x006C,0x0065,0x0020,0x0073,0x0069,0x007A,0x0065,0x00 }
   , { 0x0046,0x005F,0x0045,0x006E,0x0064,0x00 }
 
 };
-const unsigned int gXMLExceptArraySize = 357;
+const unsigned int gXMLExceptArraySize = 358;
 
diff --git a/src/xercesc/util/MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg b/src/xercesc/util/MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg
index 62ac2b1fc..b7adcb135 100644
--- a/src/xercesc/util/MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg
+++ b/src/xercesc/util/MsgLoaders/MsgCatalog/XMLMsgCat_EN_US.Msg
@@ -742,5 +742,6 @@ $set 3
 351  RecurseUnordered: There is not a complete functional mapping between the particles
 352  MapAndSum: There is not a complete functional mapping between the particles
 353  Particle derivation: Invalid content spec node type
+354  NodeIDMap overflows and exceeds the largest available size
 
 
diff --git a/src/xercesc/util/Platforms/Win32/Version.rc b/src/xercesc/util/Platforms/Win32/Version.rc
index c6bd85864..9d87bcb68 100644
--- a/src/xercesc/util/Platforms/Win32/Version.rc
+++ b/src/xercesc/util/Platforms/Win32/Version.rc
@@ -847,6 +847,7 @@ BEGIN
     8543              L"\x0052\x0065\x0063\x0075\x0072\x0073\x0065\x0055\x006E\x006F\x0072\x0064\x0065\x0072\x0065\x0064\x003A\x0020\x0054\x0068\x0065\x0072\x0065\x0020\x0069\x0073\x0020\x006E\x006F\x0074\x0020\x0061\x0020\x0063\x006F\x006D\x0070\x006C\x0065\x0074\x0065\x0020\x0066\x0075\x006E\x0063\x0074\x0069\x006F\x006E\x0061\x006C\x0020\x006D\x0061\x0070\x0070\x0069\x006E\x0067\x0020\x0062\x0065\x0074\x0077\x0065\x0065\x006E\x0020\x0074\x0068\x0065\x0020\x0070\x0061\x0072\x0074\x0069\x0063\x006C\x0065\x0073\x00"
     8544              L"\x004D\x0061\x0070\x0041\x006E\x0064\x0053\x0075\x006D\x003A\x0020\x0054\x0068\x0065\x0072\x0065\x0020\x0069\x0073\x0020\x006E\x006F\x0074\x0020\x0061\x0020\x0063\x006F\x006D\x0070\x006C\x0065\x0074\x0065\x0020\x0066\x0075\x006E\x0063\x0074\x0069\x006F\x006E\x0061\x006C\x0020\x006D\x0061\x0070\x0070\x0069\x006E\x0067\x0020\x0062\x0065\x0074\x0077\x0065\x0065\x006E\x0020\x0074\x0068\x0065\x0020\x0070\x0061\x0072\x0074\x0069\x0063\x006C\x0065\x0073\x00"
     8545              L"\x0050\x0061\x0072\x0074\x0069\x0063\x006C\x0065\x0020\x0064\x0065\x0072\x0069\x0076\x0061\x0074\x0069\x006F\x006E\x003A\x0020\x0049\x006E\x0076\x0061\x006C\x0069\x0064\x0020\x0063\x006F\x006E\x0074\x0065\x006E\x0074\x0020\x0073\x0070\x0065\x0063\x0020\x006E\x006F\x0064\x0065\x0020\x0074\x0079\x0070\x0065\x00"
+    8546              L"\x004E\x006F\x0064\x0065\x0049\x0044\x004D\x0061\x0070\x0020\x006F\x0076\x0065\x0072\x0066\x006C\x006F\x0077\x0073\x0020\x0061\x006E\x0064\x0020\x0065\x0078\x0063\x0065\x0065\x0064\x0073\x0020\x0074\x0068\x0065\x0020\x006C\x0061\x0072\x0067\x0065\x0073\x0074\x0020\x0061\x0076\x0061\x0069\x006C\x0061\x0062\x006C\x0065\x0020\x0073\x0069\x007A\x0065\x00"
 END
 
 
diff --git a/src/xercesc/util/XMLExceptMsgs.hpp b/src/xercesc/util/XMLExceptMsgs.hpp
index 0bbf28ae1..f1912401d 100644
--- a/src/xercesc/util/XMLExceptMsgs.hpp
+++ b/src/xercesc/util/XMLExceptMsgs.hpp
@@ -362,9 +362,10 @@ public :
       , PD_RecurseUnordered                = 351
       , PD_MapAndSum                       = 352
       , PD_InvalidContentType              = 353
-      , F_HighBounds                       = 354
-      , E_LowBounds                        = 355
-      , E_HighBounds                       = 356
+      , NodeIDMap_GrowErr                  = 354
+      , F_HighBounds                       = 355
+      , E_LowBounds                        = 356
+      , E_HighBounds                       = 357
     };
 
 };
-- 
GitLab