You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by db...@apache.org on 2005/06/03 18:00:46 UTC

svn commit: r179821 - in /xerces/c/trunk/src/xercesc/util: XMLInitializer.cpp XMLInitializer.hpp regx/RegularExpression.cpp regx/RegularExpression.hpp regx/TokenFactory.cpp regx/TokenFactory.hpp

Author: dbertoni
Date: Fri Jun  3 09:00:44 2005
New Revision: 179821

URL: http://svn.apache.org/viewcvs?rev=179821&view=rev
Log:
Fixes for Jira issue XERCESC-1417

Modified:
    xerces/c/trunk/src/xercesc/util/XMLInitializer.cpp
    xerces/c/trunk/src/xercesc/util/XMLInitializer.hpp
    xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp
    xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp
    xerces/c/trunk/src/xercesc/util/regx/TokenFactory.cpp
    xerces/c/trunk/src/xercesc/util/regx/TokenFactory.hpp

Modified: xerces/c/trunk/src/xercesc/util/XMLInitializer.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/XMLInitializer.cpp?rev=179821&r1=179820&r2=179821&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLInitializer.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLInitializer.cpp Fri Jun  3 09:00:44 2005
@@ -51,6 +51,7 @@
         initializeXSDErrReporterMsgLoader();
         initializeDTDGrammarDfltEntities();
         initializeRangeTokenMap();
+        initializeRegularExpression();
         initializeAnyType();
     }
     catch(...) {

Modified: xerces/c/trunk/src/xercesc/util/XMLInitializer.hpp
URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/XMLInitializer.hpp?rev=179821&r1=179820&r2=179821&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/XMLInitializer.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/XMLInitializer.hpp Fri Jun  3 09:00:44 2005
@@ -76,6 +76,7 @@
     static void initializeXSDErrReporterMsgLoader();
     static void initializeDTDGrammarDfltEntities();
     static void initializeRangeTokenMap();
+    static void initializeRegularExpression();
     static void initializeAnyType();
 
     //@}

Modified: xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp?rev=179821&r1=179820&r2=179821&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp Fri Jun  3 09:00:44 2005
@@ -133,6 +133,8 @@
 #include <xercesc/util/IllegalArgumentException.hpp>
 #include <xercesc/framework/XMLBuffer.hpp>
 #include <xercesc/util/OutOfMemoryException.hpp>
+#include <xercesc/util/XMLInitializer.hpp>
+#include <xercesc/util/XMLRegisterCleanup.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -155,6 +157,17 @@
 const unsigned short RegularExpression::WT_OTHER = 2;
 RangeToken*          RegularExpression::fWordRange = 0;
 
+
+static void
+localCleanup()
+{
+    RegularExpression::staticCleanup();
+}
+
+static XMLRegisterCleanup WordRangeCleanup;
+
+
+
 // ---------------------------------------------------------------------------
 //  RegularExpression::Context: Constructors and Destructor
 // ---------------------------------------------------------------------------
@@ -421,6 +434,8 @@
 	fTokenTree = regxParser->parse(fPattern, fOptions);
 	fNoGroups = regxParser->getNoParen();
 	fHasBackReferences = regxParser->hasBackReferences();
+
+    prepare();
 }
 
 // ---------------------------------------------------------------------------
@@ -488,9 +503,6 @@
                                 const int end, Match* const pMatch
                                 , MemoryManager* const manager)	{
 		
-	if (fOperations == 0)
-		prepare();
-
 	Context context(manager);
 	int		 strLength = XMLString::stringLen(expression);
 
@@ -694,9 +706,6 @@
                                                      const int start, const int end,
                                                      RefVectorOf<Match> *subEx){
   
-  if (fOperations == 0)
-	  prepare();
-
   RefArrayVectorOf<XMLCh>* tokenStack = new (fMemoryManager) RefArrayVectorOf<XMLCh>(16, true, fMemoryManager);
 
   Context context(fMemoryManager);
@@ -891,6 +900,31 @@
     
 }
 
+
+// -----------------------------------------------------------------------
+//  Static initialize and cleanup methods
+// -----------------------------------------------------------------------
+void
+XMLInitializer::initializeRegularExpression()
+{
+    RegularExpression::staticInitialize(XMLPlatformUtils::fgMemoryManager);
+}
+
+
+
+void
+RegularExpression::staticInitialize(MemoryManager*  memoryManager)
+{
+    fWordRange = TokenFactory::staticGetRange(fgUniIsWord, false);
+
+	if (fWordRange == 0)
+		ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Regex_RangeTokenGetError, fgUniIsWord, memoryManager);
+
+    WordRangeCleanup.registerCleanup(localCleanup);
+}
+
+
+
 // ---------------------------------------------------------------------------
 //  RegularExpression: Helpers methods
 // ---------------------------------------------------------------------------
@@ -1533,13 +1567,12 @@
 }
 
 
+
 /*
- * Prepares for matching. This method is called just before starting matching
+ * Prepares for matching. This method is called during construction.
  */
 void RegularExpression::prepare() {
 
-	XMLMutexLock lockInit(&fMutex);
-
 	compile(fTokenTree);
 
 	fMinLength = fTokenTree->getMinLength();
@@ -1622,7 +1655,7 @@
 
 		if (isSet(fOptions, USE_UNICODE_CATEGORY)) {
 
-			if (fWordRange == 0) {
+            if (fWordRange == 0) {
 
 				fWordRange = fTokenFactory->getRange(fgUniIsWord);
 				if (fWordRange == 0)

Modified: xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp
URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp?rev=179821&r1=179820&r2=179821&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp Fri Jun  3 09:00:44 2005
@@ -27,7 +27,6 @@
 #include <xercesc/util/RefArrayVectorOf.hpp>
 #include <xercesc/util/XMLString.hpp>
 #include <xercesc/util/Janitor.hpp>
-#include <xercesc/util/Mutexes.hpp>
 #include <xercesc/util/regx/Op.hpp>
 #include <xercesc/util/regx/TokenFactory.hpp>
 #include <xercesc/util/regx/BMPattern.hpp>
@@ -139,6 +138,15 @@
     XMLCh *replace(const XMLCh* const matchString, const XMLCh* const replaceString,
                    const int start, const int end);
 
+    // -----------------------------------------------------------------------
+    //  Static initialize and cleanup methods
+    // -----------------------------------------------------------------------
+    static void
+    staticInitialize(MemoryManager*  memoryManager);
+
+    static void
+    staticCleanup();
+
 private:
     // -----------------------------------------------------------------------
     //  Private data types
@@ -288,11 +296,19 @@
     RangeToken*        fFirstChar;
     static RangeToken* fWordRange;
     OpFactory          fOpFactory;
-    XMLMutex           fMutex;
     TokenFactory*      fTokenFactory;
     MemoryManager*     fMemoryManager;
 };
 
+
+
+  // -----------------------------------------------------------------------
+  //  RegularExpression: Static initialize and cleanup methods
+  // -----------------------------------------------------------------------
+  inline void RegularExpression::staticCleanup()
+  {
+      fWordRange = 0;
+  }
 
   // ---------------------------------------------------------------------------
   //  RegularExpression: Cleanup methods

Modified: xerces/c/trunk/src/xercesc/util/regx/TokenFactory.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/regx/TokenFactory.cpp?rev=179821&r1=179820&r2=179821&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/TokenFactory.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/TokenFactory.cpp Fri Jun  3 09:00:44 2005
@@ -258,7 +258,7 @@
 // ---------------------------------------------------------------------------
 //  TokenFactory - Getter methods
 // ---------------------------------------------------------------------------
-RangeToken* TokenFactory::getRange(const XMLCh* const keyword,
+RangeToken* TokenFactory::staticGetRange(const XMLCh* const keyword,
                                    const bool complement) {
 
 	return RangeTokenMap::instance()->getRange(keyword, complement);

Modified: xerces/c/trunk/src/xercesc/util/regx/TokenFactory.hpp
URL: http://svn.apache.org/viewcvs/xerces/c/trunk/src/xercesc/util/regx/TokenFactory.hpp?rev=179821&r1=179820&r2=179821&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/TokenFactory.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/TokenFactory.hpp Fri Jun  3 09:00:44 2005
@@ -98,6 +98,8 @@
 	Token* getGraphemePattern();
     MemoryManager* getMemoryManager() const;
 
+    static RangeToken* staticGetRange(const XMLCh* const name,const bool complement=false);
+
     // -----------------------------------------------------------------------
     //  Notification that lazy data has been deleted
     // -----------------------------------------------------------------------
@@ -137,6 +139,11 @@
     Token*              fGrapheme;
     MemoryManager*      fMemoryManager;
 };
+
+inline RangeToken* TokenFactory::getRange(const XMLCh* const name,const bool complement)
+{
+    return staticGetRange(name, complement);
+}
 
 inline MemoryManager* TokenFactory::getMemoryManager() const
 {



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