You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by am...@apache.org on 2007/08/28 16:18:20 UTC

svn commit: r570441 - in /xerces/c/trunk: src/xercesc/util/regx/ tests/src/DOM/DOMTest/

Author: amassari
Date: Tue Aug 28 07:18:18 2007
New Revision: 570441

URL: http://svn.apache.org/viewvc?rev=570441&view=rev
Log:
- Changed regex code to use enum instead of short
- Added some testing for regex inside DOMTest

Modified:
    xerces/c/trunk/src/xercesc/util/regx/CharToken.cpp
    xerces/c/trunk/src/xercesc/util/regx/CharToken.hpp
    xerces/c/trunk/src/xercesc/util/regx/ClosureToken.cpp
    xerces/c/trunk/src/xercesc/util/regx/ClosureToken.hpp
    xerces/c/trunk/src/xercesc/util/regx/Op.cpp
    xerces/c/trunk/src/xercesc/util/regx/Op.hpp
    xerces/c/trunk/src/xercesc/util/regx/OpFactory.cpp
    xerces/c/trunk/src/xercesc/util/regx/OpFactory.hpp
    xerces/c/trunk/src/xercesc/util/regx/ParenToken.cpp
    xerces/c/trunk/src/xercesc/util/regx/ParenToken.hpp
    xerces/c/trunk/src/xercesc/util/regx/ParserForXMLSchema.cpp
    xerces/c/trunk/src/xercesc/util/regx/ParserForXMLSchema.hpp
    xerces/c/trunk/src/xercesc/util/regx/RangeToken.cpp
    xerces/c/trunk/src/xercesc/util/regx/RangeToken.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/RegxParser.cpp
    xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp
    xerces/c/trunk/src/xercesc/util/regx/StringToken.cpp
    xerces/c/trunk/src/xercesc/util/regx/StringToken.hpp
    xerces/c/trunk/src/xercesc/util/regx/Token.cpp
    xerces/c/trunk/src/xercesc/util/regx/Token.hpp
    xerces/c/trunk/src/xercesc/util/regx/TokenFactory.cpp
    xerces/c/trunk/src/xercesc/util/regx/TokenFactory.hpp
    xerces/c/trunk/src/xercesc/util/regx/UnionToken.cpp
    xerces/c/trunk/src/xercesc/util/regx/UnionToken.hpp
    xerces/c/trunk/tests/src/DOM/DOMTest/DTest.cpp
    xerces/c/trunk/tests/src/DOM/DOMTest/DTest.h

Modified: xerces/c/trunk/src/xercesc/util/regx/CharToken.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/CharToken.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/CharToken.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/CharToken.cpp Tue Aug 28 07:18:18 2007
@@ -29,8 +29,8 @@
 // ---------------------------------------------------------------------------
 //  Token: Constructors and Destructors
 // ---------------------------------------------------------------------------
-CharToken::CharToken(const unsigned short tokType, const XMLInt32 ch, MemoryManager* const manager)
-    : Token(tokType, manager)
+CharToken::CharToken(const Token::tokType tkType, const XMLInt32 ch, MemoryManager* const manager)
+    : Token(tkType, manager)
     , fCharData(ch)
 {
 

Modified: xerces/c/trunk/src/xercesc/util/regx/CharToken.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/CharToken.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/CharToken.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/CharToken.hpp Tue Aug 28 07:18:18 2007
@@ -34,7 +34,7 @@
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-	CharToken(const unsigned short tokType, const XMLInt32 ch
+	CharToken(const tokType tkType, const XMLInt32 ch
         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
 	~CharToken();
 

Modified: xerces/c/trunk/src/xercesc/util/regx/ClosureToken.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/ClosureToken.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/ClosureToken.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/ClosureToken.cpp Tue Aug 28 07:18:18 2007
@@ -29,8 +29,8 @@
 // ---------------------------------------------------------------------------
 //  ClosureToken: Constructors and Destructors
 // ---------------------------------------------------------------------------
-ClosureToken::ClosureToken(const unsigned short tokType, Token* const tok, MemoryManager* const manager)
-    : Token(tokType, manager)
+ClosureToken::ClosureToken(const Token::tokType tkType, Token* const tok, MemoryManager* const manager)
+    : Token(tkType, manager)
     , fMin(-1)    
     , fMax(-1)
     , fChild(tok)

Modified: xerces/c/trunk/src/xercesc/util/regx/ClosureToken.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/ClosureToken.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/ClosureToken.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/ClosureToken.hpp Tue Aug 28 07:18:18 2007
@@ -34,7 +34,7 @@
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-	ClosureToken(const unsigned short tokType, Token* const tok
+	ClosureToken(const tokType tkType, Token* const tok
         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
 	~ClosureToken();
 

Modified: xerces/c/trunk/src/xercesc/util/regx/Op.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/Op.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/Op.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/Op.cpp Tue Aug 28 07:18:18 2007
@@ -30,7 +30,7 @@
 // ---------------------------------------------------------------------------
 //  Op: Constructors and Destructors
 // ---------------------------------------------------------------------------
-Op::Op(const short type, MemoryManager* const manager) 
+Op::Op(const Op::opType type, MemoryManager* const manager) 
     : fMemoryManager(manager)
     , fOpType(type)
     , fNextOp(0)
@@ -110,7 +110,7 @@
 // ---------------------------------------------------------------------------
 //  CharOp: Constructors and Destuctors
 // ---------------------------------------------------------------------------
-CharOp::CharOp(const short type, const XMLInt32 charData
+CharOp::CharOp(const Op::opType type, const XMLInt32 charData
                , MemoryManager* const manager)
     : Op(type, manager)
       , fCharData(charData) {
@@ -127,7 +127,7 @@
 // ---------------------------------------------------------------------------
 //  UnionOp: Constructors and Destuctors
 // ---------------------------------------------------------------------------
-UnionOp::UnionOp(const short type, const int size, MemoryManager* const manager)
+UnionOp::UnionOp(const Op::opType type, const int size, MemoryManager* const manager)
     : Op(type, manager)
       , fBranches(new (manager) RefVectorOf<Op> (size, false, manager)) {
 
@@ -154,7 +154,7 @@
 // ---------------------------------------------------------------------------
 //  ChildOp: Constructors and Destuctors
 // ---------------------------------------------------------------------------
-ChildOp::ChildOp(const short type, MemoryManager* const manager)
+ChildOp::ChildOp(const Op::opType type, MemoryManager* const manager)
     : Op(type, manager)
       , fChild(0) {
 
@@ -176,7 +176,7 @@
 // ---------------------------------------------------------------------------
 //  ModifierOp: Constructors and Destuctors
 // ---------------------------------------------------------------------------
-ModifierOp::ModifierOp(const short type, const XMLInt32 v1, const XMLInt32 v2
+ModifierOp::ModifierOp(const Op::opType type, const XMLInt32 v1, const XMLInt32 v2
                        , MemoryManager* const manager)
     : ChildOp(type, manager)
       , fVal1(v1)
@@ -200,7 +200,7 @@
 // ---------------------------------------------------------------------------
 //  RangeOp: Constructors and Destuctors
 // ---------------------------------------------------------------------------
-RangeOp::RangeOp(const short type, const Token* const token, MemoryManager* const manager)
+RangeOp::RangeOp(const Op::opType type, const Token* const token, MemoryManager* const manager)
     : Op (type, manager)
       , fToken(token) {
 
@@ -218,7 +218,7 @@
 // ---------------------------------------------------------------------------
 //  StringOp: Constructors and Destuctors
 // ---------------------------------------------------------------------------
-StringOp::StringOp(const short type, const XMLCh* const literal
+StringOp::StringOp(const Op::opType type, const XMLCh* const literal
                    , MemoryManager* const manager)
     : Op (type, manager)
       , fLiteral(XMLString::replicate(literal, manager)) {
@@ -236,7 +236,7 @@
 // ---------------------------------------------------------------------------
 //  ConditionOp: Constructors and Destuctors
 // ---------------------------------------------------------------------------
-ConditionOp::ConditionOp(const short type, const int refNo,
+ConditionOp::ConditionOp(const Op::opType type, const int refNo,
                          const Op* const condFlow, const Op* const yesFlow,
                          const Op* const noFlow, MemoryManager* const manager)
     : Op (type, manager)

Modified: xerces/c/trunk/src/xercesc/util/regx/Op.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/Op.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/Op.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/Op.hpp Tue Aug 28 07:18:18 2007
@@ -40,7 +40,7 @@
 {
 public:
 
-    enum {
+    typedef enum {
         O_DOT                = 0,
         O_CHAR               = 1,
         O_RANGE              = 3,
@@ -61,7 +61,7 @@
         O_INDEPENDENT        = 24,
         O_MODIFIER           = 25,
         O_CONDITION          = 26
-    };
+    } opType;
 
     // -----------------------------------------------------------------------
     //  Public Constructors and Destructor
@@ -71,7 +71,7 @@
     // -----------------------------------------------------------------------
     // Getter functions
     // -----------------------------------------------------------------------
-            short        getOpType() const;
+            opType       getOpType() const;
             const Op*    getNextOp() const;
     virtual XMLInt32     getData() const;
     virtual XMLInt32     getData2() const;
@@ -88,14 +88,14 @@
     // -----------------------------------------------------------------------
     // Setter functions
     // -----------------------------------------------------------------------
-    void setOpType(const short type);
+    void setOpType(const opType type);
     void setNextOp(const Op* const next);
 
 protected:
     // -----------------------------------------------------------------------
     //  Protected Constructors
     // -----------------------------------------------------------------------
-    Op(const short type, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
+    Op(const opType type, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
     friend class OpFactory;
 
     MemoryManager* const fMemoryManager;
@@ -116,7 +116,7 @@
     //  fNextOp
     //      Points to the next operation in the chain
     // -----------------------------------------------------------------------
-    short fOpType;
+    opType      fOpType;
     const Op*   fNextOp;
 };
 
@@ -126,7 +126,7 @@
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-	CharOp(const short type, const XMLInt32 charData, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
+	CharOp(const opType type, const XMLInt32 charData, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
 	~CharOp() {}
 
 	// -----------------------------------------------------------------------
@@ -150,7 +150,7 @@
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-	UnionOp(const short type, const int size,
+	UnionOp(const opType type, const int size,
             MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
 	~UnionOp() { delete fBranches; }
 
@@ -182,7 +182,7 @@
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-	ChildOp(const short type, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
+	ChildOp(const opType type, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
 	~ChildOp() {}
 
 	// -----------------------------------------------------------------------
@@ -211,7 +211,7 @@
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-	ModifierOp(const short type, const XMLInt32 v1, const XMLInt32 v2, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
+	ModifierOp(const opType type, const XMLInt32 v1, const XMLInt32 v2, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
 	~ModifierOp() {}
 
 	// -----------------------------------------------------------------------
@@ -237,7 +237,7 @@
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-	RangeOp(const short type, const Token* const token, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
+	RangeOp(const opType type, const Token* const token, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
 	~RangeOp() {}
 
 	// -----------------------------------------------------------------------
@@ -261,7 +261,7 @@
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-	StringOp(const short type, const XMLCh* const literal, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
+	StringOp(const opType type, const XMLCh* const literal, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
 	~StringOp() { fMemoryManager->deallocate(fLiteral);}
 
 	// -----------------------------------------------------------------------
@@ -285,7 +285,7 @@
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-	ConditionOp(const short type, const int refNo,
+	ConditionOp(const opType type, const int refNo,
 				const Op* const condFlow, const Op* const yesFlow,
 				const Op* const noFlow, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
 	~ConditionOp() {}
@@ -315,7 +315,7 @@
 // ---------------------------------------------------------------------------
 //  Op: getter methods
 // ---------------------------------------------------------------------------
-inline short Op::getOpType() const {
+inline Op::opType Op::getOpType() const {
 
 	return fOpType;
 }
@@ -328,7 +328,7 @@
 // ---------------------------------------------------------------------------
 //  Op: setter methods
 // ---------------------------------------------------------------------------
-inline void Op::setOpType(const short type) {
+inline void Op::setOpType(const Op::opType type) {
 
 	fOpType = type;
 }

Modified: xerces/c/trunk/src/xercesc/util/regx/OpFactory.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/OpFactory.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/OpFactory.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/OpFactory.cpp Tue Aug 28 07:18:18 2007
@@ -120,7 +120,7 @@
 	return tmpOp;
 }
 
-ChildOp* OpFactory::createLookOp(const short type, const Op* const next,
+ChildOp* OpFactory::createLookOp(const Op::opType type, const Op* const next,
 						         const Op* const branch) {
 
 	ChildOp* tmpOp = new (fMemoryManager) ChildOp(type, fMemoryManager);

Modified: xerces/c/trunk/src/xercesc/util/regx/OpFactory.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/OpFactory.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/OpFactory.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/OpFactory.hpp Tue Aug 28 07:18:18 2007
@@ -72,7 +72,7 @@
 	ChildOp* createNonGreedyClosureOp();
 	ChildOp* createQuestionOp(bool nonGreedy);
 	RangeOp* createRangeOp(const Token* const token);
-	ChildOp* createLookOp(const short type, const Op* const next,
+    ChildOp* createLookOp(const Op::opType type, const Op* const next,
                           const Op* const branch);
 	CharOp* createBackReferenceOp(int refNo);
 	StringOp* createStringOp(const XMLCh* const literal);

Modified: xerces/c/trunk/src/xercesc/util/regx/ParenToken.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/ParenToken.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/ParenToken.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/ParenToken.cpp Tue Aug 28 07:18:18 2007
@@ -29,9 +29,9 @@
 // ---------------------------------------------------------------------------
 //  ParenToken: Constructors and Destructors
 // ---------------------------------------------------------------------------
-ParenToken::ParenToken(const unsigned short tokType,
+ParenToken::ParenToken(const Token::tokType tkType,
                        Token* const tok, const int noParen, MemoryManager* const manager)
-    : Token(tokType, manager)
+    : Token(tkType, manager)
     , fNoParen(noParen)
     , fChild(tok)
 {

Modified: xerces/c/trunk/src/xercesc/util/regx/ParenToken.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/ParenToken.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/ParenToken.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/ParenToken.hpp Tue Aug 28 07:18:18 2007
@@ -34,7 +34,7 @@
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-	ParenToken(const unsigned short tokType, Token* const tok,
+	ParenToken(const tokType tkType, Token* const tok,
                const int noParen, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
     ~ParenToken();
 

Modified: xerces/c/trunk/src/xercesc/util/regx/ParserForXMLSchema.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/ParserForXMLSchema.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/ParserForXMLSchema.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/ParserForXMLSchema.cpp Tue Aug 28 07:18:18 2007
@@ -288,7 +288,7 @@
     return -1;
 }
 
-Token* ParserForXMLSchema::processLook(const unsigned short) {
+Token* ParserForXMLSchema::processLook(const Token::tokType ) {
 
     ThrowXMLwithMemMgr(RuntimeException, XMLExcepts::Regex_NotSupported, getMemoryManager());
     return 0; // for compilers that complain about no return value

Modified: xerces/c/trunk/src/xercesc/util/regx/ParserForXMLSchema.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/ParserForXMLSchema.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/ParserForXMLSchema.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/ParserForXMLSchema.hpp Tue Aug 28 07:18:18 2007
@@ -55,7 +55,7 @@
                                          const XMLInt32 ch);
     Token*      processCaret();
     Token*      processDollar();
-	Token*		processLook(const unsigned short tokType);
+	Token*		processLook(const Token::tokType tkType);
     Token*      processBacksolidus_A();
     Token*      processBacksolidus_Z();
     Token*      processBacksolidus_z();

Modified: xerces/c/trunk/src/xercesc/util/regx/RangeToken.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/RangeToken.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/RangeToken.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/RangeToken.cpp Tue Aug 28 07:18:18 2007
@@ -54,9 +54,9 @@
 // ---------------------------------------------------------------------------
 //  RangeToken: Constructors and Destructors
 // ---------------------------------------------------------------------------
-RangeToken::RangeToken(const unsigned short tokType,
+RangeToken::RangeToken(const Token::tokType tkType,
                        MemoryManager* const manager) 
-    : Token(tokType, manager)
+    : Token(tkType, manager)
     , fSorted(false)
     , fCompacted(false)
     , fNonMapIndex(0)

Modified: xerces/c/trunk/src/xercesc/util/regx/RangeToken.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/RangeToken.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/RangeToken.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/RangeToken.hpp Tue Aug 28 07:18:18 2007
@@ -41,7 +41,7 @@
     // -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-    RangeToken(const unsigned short tokType,
+    RangeToken(const tokType tkType,
                MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
     ~RangeToken();
 

Modified: xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/RegularExpression.cpp Tue Aug 28 07:18:18 2007
@@ -55,9 +55,6 @@
 const unsigned int RegularExpression::PROHIBIT_FIXED_STRING_OPTIMIZATION = 256;
 const unsigned int RegularExpression::XMLSCHEMA_MODE = 512;
 const unsigned int RegularExpression::SPECIAL_COMMA = 1024;
-const unsigned short RegularExpression::WT_IGNORE = 0;
-const unsigned short RegularExpression::WT_LETTER = 1;
-const unsigned short RegularExpression::WT_OTHER = 2;
 RangeToken*          RegularExpression::fWordRange = 0;
 
 
@@ -998,7 +995,7 @@
 int RegularExpression::match(Context* const context, const Op* const operations
 							 , XMLSize_t offset, const short direction)
 {
-    ValueStackOf<RE_RuntimeContext>	opStack((unsigned int)(context->fLength - offset), fMemoryManager);
+    ValueStackOf<RE_RuntimeContext>	opStack(0, fMemoryManager);
 	const Op* tmpOp = operations;
 	bool ignoreCase = isSet(fOptions, IGNORE_CASE);
 	int	doReturn;
@@ -1279,9 +1276,9 @@
 		if (context->fLength == 0)
 			break;
 		{
-			int after = getWordType(context->fString, context->fStart,
+			wordType after = getWordType(context->fString, context->fStart,
 									context->fLimit, offset);
-			if (after == WT_IGNORE
+			if (after == wordTypeIgnore
 				|| after == getPreviousWordType(context->fString,
 												context->fStart,
 												context->fLimit, offset))
@@ -1292,9 +1289,9 @@
 		if (context->fLength == 0)
 			return false;
 		{
-			int after = getWordType(context->fString, context->fStart,
+			wordType after = getWordType(context->fString, context->fStart,
 									context->fLimit, offset);
-			if (after == WT_IGNORE
+			if (after == wordTypeIgnore
 				|| after == getPreviousWordType(context->fString,
 												context->fStart
 												, context->fLimit, offset))
@@ -1342,9 +1339,9 @@
 			return false;
 
 		if (getWordType(context->fString, context->fStart, context->fLimit,
-						offset) != WT_LETTER
+						offset) != wordTypeLetter
 			|| getPreviousWordType(context->fString, context->fStart,
-								   context->fLimit, offset) != WT_OTHER)
+								   context->fLimit, offset) != wordTypeOther)
 			return false;
 		break;
 	case chCloseAngle:
@@ -1352,9 +1349,9 @@
 			return false;
 
 		if (getWordType(context->fString, context->fStart, context->fLimit,
-						offset) != WT_OTHER
+						offset) != wordTypeOther
 			|| getPreviousWordType(context->fString, context->fStart,
-								   context->fLimit, offset) != WT_LETTER)
+								   context->fLimit, offset) != wordTypeLetter)
 			return false;
 		break;
 	}
@@ -1524,7 +1521,7 @@
 
 	Op* ret = 0;
 
-	const unsigned short tokenType = token->getTokenType();
+    const Token::tokType tokenType = token->getTokenType();
 
 	switch(tokenType) {
 	case Token::T_DOT:
@@ -1667,7 +1664,7 @@
 		!isSet(fOptions, XMLSCHEMA_MODE))							{
 
 		RangeToken* rangeTok = fTokenFactory->createRange();
-		int result = fTokenTree->analyzeFirstCharacter(rangeTok, fOptions, fTokenFactory);
+        Token::firstCharacterOptions result = fTokenTree->analyzeFirstCharacter(rangeTok, fOptions, fTokenFactory);
 
 		if (result == Token::FC_TERMINAL) {
 
@@ -1741,7 +1738,7 @@
 	}
 }
 
-unsigned short RegularExpression::getCharType(const XMLCh ch) {
+RegularExpression::wordType RegularExpression::getCharType(const XMLCh ch) {
 
     if (!isSet(fOptions, UNICODE_WORD_BOUNDARY)) {
 
@@ -1754,10 +1751,10 @@
 					ThrowXMLwithMemMgr1(RuntimeException, XMLExcepts::Regex_RangeTokenGetError, fgUniIsWord, fMemoryManager);
 			}
 
-			return fWordRange->match(ch) ? WT_LETTER : WT_OTHER;
+			return fWordRange->match(ch) ? wordTypeLetter : wordTypeOther;
 		}
 
-		return RegxUtil::isWordChar(ch);
+        return RegxUtil::isWordChar(ch) ? wordTypeLetter : wordTypeIgnore;
     }
 
 	switch (XMLUniCharacter::getType(ch)) {
@@ -1770,11 +1767,11 @@
 	case XMLUniCharacter::DECIMAL_DIGIT_NUMBER:
 	case XMLUniCharacter::OTHER_NUMBER:
 	case XMLUniCharacter::COMBINING_SPACING_MARK:
-		return WT_LETTER;
+		return wordTypeLetter;
 	case XMLUniCharacter::FORMAT:
 	case XMLUniCharacter::NON_SPACING_MARK:
 	case XMLUniCharacter::ENCLOSING_MARK:
-		return WT_IGNORE;
+		return wordTypeIgnore;
 	case XMLUniCharacter::CONTROL:
 		switch (ch) {
 		case chHTab:
@@ -1782,13 +1779,13 @@
 		case chVTab:
 		case chFF:
 		case chCR:
-			return WT_OTHER;
+			return wordTypeOther;
 		default:
-			return WT_IGNORE;
+			return wordTypeIgnore;
 		}
 	}
 
-    return WT_OTHER;
+    return wordTypeOther;
 }
 
 

Modified: xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/RegularExpression.hpp Tue Aug 28 07:18:18 2007
@@ -89,9 +89,12 @@
     static const unsigned int   PROHIBIT_FIXED_STRING_OPTIMIZATION;
     static const unsigned int   XMLSCHEMA_MODE;
     static const unsigned int   SPECIAL_COMMA;
-    static const unsigned short WT_IGNORE;
-    static const unsigned short WT_LETTER;
-    static const unsigned short WT_OTHER;
+    typedef enum 
+    {
+        wordTypeIgnore = 0,
+        wordTypeLetter = 1,
+        wordTypeOther = 2
+    } wordType;
 
     // -----------------------------------------------------------------------
     //  Public Helper methods
@@ -205,10 +208,10 @@
     // -----------------------------------------------------------------------
     void prepare();
     int parseOptions(const XMLCh* const options);
-    unsigned short getWordType(const XMLCh* const target, const XMLSize_t begin,
+    wordType getWordType(const XMLCh* const target, const XMLSize_t begin,
                                const XMLSize_t end, const XMLSize_t offset);
-    unsigned short getCharType(const XMLCh ch);
-    unsigned short getPreviousWordType(const XMLCh* const target,
+    wordType getCharType(const XMLCh ch);
+    wordType getPreviousWordType(const XMLCh* const target,
                                        const XMLSize_t start, const XMLSize_t end,
                                        XMLSize_t offset);
 
@@ -274,7 +277,7 @@
       *    Helper methods used by compile
       */
     Op* compileSingle(const Token* const token, Op* const next,
-                      const unsigned short tokType);
+                      const Token::tokType tkType);
     Op* compileUnion(const Token* const token, Op* const next,
                      const bool reverse);
     Op* compileCondition(const Token* const token, Op* const next,
@@ -282,11 +285,11 @@
     Op* compileParenthesis(const Token* const token, Op* const next,
                            const bool reverse);
     Op* compileLook(const Token* const token, const Op* const next,
-                    const bool reverse, const unsigned short tokType);
+                    const bool reverse, const Token::tokType tkType);
     Op* compileConcat(const Token* const token, Op* const next,
                       const bool reverse);
     Op* compileClosure(const Token* const token, Op* const next,
-                       const bool reverse, const unsigned short tokType);
+                       const bool reverse, const Token::tokType tkType);
 
     // -----------------------------------------------------------------------
     //  Private data members
@@ -294,8 +297,8 @@
     bool               fHasBackReferences;
     bool               fFixedStringOnly;
     int                fNoGroups;
-    int                fMinLength;
-    int                fNoClosures;
+    XMLSize_t          fMinLength;
+    unsigned int       fNoClosures;
     unsigned int       fOptions;
     BMPattern*         fBMPattern;
     XMLCh*             fPattern;
@@ -341,12 +344,12 @@
   inline Op* RegularExpression::compileLook(const Token* const token,
                                             const Op* const next,
                                             const bool reverse,
-                                            const unsigned short tokType) {
+                                            const Token::tokType tkType) {
 
       Op*    ret = 0;
       Op*    result = compile(token->getChild(0), 0, reverse);
 
-      switch(tokType) {
+      switch(tkType) {
       case Token::T_LOOKAHEAD:
           ret = fOpFactory.createLookOp(Op::O_LOOKAHEAD, next, result);
           break;
@@ -375,11 +378,11 @@
 
   inline Op* RegularExpression::compileSingle(const Token* const token,
                                               Op* const next,
-                                              const unsigned short tokType) {
+                                              const Token::tokType tkType) {
 
       Op* ret = 0;
 
-      switch (tokType) {
+      switch (tkType) {
       case Token::T_DOT:
           ret = fOpFactory.createDotOp();
           break;
@@ -404,7 +407,7 @@
           break;
       }
 
-      if (tokType != Token::T_EMPTY)
+      if (tkType != Token::T_EMPTY)
           ret->setNextOp(next);
 
       return ret;
@@ -492,7 +495,7 @@
   inline Op* RegularExpression::compileClosure(const Token* const token,
                                                Op* const next,
                                                const bool reverse,
-                                               const unsigned short tokType) {
+                                               const Token::tokType tkType) {
 
       Op*    ret      = 0;
       Token* childTok = token->getChild(0);
@@ -518,7 +521,7 @@
           for (int i=0; i<max; i++) {
 
               ChildOp* childOp = fOpFactory.createQuestionOp(
-                  tokType == Token::T_NONGREEDYCLOSURE);
+                  tkType == Token::T_NONGREEDYCLOSURE);
 
               childOp->setNextOp(next);
               childOp->setChild(compile(childTok, ret, reverse));
@@ -529,7 +532,7 @@
 
           ChildOp* childOp = 0;
 
-          if (tokType == Token::T_NONGREEDYCLOSURE) {
+          if (tkType == Token::T_NONGREEDYCLOSURE) {
               childOp = fOpFactory.createNonGreedyClosureOp();
           }
           else {
@@ -570,26 +573,26 @@
       return ret;
   }
 
-  inline unsigned short RegularExpression::getWordType(const XMLCh* const target
-                                                       , const XMLSize_t begin
-                                                       , const XMLSize_t end
-                                                       , const XMLSize_t offset)
+  inline RegularExpression::wordType RegularExpression::getWordType(const XMLCh* const target
+                                                                   , const XMLSize_t begin
+                                                                   , const XMLSize_t end
+                                                                   , const XMLSize_t offset)
   {
       if (offset < begin || offset >= end)
-          return WT_OTHER;
+          return wordTypeOther;
 
       return getCharType(target[offset]);
   }
 
   inline
-  unsigned short RegularExpression::getPreviousWordType(const XMLCh* const target
-                                                        , const XMLSize_t start
-                                                        , const XMLSize_t end
-                                                        , XMLSize_t offset)
+  RegularExpression::wordType RegularExpression::getPreviousWordType(const XMLCh* const target
+                                                                    , const XMLSize_t start
+                                                                    , const XMLSize_t end
+                                                                    , XMLSize_t offset)
   {
-      unsigned short ret = getWordType(target, start, end, --offset);
+      wordType ret = getWordType(target, start, end, --offset);
 
-      while (ret == WT_IGNORE) {
+      while (ret == wordTypeIgnore) {
           ret = getWordType(target, start, end, --offset);
       }
 

Modified: xerces/c/trunk/src/xercesc/util/regx/RegxParser.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/RegxParser.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/RegxParser.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/RegxParser.cpp Tue Aug 28 07:18:18 2007
@@ -34,12 +34,6 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 // ---------------------------------------------------------------------------
-//  Static member data initialization
-// ---------------------------------------------------------------------------
-const unsigned short RegxParser::regexParserStateNormal		= 0;
-const unsigned short RegxParser::regexParserStateInBrackets	= 1;
-
-// ---------------------------------------------------------------------------
 //  RegxParser::ReferencePostion: Constructors and Destructor
 // ---------------------------------------------------------------------------
 RegxParser::ReferencePosition::ReferencePosition(const int refNo,
@@ -61,7 +55,7 @@
      fNoGroups(1),
      fParseContext(regexParserStateNormal),
      fStringLen(0),
-     fState(0),
+     fState(REGX_T_EOF),
      fCharData(0),
      fString(0),
      fReferences(0),
@@ -139,7 +133,7 @@
         return;
 	}
 
-    unsigned short nextState;
+    parserState nextState;
 	XMLCh ch = fString[fOffset++];
 	fCharData = ch;
 
@@ -349,7 +343,7 @@
 
 Token* RegxParser::parseTerm(const bool matchingRParen) {
 
-    unsigned short state = fState;
+    parserState state = fState;
 
     if (state == REGX_T_OR || state == REGX_T_EOF
         || (state == REGX_T_RPAREN && matchingRParen)) {
@@ -391,11 +385,11 @@
 }
 
 
-Token* RegxParser::processLook(const unsigned short tokType) {
+Token* RegxParser::processLook(const Token::tokType tkType) {
 
     processNext();
 
-	Token* tok = fTokenFactory->createLook(tokType, parseRegx());
+	Token* tok = fTokenFactory->createLook(tkType, parseRegx());
 
     if (fState != REGX_T_RPAREN) {
         ThrowXMLwithMemMgr(ParseException,XMLExcepts::Parser_Factor1, fMemoryManager);

Modified: xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/RegxParser.hpp Tue Aug 28 07:18:18 2007
@@ -30,6 +30,7 @@
 // ---------------------------------------------------------------------------
 #include <xercesc/util/RefVectorOf.hpp>
 #include <xercesc/util/XMLUniDefs.hpp>
+#include <xercesc/util/regx/Token.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -48,7 +49,7 @@
     //  Public constant data
     // -----------------------------------------------------------------------
     // Parse tokens
-	enum {
+	typedef enum {
 		REGX_T_CHAR                     = 0,
 		REGX_T_EOF                      = 1,
 		REGX_T_OR                       = 2,
@@ -74,10 +75,12 @@
 		REGX_T_MODIFIERS                = 22,
 		REGX_T_CONDITION                = 23,
 		REGX_T_XMLSCHEMA_CC_SUBTRACTION	= 24
-	};
+	} parserState;
 
-	static const unsigned short regexParserStateNormal;
-	static const unsigned short regexParserStateInBrackets;
+    typedef enum {
+        regexParserStateNormal = 0,
+        regexParserStateInBrackets = 1
+    } parserStateContext;
 
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
@@ -88,19 +91,19 @@
     // -----------------------------------------------------------------------
     //  Getter methods
     // -----------------------------------------------------------------------
-    unsigned short getParseContext() const;
-    unsigned short getState() const;
-    XMLInt32       getCharData() const;
-    int            getNoParen() const;
-	XMLSize_t      getOffset() const;
-	bool           hasBackReferences() const;
-    TokenFactory*  getTokenFactory() const;
-    int            getOptions() const;
+    parserStateContext  getParseContext() const;
+    parserState         getState() const;
+    XMLInt32            getCharData() const;
+    int                 getNoParen() const;
+	XMLSize_t           getOffset() const;
+	bool                hasBackReferences() const;
+    TokenFactory*       getTokenFactory() const;
+    int                 getOptions() const;
 
 	// -----------------------------------------------------------------------
     //  Setter methods
     // -----------------------------------------------------------------------
-	void setParseContext(const unsigned short value);
+	void setParseContext(const parserStateContext value);
     void setTokenFactory(TokenFactory* const tokFactory);
     void setOptions(const int options);
 
@@ -123,7 +126,7 @@
 	Token*              parseRegx(const bool matchingRParen = false);
 	virtual Token*      processCaret();
     virtual Token*      processDollar();
-	virtual Token*      processLook(const unsigned short tokType);
+	virtual Token*      processLook(const Token::tokType tkType);
     virtual Token*      processBacksolidus_A();
     virtual Token*      processBacksolidus_z();
     virtual Token*      processBacksolidus_Z();
@@ -197,9 +200,9 @@
 	int                             fOptions;
 	XMLSize_t                       fOffset;
 	int                             fNoGroups;
-	unsigned short                  fParseContext;
+	parserStateContext              fParseContext;
 	XMLSize_t                       fStringLen;
-	unsigned short                  fState;
+	parserState                     fState;
 	XMLInt32                        fCharData;
 	XMLCh*                          fString;
 	RefVectorOf<ReferencePosition>* fReferences;
@@ -210,12 +213,12 @@
 // ---------------------------------------------------------------------------
 //  RegxParser: Getter Methods
 // ---------------------------------------------------------------------------
-inline unsigned short RegxParser::getParseContext() const {
+inline RegxParser::parserStateContext RegxParser::getParseContext() const {
 
     return fParseContext;
 }
 
-inline unsigned short RegxParser::getState() const {
+inline RegxParser::parserState RegxParser::getState() const {
 
 	return fState;
 }
@@ -257,7 +260,7 @@
 // ---------------------------------------------------------------------------
 //  RegxParser: Setter Methods
 // ---------------------------------------------------------------------------
-inline void RegxParser::setParseContext(const unsigned short value) {
+inline void RegxParser::setParseContext(const RegxParser::parserStateContext value) {
 
 	fParseContext = value;
 }

Modified: xerces/c/trunk/src/xercesc/util/regx/StringToken.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/StringToken.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/StringToken.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/StringToken.cpp Tue Aug 28 07:18:18 2007
@@ -29,11 +29,11 @@
 // ---------------------------------------------------------------------------
 //  Token: Constructors and Destructors
 // ---------------------------------------------------------------------------
-StringToken::StringToken(const unsigned short tokType,
+StringToken::StringToken(const Token::tokType tkType,
                          const XMLCh* const literal,
                          const int refNo,
                          MemoryManager* const manager)
-    : Token(tokType, manager)
+    : Token(tkType, manager)
     , fRefNo(refNo)
     , fString(XMLString::replicate(literal, manager))    
     , fMemoryManager(manager)

Modified: xerces/c/trunk/src/xercesc/util/regx/StringToken.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/StringToken.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/StringToken.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/StringToken.hpp Tue Aug 28 07:18:18 2007
@@ -35,7 +35,7 @@
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-	StringToken(const unsigned short tokType,
+	StringToken(const tokType tkType,
                 const XMLCh* const literal,
                 const int refNo,
                 MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);

Modified: xerces/c/trunk/src/xercesc/util/regx/Token.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/Token.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/Token.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/Token.cpp Tue Aug 28 07:18:18 2007
@@ -33,16 +33,13 @@
 //  Static member data initialization
 // ---------------------------------------------------------------------------
 const XMLInt32		 Token::UTF16_MAX = 0x10FFFF;
-const unsigned short Token::FC_CONTINUE = 0;
-const unsigned short Token::FC_TERMINAL = 1;
-const unsigned short Token::FC_ANY = 2;
 
 // ---------------------------------------------------------------------------
 //  Token: Constructors and Destructors
 // ---------------------------------------------------------------------------
-Token::Token(const unsigned short tokType
+Token::Token(const Token::tokType tkType
              , MemoryManager* const manager) 
-             : fTokenType(tokType) 
+             : fTokenType(tkType) 
              , fMemoryManager(manager)
 {
 
@@ -56,13 +53,13 @@
 // ---------------------------------------------------------------------------
 //  Token: Getter mthods
 // ---------------------------------------------------------------------------
-int Token::getMinLength() const {
+XMLSize_t Token::getMinLength() const {
 
 	switch (fTokenType) {
 
 	case T_CONCAT:
         {
-            int sum = 0;
+            XMLSize_t sum = 0;
             unsigned int childSize = size();
 
             for (unsigned int i=0; i<childSize; i++) {
@@ -78,11 +75,11 @@
             if (childSize == 0) {
                 return 0;
             }
-			int ret = getChild(0)->getMinLength();
+			XMLSize_t ret = getChild(0)->getMinLength();
 
             for (unsigned int i=1; i < childSize; i++) {
 
-                int min = getChild(i)->getMinLength();
+                XMLSize_t min = getChild(i)->getMinLength();
                 if (min < ret)
                     ret = min;
             }
@@ -109,7 +106,7 @@
 	case T_BACKREFERENCE:
 		return 0; // *****  - REVISIT
 	case T_STRING:
-		return (int)XMLString::stringLen(getString());
+		return XMLString::stringLen(getString());
 	case T_LOOKAHEAD:
 	case T_NEGATIVELOOKAHEAD:
 	case T_LOOKBEHIND:
@@ -120,7 +117,7 @@
 	}
 
 	// We should not get here, but we have it to make some compilers happy
-	return -1;
+	return (XMLSize_t)-1;
 }
 
 
@@ -207,14 +204,14 @@
 // ---------------------------------------------------------------------------
 //  Token: Helper mthods
 // ---------------------------------------------------------------------------
-int Token::analyzeFirstCharacter(RangeToken* const rangeTok,
-								 const int options,
-                                 TokenFactory* const tokFactory)
+Token::firstCharacterOptions Token::analyzeFirstCharacter(RangeToken* const rangeTok,
+                                                          const int options,
+                                                          TokenFactory* const tokFactory)
 {
 	switch(fTokenType) {
 	case T_CONCAT:
 		{
-			int ret = FC_CONTINUE;
+			firstCharacterOptions ret = FC_CONTINUE;
 			for (int i=0; i<size(); i++) {
 
 				Token* tok = getChild(i);
@@ -231,7 +228,7 @@
             if (childSize == 0)
                 return FC_CONTINUE;
 
-            int ret = FC_CONTINUE;
+            firstCharacterOptions ret = FC_CONTINUE;
 			bool hasEmpty = false;
 
 			for (unsigned int i=0; i < childSize; i++) {
@@ -247,7 +244,7 @@
 		}
 	case T_CONDITION:
 		{
-            int ret1 = getChild(0)->analyzeFirstCharacter(rangeTok, options, tokFactory);
+            firstCharacterOptions ret1 = getChild(0)->analyzeFirstCharacter(rangeTok, options, tokFactory);
 
             if (size() == 1)
                 return FC_CONTINUE;
@@ -255,7 +252,7 @@
 			if (ret1 == FC_ANY)
 				return FC_ANY;
 
-			int ret2 = getChild(1)->analyzeFirstCharacter(rangeTok, options, tokFactory);
+			firstCharacterOptions ret2 = getChild(1)->analyzeFirstCharacter(rangeTok, options, tokFactory);
 			if (ret2 == FC_ANY)
 				return FC_ANY;
 
@@ -344,7 +341,7 @@
 //		throw;
 	}
 
-	return 0;
+	return FC_CONTINUE;
 }
 
 

Modified: xerces/c/trunk/src/xercesc/util/regx/Token.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/Token.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/Token.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/Token.hpp Tue Aug 28 07:18:18 2007
@@ -41,18 +41,10 @@
 {
 public:
 	// -----------------------------------------------------------------------
-    //  Public Constructors and Destructor
-    // -----------------------------------------------------------------------
-	Token(const unsigned short tokType
-        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
-        );
-	virtual ~Token();
-
-	// -----------------------------------------------------------------------
     //  Public Constants
     // -----------------------------------------------------------------------
 	// Token types
-	enum {
+	typedef enum {
 		T_CHAR = 0,
 		T_CONCAT = 1,
 		T_UNION = 2,
@@ -73,18 +65,29 @@
 		T_INDEPENDENT = 24,
 		T_MODIFIERGROUP = 25,
 		T_CONDITION = 26
-	};
+	} tokType;
+
+	// -----------------------------------------------------------------------
+    //  Public Constructors and Destructor
+    // -----------------------------------------------------------------------
+    Token(const tokType tkType
+        , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
+        );
+	virtual ~Token();
 
 	static const XMLInt32		UTF16_MAX;
-	static const unsigned short FC_CONTINUE;
-	static const unsigned short FC_TERMINAL;
-	static const unsigned short FC_ANY;
+
+    typedef enum {
+        FC_CONTINUE = 0,
+        FC_TERMINAL = 1,
+        FC_ANY = 2
+    } firstCharacterOptions;
 
 	// -----------------------------------------------------------------------
     //  Getter methods
     // -----------------------------------------------------------------------
-	unsigned short       getTokenType() const;
-	int                  getMinLength() const;
+	tokType              getTokenType() const;
+	XMLSize_t            getMinLength() const;
     int                  getMaxLength() const;
 	virtual Token*       getChild(const int index) const;
 	virtual int          size() const;
@@ -98,7 +101,7 @@
 	// -----------------------------------------------------------------------
     //  Setter methods
     // -----------------------------------------------------------------------
-	void setTokenType(const unsigned short tokType);
+    void setTokenType(const tokType tokType);
 	virtual void setMin(const int minVal);
 	virtual void setMax(const int maxVal);
 
@@ -120,8 +123,8 @@
 	// -----------------------------------------------------------------------
     //  Helper methods
     // -----------------------------------------------------------------------
-	int analyzeFirstCharacter(RangeToken* const rangeTok, const int options,
-                              TokenFactory* const tokFactory);
+	firstCharacterOptions analyzeFirstCharacter(RangeToken* const rangeTok, const int options,
+                                                TokenFactory* const tokFactory);
     Token* findFixedString(int options, int& outOptions);
 
 private:
@@ -140,7 +143,7 @@
 	// -----------------------------------------------------------------------
     //  Private data members
 	// -----------------------------------------------------------------------
-	unsigned short fTokenType;
+	tokType fTokenType;
 protected:
     MemoryManager* const    fMemoryManager;
 };
@@ -149,7 +152,7 @@
 // ---------------------------------------------------------------------------
 //  Token: getter methods
 // ---------------------------------------------------------------------------
-inline unsigned short Token::getTokenType() const {
+inline Token::tokType Token::getTokenType() const {
 
 	return fTokenType;
 }
@@ -197,7 +200,7 @@
 // ---------------------------------------------------------------------------
 //  Token: setter methods
 // ---------------------------------------------------------------------------
-inline void Token::setTokenType(const unsigned short tokType) {
+inline void Token::setTokenType(const Token::tokType tokType) {
 	
 	fTokenType = tokType;
 }

Modified: xerces/c/trunk/src/xercesc/util/regx/TokenFactory.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/TokenFactory.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/TokenFactory.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/TokenFactory.cpp Tue Aug 28 07:18:18 2007
@@ -68,14 +68,14 @@
 // ---------------------------------------------------------------------------
 //  TokenFactory - Factory methods
 // ---------------------------------------------------------------------------
-Token* TokenFactory::createToken(const unsigned short tokType) {
+Token* TokenFactory::createToken(const Token::tokType tkType) {
 
-	if (tokType == Token::T_EMPTY && fEmpty != 0)
+	if (tkType == Token::T_EMPTY && fEmpty != 0)
 		return fEmpty;
 
-	Token* tmpTok = new (fMemoryManager) Token(tokType, fMemoryManager);
+	Token* tmpTok = new (fMemoryManager) Token(tkType, fMemoryManager);
 
-	if (tokType == Token::T_EMPTY) {
+	if (tkType == Token::T_EMPTY) {
 		fEmpty = tmpTok;
     }
 
@@ -85,10 +85,10 @@
 }
 
 
-ParenToken* TokenFactory::createLook(const unsigned short tokType,
+ParenToken* TokenFactory::createLook(const Token::tokType tkType,
 									 Token* const token) {
 
-	ParenToken* tmpTok = new (fMemoryManager) ParenToken(tokType, token, 0, fMemoryManager);
+	ParenToken* tmpTok = new (fMemoryManager) ParenToken(tkType, token, 0, fMemoryManager);
 
 	fTokens->addElement(tmpTok);
 	return tmpTok;

Modified: xerces/c/trunk/src/xercesc/util/regx/TokenFactory.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/TokenFactory.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/TokenFactory.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/TokenFactory.hpp Tue Aug 28 07:18:18 2007
@@ -57,9 +57,9 @@
     // -----------------------------------------------------------------------
     //  Factory methods
     // -----------------------------------------------------------------------
-    Token* createToken(const unsigned short tokType);
+    Token* createToken(const Token::tokType tkType);
 
-    ParenToken* createLook(const unsigned short tokType, Token* const token);
+    ParenToken* createLook(const Token::tokType tkType, Token* const token);
     ParenToken* createParenthesis(Token* const token, const int noGroups);
     ClosureToken* createClosure(Token* const token, bool isNonGreedy = false);
     ConcatToken* createConcat(Token* const token1, Token* const token2);

Modified: xerces/c/trunk/src/xercesc/util/regx/UnionToken.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/UnionToken.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/UnionToken.cpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/UnionToken.cpp Tue Aug 28 07:18:18 2007
@@ -38,8 +38,8 @@
 // ---------------------------------------------------------------------------
 //  UnionToken: Constructors and Destructors
 // ---------------------------------------------------------------------------
-UnionToken::UnionToken(const unsigned short tokType, MemoryManager* const manager)
-    : Token(tokType, manager)
+UnionToken::UnionToken(const Token::tokType tkType, MemoryManager* const manager)
+    : Token(tkType, manager)
     , fChildren(0)
 {
 
@@ -68,7 +68,7 @@
         return;
     }
 
-    unsigned short childType = child->getTokenType();
+    Token::tokType childType = child->getTokenType();
     unsigned int   childSize = child->size();
 
     if (childType == T_CONCAT) {
@@ -89,7 +89,7 @@
     }
 
     Token* previousTok = fChildren->elementAt(childrenSize - 1);
-    unsigned short previousType = previousTok->getTokenType();
+    Token::tokType previousType = previousTok->getTokenType();
 
     if (!((previousType == T_CHAR || previousType == T_STRING)
           && (childType == T_CHAR || childType == T_STRING))) {

Modified: xerces/c/trunk/src/xercesc/util/regx/UnionToken.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/util/regx/UnionToken.hpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/util/regx/UnionToken.hpp (original)
+++ xerces/c/trunk/src/xercesc/util/regx/UnionToken.hpp Tue Aug 28 07:18:18 2007
@@ -35,7 +35,7 @@
 	// -----------------------------------------------------------------------
     //  Public Constructors and Destructor
     // -----------------------------------------------------------------------
-	UnionToken(const unsigned short tokType
+	UnionToken(const tokType tkType
         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
     ~UnionToken();
 

Modified: xerces/c/trunk/tests/src/DOM/DOMTest/DTest.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/DOM/DOMTest/DTest.cpp?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/DOM/DOMTest/DTest.cpp (original)
+++ xerces/c/trunk/tests/src/DOM/DOMTest/DTest.cpp Tue Aug 28 07:18:18 2007
@@ -897,6 +897,7 @@
          OK = test.testText(d);
          OK = test.testDOMerrors(d);
          OK = test.testXPath(d);
+         OK = test.testRegex();
 
          // Null out the static object references in class DOMTest,
          // which will recover their storage.
@@ -5010,4 +5011,182 @@
     return answer;
 }
 
+#define TEST_VALID_REGEX(str, regex, line) \
+    try \
+    { \
+        RegularExpression p(regex); \
+        if(!p.matches(str)) \
+        { \
+            fprintf(stderr, "Regular expression test failed at line %i\n", line); \
+            OK = false; \
+        } \
+    }   \
+    catch(XMLException& ) \
+    {   \
+        fprintf(stderr, "Regular expression test failed at line %i\n", line); \
+        OK = false; \
+    }
+
+#define TEST_INVALID_REGEX(str, regex, line) \
+    try \
+    { \
+        RegularExpression p(regex); \
+        if(p.matches(str)) \
+        { \
+            fprintf(stderr, "Regular expression test failed at line %i\n", line); \
+            OK = false; \
+        } \
+    }   \
+    catch(XMLException& ) \
+    {   \
+        fprintf(stderr, "Regular expression test failed at line %i\n", line); \
+        OK = false; \
+    }
 
+#define TEST_VALID_SCHEMA_REGEX(str, regex, line) \
+    try \
+    { \
+        RegularExpression p(regex, "X"); \
+        if(!p.matches(str)) \
+        { \
+            fprintf(stderr, "Regular expression test failed at line %i\n", line); \
+            OK = false; \
+        } \
+    }   \
+    catch(XMLException& ) \
+    {   \
+        fprintf(stderr, "Regular expression test failed at line %i\n", line); \
+        OK = false; \
+    }
+
+#define TEST_INVALID_SCHEMA_REGEX(str, regex, line) \
+    try \
+    { \
+        RegularExpression p(regex, "X"); \
+        if(p.matches(str)) \
+        { \
+            fprintf(stderr, "Regular expression test failed at line %i\n", line); \
+            OK = false; \
+        } \
+    }   \
+    catch(XMLException& ) \
+    {   \
+        fprintf(stderr, "Regular expression test failed at line %i\n", line); \
+        OK = false; \
+    }
+
+#define HUGE_STRING (100*1024)  // 100Kb
+
+bool DOMTest::testRegex() {
+    bool OK = true;
+
+    char* hugeString=new char[HUGE_STRING+1];
+    for(int i=0;i<HUGE_STRING;i++)
+        hugeString[i]='A';
+    hugeString[HUGE_STRING]=0;
+    TEST_VALID_REGEX(hugeString, "([A-F0-9]{2})*", __LINE__);
+
+    TEST_VALID_REGEX("12_END", "[12]{2}_END", __LINE__);
+    TEST_INVALID_REGEX("12", "[12]{2}_END", __LINE__);
+
+    TEST_VALID_REGEX("AE", "(A|B*|C)E", __LINE__);
+    TEST_VALID_REGEX("E", "(A|B*|C)E", __LINE__);
+    TEST_VALID_REGEX("BBBBBBBBBBBBBE", "(A|B*|C)E", __LINE__);
+    TEST_VALID_REGEX("CE", "(A|B*|C)E", __LINE__);
+    TEST_INVALID_REGEX("A", "(A|B*|C)E", __LINE__);
+    TEST_INVALID_REGEX("", "(A|B*|C)E", __LINE__);
+    TEST_INVALID_REGEX("BBBBBBBBBBBBB", "(A|B*|C)E", __LINE__);
+    TEST_INVALID_REGEX("C", "(A|B*|C)E", __LINE__);
+
+    // this tests the closures that need fOffset in the context
+    for(int i=0;i<HUGE_STRING-1;i++)
+        hugeString[i]=i%2?'B':'C';
+    hugeString[HUGE_STRING-1]='E';
+    // we run out of stack space when testing this one
+    //TEST_VALID_REGEX(hugeString, "(B?C?)*E", __LINE__);
+    TEST_VALID_REGEX("BBBBE", "(B?C?)*E", __LINE__);
+    TEST_VALID_REGEX("E", "(B?C?)*E", __LINE__);
+    TEST_VALID_REGEX("CCCCCCCE", "(B?C?)*E", __LINE__);
+    TEST_VALID_REGEX("BCBCBBBBCCCCCE", "(B?C?)*E", __LINE__);
+
+    TEST_VALID_REGEX(" C", "[\\s]*[\\S]+[\\s\\S]*", __LINE__);
+    TEST_VALID_REGEX("C asasaskja ksakj", "[\\s]*[\\S]+[\\s\\S]*", __LINE__);
+    TEST_VALID_REGEX(" C", "[\\s]*[\\S]+[\\s\\S]*", __LINE__);
+    TEST_INVALID_REGEX("\t         ", "[\\s]*[\\S]+[\\S]*", __LINE__);
+
+    TEST_VALID_REGEX("U2VsZWN0IFRoaXMgaXMgZmlmdGg7DQogDQpOT1RFOiBUaGUgaW5mb3JtYXRpb24gY29udGFpbmVk\n"
+                     "IGluIHRoaXMgZW1haWwgbWVzc2FnZSBpcyBjb25zaWRlcmVkIGNvbmZpZGVudGlhbCBhbmQgcHJv\n"
+                     "cHJpZXRhcnkgdG8gdGhlIHNlbmRlciBhbmQgaXMgaW50ZW5kZWQgc29sZWx5IGZvciByZXZpZXcg\n"
+                     "YW5kIHVzZSBieSB0aGUgbmFtZWQgcmVjaXBpZW50LiAgQW55IHVuYXV0aG9yaXplZCByZXZpZXcs\n"
+                     "IHVzZSBvciBkaXN0cmlidXRpb24gaXMgc3RyaWN0bHkgcHJvaGliaXRlZC4gSWYgeW91IGhhdmUg\n"
+                     "cmVjZWl2ZWQgdGhpcyBtZXNzYWdlIGluIGVycm9yLCBwbGVhc2UgYWR2aXNlIHRoZSBzZW5kZXIg\n"
+                     "YnkgcmVwbHkgZW1haWwgYW5kIGRlbGV0ZSB0aGUgbWVzc2FnZS4NCg==\n", "(^(([A-Za-z0-9+/=]){4}){1,19}$)*", __LINE__);
+
+    // examples from XMLSchema specs
+    TEST_VALID_SCHEMA_REGEX("123 456", "123 (\\d+\\s)*456", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("123 987 456", "123 (\\d+\\s)*456", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("123 987 567 456", "123 (\\d+\\s)*456", __LINE__);
+    
+    TEST_VALID_SCHEMA_REGEX("P0100Y02M", "P\\p{Nd}{4}Y\\p{Nd}{2}M", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("en-US", "[a-zA-Z]{1,8}(-[a-zA-Z0-9]{1,8})*", __LINE__);
+
+    TEST_VALID_SCHEMA_REGEX("123-XX", "\\d{3}-[A-Z]{2}", __LINE__);
+    
+    TEST_VALID_SCHEMA_REGEX("01803", "[0-9]{5}(-[0-9]{4})?", __LINE__);
+    
+    TEST_VALID_SCHEMA_REGEX("_id1", "\\i\\c*", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX("0id", "\\i\\c*", __LINE__);
+
+    TEST_VALID_SCHEMA_REGEX("hello", "[\\i-[:]][\\c-[:]]*", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX("0qq", "[\\i-[:]][\\c-[:]]*", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX("ns:localname", "[\\i-[:]][\\c-[:]]*", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX("ns:", "[\\i-[:]][\\c-[:]]*", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX(":qq", "[\\i-[:]][\\c-[:]]*", __LINE__);
+    
+    TEST_VALID_SCHEMA_REGEX("900", "[\\-+]?[0-9]+", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("-900", "[\\-+]?[0-9]+", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("+900", "[\\-+]?[0-9]+", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX("+", "[\\-+]?[0-9]+", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX("-", "[\\-+]?[0-9]+", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX("0.4", "[\\-+]?[0-9]+", __LINE__);
+
+    TEST_VALID_SCHEMA_REGEX("ABCDEFGHIJKLMNOPQRSTUVWXYZ", "A.*Z", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX("Z", "A.*Z", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX("A", "A.*Z", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX("ABC", "A.*Z", __LINE__);
+
+    // tests from the XMLSchema Test Suite
+    TEST_VALID_SCHEMA_REGEX("Chapter b", "Chapter\\s{0,2}\\w", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("Chapter\tb", "Chapter\\s{0,2}\\w", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("Chapter\nb", "Chapter\\s{0,2}\\w", __LINE__);
+    
+    TEST_VALID_SCHEMA_REGEX("abx", "(a|b)+x", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("bax", "(a|b)+x", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("bbx", "(a|b)+x", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("aaax", "(a|b)+x", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("abax", "(a|b)+x", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("abbx", "(a|b)+x", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("bbax", "(a|b)+x", __LINE__);
+    
+    TEST_VALID_SCHEMA_REGEX("1x2abc", ".*abc.*", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("abc1x2", ".*abc.*", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("z3455abch00ray", ".*abc.*", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("bcabcabcab", ".*abc.*", __LINE__);
+
+    TEST_VALID_SCHEMA_REGEX("abbbx", "ab{2,4}x", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("abbbbx", "ab{2,4}x", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX("abx", "ab{2,4}x", __LINE__);
+    TEST_INVALID_SCHEMA_REGEX("abbbbbx", "ab{2,4}x", __LINE__);
+    
+    TEST_VALID_SCHEMA_REGEX("5 Bedford Street Boston , MA 15604-1536", "\\d{1,5}\\s([A-Z][a-z]{1,20}\\s){1}Street\\s([A-Z][a-z]{1,20}\\s){1},\\s[A-Z]{2}\\s15604-1536", __LINE__);
+    
+    // from X3D schema
+    TEST_VALID_SCHEMA_REGEX("0.5 0.2 1.0", "((((\\.[0-9]+|0(\\.[0-9]*)?)((E|e)(\\+|\\-)?[0-9]+)?)|(1(\\.[0]*)?((E|e)\\-[0-9]+)?)|([1-9](\\.[0-9]*)((E|e)\\-[0-9]+))) (((\\.[0-9]+|0(\\.[0-9]*)?)((E|e)(\\+|\\-)?[0-9]+)?)|(1(\\.[0]*)?((E|e)\\-[0-9]+)?)|([1-9](\\.[0-9]*)((E|e)\\-[0-9]+))) (((\\.[0-9]+|0(\\.[0-9]*)?)((E|e)(\\+|\\-)?[0-9]+)?)|(1(\\.[0]*)?((E|e)\\-[0-9]+)?)|([1-9](\\.[0-9]*)((E|e)\\-[0-9]+))))?", __LINE__);
+    TEST_VALID_SCHEMA_REGEX("5.0e-2 .2 1", "((((\\.[0-9]+|0(\\.[0-9]*)?)((E|e)(\\+|\\-)?[0-9]+)?)|(1(\\.[0]*)?((E|e)\\-[0-9]+)?)|([1-9](\\.[0-9]*)((E|e)\\-[0-9]+))) (((\\.[0-9]+|0(\\.[0-9]*)?)((E|e)(\\+|\\-)?[0-9]+)?)|(1(\\.[0]*)?((E|e)\\-[0-9]+)?)|([1-9](\\.[0-9]*)((E|e)\\-[0-9]+))) (((\\.[0-9]+|0(\\.[0-9]*)?)((E|e)(\\+|\\-)?[0-9]+)?)|(1(\\.[0]*)?((E|e)\\-[0-9]+)?)|([1-9](\\.[0-9]*)((E|e)\\-[0-9]+))))?", __LINE__);
+
+    TEST_VALID_SCHEMA_REGEX("-0 +3989 -90.76754,+9E77, -0.3e+9", "(((\\+|\\-)?(0|[1-9][0-9]*)?(\\.[0-9]*)?((E|e)(\\+|\\-)?[0-9]+)?)?( )?(,)?( )?)*", __FILE__);
+
+    delete hugeString;
+
+    return OK;
+}

Modified: xerces/c/trunk/tests/src/DOM/DOMTest/DTest.h
URL: http://svn.apache.org/viewvc/xerces/c/trunk/tests/src/DOM/DOMTest/DTest.h?rev=570441&r1=570440&r2=570441&view=diff
==============================================================================
--- xerces/c/trunk/tests/src/DOM/DOMTest/DTest.h (original)
+++ xerces/c/trunk/tests/src/DOM/DOMTest/DTest.h Tue Aug 28 07:18:18 2007
@@ -109,6 +109,7 @@
 bool testWholeText(XercesDOMParser* parser);
 bool testLSExceptions();
 
+bool testRegex();
 };
 
 class myUserDataHandler : public DOMUserDataHandler {



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