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 2006/01/16 11:15:51 UTC
svn commit: r369417 - in /xerces/c/branches/xerces-2.7:
Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp
src/xercesc/util/regx/RegularExpression.cpp
src/xercesc/util/regx/RegularExpression.hpp
Author: amassari
Date: Mon Jan 16 02:15:42 2006
New Revision: 369417
URL: http://svn.apache.org/viewcvs?rev=369417&view=rev
Log:
When evaluating a union in a regular expression, take the branch that matches the longest part of the input string (jira#1521)
Modified:
xerces/c/branches/xerces-2.7/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp
xerces/c/branches/xerces-2.7/src/xercesc/util/regx/RegularExpression.cpp
xerces/c/branches/xerces-2.7/src/xercesc/util/regx/RegularExpression.hpp
Modified: xerces/c/branches/xerces-2.7/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp?rev=369417&r1=369416&r2=369417&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp (original)
+++ xerces/c/branches/xerces-2.7/Projects/Win32/VC6/xerces-all/XercesLib/XercesLib.dsp Mon Jan 16 02:15:42 2006
@@ -45,7 +45,7 @@
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /G6 /MD /Za /W3 /GX /O2 /Ob2 /I "..\..\..\..\..\src" /D "NDEBUG" /D "PLATFORM_WIN32" /D "_CRTDBG_MAP_ALLOC" /D "PROJ_XMLPARSER" /D "PROJ_XMLUTIL" /D "PROJ_PARSERS" /D "PROJ_SAX4C" /D "PROJ_SAX2" /D "PROJ_DOM" /D "PROJ_VALIDATORS" /D "XML_SINGLEDLL" /D "WIN32" /D "_WINDOWS" /D "XML_USE_WIN32_TRANSCODER" /D "XML_USE_WIN32_MSGLOADER" /D "XML_USE_NETACCESSOR_WINSOCK" /FD /c
+# ADD CPP /G6 /MD /Ze /W3 /GX /O2 /Ob2 /I "..\..\..\..\..\src" /D "NDEBUG" /D "PLATFORM_WIN32" /D "_CRTDBG_MAP_ALLOC" /D "PROJ_XMLPARSER" /D "PROJ_XMLUTIL" /D "PROJ_PARSERS" /D "PROJ_SAX4C" /D "PROJ_SAX2" /D "PROJ_DOM" /D "PROJ_VALIDATORS" /D "XML_SINGLEDLL" /D "WIN32" /D "_WINDOWS" /D "XML_USE_WIN32_TRANSCODER" /D "XML_USE_WIN32_MSGLOADER" /D "XML_USE_NETACCESSOR_WINSOCK" /FD /c
# SUBTRACT CPP /Fr
# ADD BASE MTL /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /D "NDEBUG" /mktyplib203 /o "NUL" /win32
@@ -71,7 +71,7 @@
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
-# ADD CPP /G6 /MDd /Za /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\src" /D "_CRTDBG_MAP_ALLOC" /D "PROJ_SAX2" /D "_DEBUG" /D "PROJ_XMLPARSER" /D "PROJ_XMLUTIL" /D "PROJ_PARSERS" /D "PROJ_SAX4C" /D "PROJ_DOM" /D "PROJ_VALIDATORS" /D "XML_SINGLEDLL" /D "WIN32" /D "_WINDOWS" /D "XML_USE_WIN32_TRANSCODER" /D "XML_USE_WIN32_MSGLOADER" /D "XML_USE_NETACCESSOR_WINSOCK" /FD /c
+# ADD CPP /G6 /MDd /Ze /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\src" /D "_CRTDBG_MAP_ALLOC" /D "PROJ_SAX2" /D "_DEBUG" /D "PROJ_XMLPARSER" /D "PROJ_XMLUTIL" /D "PROJ_PARSERS" /D "PROJ_SAX4C" /D "PROJ_DOM" /D "PROJ_VALIDATORS" /D "XML_SINGLEDLL" /D "WIN32" /D "_WINDOWS" /D "XML_USE_WIN32_TRANSCODER" /D "XML_USE_WIN32_MSGLOADER" /D "XML_USE_NETACCESSOR_WINSOCK" /FD /c
# SUBTRACT CPP /Fr
# ADD BASE MTL /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /D "_DEBUG" /mktyplib203 /o "NUL" /win32
@@ -99,7 +99,7 @@
# PROP Target_Dir ""
# ADD BASE CPP /G6 /MDd /Za /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\src" /D "_CRTDBG_MAP_ALLOC" /D "PROJ_SAX2" /D "_DEBUG" /D "PROJ_XMLPARSER" /D "PROJ_XMLUTIL" /D "PROJ_PARSERS" /D "PROJ_SAX4C" /D "PROJ_DOM" /D "PROJ_VALIDATORS" /D "XML_SINGLEDLL" /D "WIN32" /D "_WINDOWS" /D "XML_USE_WIN32_TRANSCODER" /D "XML_USE_WIN32_MSGLOADER" /D "XML_USE_NETACCESSOR_WINSOCK" /FD /c
# SUBTRACT BASE CPP /Fr /YX
-# ADD CPP /MDd /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\src" /D "WIN64" /D "_CRTDBG_MAP_ALLOC" /D "PROJ_SAX2" /D "_DEBUG" /D "PROJ_XMLPARSER" /D "PROJ_XMLUTIL" /D "PROJ_PARSERS" /D "PROJ_SAX4C" /D "PROJ_DOM" /D "PROJ_VALIDATORS" /D "XML_SINGLEDLL" /D "WIN32" /D "_WINDOWS" /D "XML_USE_WIN32_TRANSCODER" /D "XML_USE_WIN32_MSGLOADER" /D "XML_USE_NETACCESSOR_WINSOCK" /FD /c
+# ADD CPP /MDd /Ze /W3 /Gm /GX /Zi /Od /I "..\..\..\..\..\src" /D "WIN64" /D "_CRTDBG_MAP_ALLOC" /D "PROJ_SAX2" /D "_DEBUG" /D "PROJ_XMLPARSER" /D "PROJ_XMLUTIL" /D "PROJ_PARSERS" /D "PROJ_SAX4C" /D "PROJ_DOM" /D "PROJ_VALIDATORS" /D "XML_SINGLEDLL" /D "WIN32" /D "_WINDOWS" /D "XML_USE_WIN32_TRANSCODER" /D "XML_USE_WIN32_MSGLOADER" /D "XML_USE_NETACCESSOR_WINSOCK" /FD /c
# ADD BASE MTL /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /D "_DEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
@@ -126,7 +126,7 @@
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /G6 /MD /Za /W3 /GX /O2 /I "..\..\..\..\..\src" /D "NDEBUG" /D "PLATFORM_WIN32" /D "_CRTDBG_MAP_ALLOC" /D "PROJ_XMLPARSER" /D "PROJ_XMLUTIL" /D "PROJ_PARSERS" /D "PROJ_SAX4C" /D "PROJ_SAX2" /D "PROJ_DOM" /D "PROJ_VALIDATORS" /D "XML_SINGLEDLL" /D "WIN32" /D "_WINDOWS" /D "XML_USE_WIN32_TRANSCODER" /D "XML_USE_WIN32_MSGLOADER" /D "XML_USE_NETACCESSOR_WINSOCK" /FD /c
-# ADD CPP /MD /W3 /GX /O2 /I "..\..\..\..\..\src" /D "WIN64" /D "NDEBUG" /D "PLATFORM_WIN32" /D "_CRTDBG_MAP_ALLOC" /D "PROJ_XMLPARSER" /D "PROJ_XMLUTIL" /D "PROJ_PARSERS" /D "PROJ_SAX4C" /D "PROJ_SAX2" /D "PROJ_DOM" /D "PROJ_VALIDATORS" /D "XML_SINGLEDLL" /D "WIN32" /D "_WINDOWS" /D "XML_USE_WIN32_TRANSCODER" /D "XML_USE_WIN32_MSGLOADER" /D "XML_USE_NETACCESSOR_WINSOCK" /FD /c
+# ADD CPP /MD /Ze /W3 /GX /O2 /I "..\..\..\..\..\src" /D "WIN64" /D "NDEBUG" /D "PLATFORM_WIN32" /D "_CRTDBG_MAP_ALLOC" /D "PROJ_XMLPARSER" /D "PROJ_XMLUTIL" /D "PROJ_PARSERS" /D "PROJ_SAX4C" /D "PROJ_SAX2" /D "PROJ_DOM" /D "PROJ_VALIDATORS" /D "XML_SINGLEDLL" /D "WIN32" /D "_WINDOWS" /D "XML_USE_WIN32_TRANSCODER" /D "XML_USE_WIN32_MSGLOADER" /D "XML_USE_NETACCESSOR_WINSOCK" /FD /c
# ADD BASE MTL /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD MTL /D "NDEBUG" /mktyplib203 /o "NUL" /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
Modified: xerces/c/branches/xerces-2.7/src/xercesc/util/regx/RegularExpression.cpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/util/regx/RegularExpression.cpp?rev=369417&r1=369416&r2=369417&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/util/regx/RegularExpression.cpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/util/regx/RegularExpression.cpp Mon Jan 16 02:15:42 2006
@@ -135,6 +135,62 @@
{
}
+RegularExpression::Context::Context(Context* src) :
+ fAdoptMatch(false)
+ , fStart(src->fStart)
+ , fLimit(src->fLimit)
+ , fLength(src->fLength)
+ , fSize(src->fSize)
+ , fStringMaxLen(src->fStringMaxLen)
+ , fOffsets(0)
+ , fMatch(0)
+ , fString(src->fString)
+ , fMemoryManager(src->fMemoryManager)
+{
+ if(src->fOffsets)
+ {
+ fOffsets = (int*) fMemoryManager->allocate(fSize* sizeof(int));
+ for (int i = 0; i< fSize; i++)
+ fOffsets[i] = src->fOffsets[i];
+ }
+ if(src->fMatch)
+ {
+ fMatch=new Match(*src->fMatch);
+ fAdoptMatch=true;
+ }
+}
+
+RegularExpression::Context& RegularExpression::Context::operator= (const RegularExpression::Context& other)
+{
+ fStart=other.fStart;
+ fLimit=other.fLimit;
+ fLength=other.fLength;
+ fSize=other.fSize;
+ fStringMaxLen=other.fStringMaxLen;
+ fString=other.fString;
+ if (fOffsets)
+ fMemoryManager->deallocate(fOffsets);//delete [] fOffsets;
+ fOffsets=0;
+ if (fAdoptMatch)
+ delete fMatch;
+ fMatch=0;
+ fAdoptMatch=false;
+
+ fMemoryManager=other.fMemoryManager;
+ if(other.fOffsets)
+ {
+ fOffsets = (int*) fMemoryManager->allocate(fSize* sizeof(int));
+ for (int i = 0; i< fSize; i++)
+ fOffsets[i] = other.fOffsets[i];
+ }
+ if(other.fMatch)
+ {
+ fMatch=new Match(*other.fMatch);
+ fAdoptMatch=true;
+ }
+ return *this;
+}
+
RegularExpression::Context::~Context()
{
if (fOffsets)
@@ -1329,6 +1385,29 @@
context->fMatch->setEndPos(-index, save);
return ret;
}
+
+int RegularExpression::matchUnion(Context* const context,
+ const Op* const op, int offset,
+ const short direction)
+{
+ unsigned int opSize = op->getSize();
+
+ Context bestResultContext;
+ int bestResult=-1;
+ for(unsigned int i=0; i < opSize; i++) {
+ Context tmpContext(context);
+ int ret = match(&tmpContext, op->elementAt(i), offset, direction);
+ if (ret >= 0 && ret <= context->fLimit && ret>bestResult)
+ {
+ bestResult=ret;
+ bestResultContext=tmpContext;
+ }
+ }
+ if(bestResult!=-1)
+ *context=bestResultContext;
+ return bestResult;
+}
+
bool RegularExpression::matchCondition(Context* const context,
const Op* const op, int offset,
Modified: xerces/c/branches/xerces-2.7/src/xercesc/util/regx/RegularExpression.hpp
URL: http://svn.apache.org/viewcvs/xerces/c/branches/xerces-2.7/src/xercesc/util/regx/RegularExpression.hpp?rev=369417&r1=369416&r2=369417&view=diff
==============================================================================
--- xerces/c/branches/xerces-2.7/src/xercesc/util/regx/RegularExpression.hpp (original)
+++ xerces/c/branches/xerces-2.7/src/xercesc/util/regx/RegularExpression.hpp Mon Jan 16 02:15:42 2006
@@ -158,8 +158,10 @@
{
public :
Context(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
+ Context(Context* src);
~Context();
+ Context& operator= (const Context& other);
inline const XMLCh* getString() const { return fString; }
void reset(const XMLCh* const string, const int stringLen,
const int start, const int limit, const int noClosures);
@@ -546,24 +548,6 @@
}
return ret;
- }
-
- inline int RegularExpression::matchUnion(Context* const context,
- const Op* const op, int offset,
- const short direction)
- {
- unsigned int opSize = op->getSize();
- int ret = -1;
-
- for (unsigned int i=0; i < opSize; i++) {
-
- ret = match(context, op->elementAt(i), offset, direction);
-
- if (ret >= 0 && ret <= context->fLimit)
- return ret;
- }
-
- return -1;
}
inline int RegularExpression::matchModifier(Context* const context,
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org