You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by "mark hermann (JIRA)" <xe...@xml.apache.org> on 2009/05/15 16:24:45 UTC
[jira] Created: (XERCESC-1870) Xerces 2.8.0 and 3.0.1: Bug in
RegularExpression::matches(txt, pMatch)
Xerces 2.8.0 and 3.0.1: Bug in RegularExpression::matches(txt, pMatch)
----------------------------------------------------------------------
Key: XERCESC-1870
URL: https://issues.apache.org/jira/browse/XERCESC-1870
Project: Xerces-C++
Issue Type: Bug
Components: Utilities
Affects Versions: 2.8.0, 3.0.1
Environment: Platform Windows XP
MSVC 7.1, 8.0, 9.0
Reporter: mark hermann
Fix For: 2.7.0
RegularExpression::matches(txt, pMatch) does not work anymore in 2.8, 3.0.1
since pMatch is not updated correctly anymore.
// Test code - works with 2.7.0
XMLCh * txt = L"2004-06-17";
Match m;
RegularExpression r("(\\-?\\d+(\\-\\d{2}(\\-\\d{2})?)?)?(T\\d{2}(:\\d{2}(:\\d{2}(:\\d+)?)?)?)?(F\\d+)?((\\-|\\+)\\d{2}:\\d{2})?");
if(r.matches(txt, &m))
{
for(int i = 1; i < m.getNoGroups(); i++)
{
int i1 = m.getStartPos(i); // Should be 0
int i2 = Mp7JrsUtil::GetNextEndPos(m, i); // Should be 4
if(i1 == i2) // Is -1
{
printf("This is wrong!\n");
return;
}
}
}
Problem can be tracked via
bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
, const XMLSize_t end, Match* const pMatch
, MemoryManager* const manager) const;
which does
Match* lMatch = pMatch; // use our pMatch
context.fMatch = lMatch; // put pMatch into context
/*
* Straightforward matching
*/
for (matchStart=context.fStart; matchStart<=limit; matchStart++) {
if (0 <= (matchEnd = match(&context,fOperations,matchStart)))
break;
}
and at the end updates the context fMatch data
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
}
return true;
}
But: context.fMatch is NOT the original match pointer (pMatch), but a temporal one.
So the correct result is not propagated back to the caller anymore.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[jira] Resolved: (XERCESC-1870) Xerces 2.8.0 and 3.0.1: Bug in
RegularExpression::matches(txt, pMatch)
Posted by "Alberto Massari (JIRA)" <xe...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XERCESC-1870?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Alberto Massari resolved XERCESC-1870.
--------------------------------------
Resolution: Fixed
Fix Version/s: (was: 2.7.0)
3.1.0
Assignee: Alberto Massari
I fixed it in a different way, avoid creating temporary objects during the evaluation of the regex
> Xerces 2.8.0 and 3.0.1: Bug in RegularExpression::matches(txt, pMatch)
> ----------------------------------------------------------------------
>
> Key: XERCESC-1870
> URL: https://issues.apache.org/jira/browse/XERCESC-1870
> Project: Xerces-C++
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.8.0, 3.0.1
> Environment: Platform Windows XP
> MSVC 7.1, 8.0, 9.0
> Reporter: mark hermann
> Assignee: Alberto Massari
> Fix For: 3.1.0
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> RegularExpression::matches(txt, pMatch) does not work in 2.8, 3.0.1
> since pMatch is not updated correctly anymore.
> // Test code - works with 2.7.0
> XMLCh * txt = L"2004-06-17";
> Match m;
> RegularExpression r("(\\-?\\d+(\\-\\d{2}(\\-\\d{2})?)?)?(T\\d{2}(:\\d{2}(:\\d{2}(:\\d+)?)?)?)?(F\\d+)?((\\-|\\+)\\d{2}:\\d{2})?");
> if(r.matches(txt, &m))
> {
> for(int i = 1; i < m.getNoGroups(); i++)
> {
> int i1 = m.getStartPos(i); // Should be 0
>
> if(i1 < 0) // Is -1
> {
> printf("This is wrong!\n");
> return;
> }
> }
> }
> Problem can be tracked via
> bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
> , const XMLSize_t end, Match* const pMatch
> , MemoryManager* const manager) const;
> which does
> Match* lMatch = pMatch; // use our pMatch
> context.fMatch = lMatch; // put pMatch into context
> /*
> * Straightforward matching
> */
> for (matchStart=context.fStart; matchStart<=limit; matchStart++) {
> if (0 <= (matchEnd = match(&context,fOperations,matchStart)))
> break;
> }
>
> and at the end updates the context fMatch data
> if (matchEnd >= 0) {
> if (context.fMatch != 0) {
> context.fMatch->setStartPos(0, (int)matchStart);
> context.fMatch->setEndPos(0, matchEnd);
> }
> return true;
> }
> But: context.fMatch is NOT the original match pointer (pMatch), but a temporal one.
> So the correct result is not propagated back to the caller anymore.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[jira] Issue Comment Edited: (XERCESC-1870) Xerces 2.8.0 and 3.0.1:
Bug in RegularExpression::matches(txt, pMatch)
Posted by "mark hermann (JIRA)" <xe...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XERCESC-1870?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12725999#action_12725999 ]
mark hermann edited comment on XERCESC-1870 at 7/2/09 7:43 AM:
---------------------------------------------------------------
A simple fix seems to be:
in method
bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
, const XMLSize_t end, Match* const pMatch
, MemoryManager* const manager) const
at the very end of method body
add lines of code
<Orginal-Buggy>
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
}
return true;
}
</Original-Buggy>
<Fixed>
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
////////////////////////////////////////////////////////////////////// Added code
lMatch = context.fMatch;
if(pMatch != 0 && pMatch != lMatch){
for(int i = 0; i < pMatch->getNoGroups(); ++i){
int p = lMatch->getStartPos(i);
pMatch->setStartPos(i, p);
p = lMatch->getEndPos(i);
pMatch->setEndPos(i, p);
}
}
////////////////////////////////////////////////////////////////////// End of added code
}
return true;
}
</Fixed>
was (Author: marher):
A simple fix seems to be:
in method
bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
, const XMLSize_t end, Match* const pMatch
, MemoryManager* const manager) const
at the very end of method body
add lines of code
<Orginal-Buggy>
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
}
return true;
}
</Original-Buggy>
<Fixed>
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
////////////////////////////////////////////////////////////////////// Added code
lMatch = context.fMatch;
if(pMatch != 0 && pMatch != lMatch){
for(int i = 1; i < pMatch->getNoGroups(); ++i){
int p = lMatch->getStartPos(i);
pMatch->setStartPos(i, p);
p = lMatch->getEndPos(i);
pMatch->setEndPos(i, p);
}
}
////////////////////////////////////////////////////////////////////// End of added code
}
return true;
}
</Fixed>
> Xerces 2.8.0 and 3.0.1: Bug in RegularExpression::matches(txt, pMatch)
> ----------------------------------------------------------------------
>
> Key: XERCESC-1870
> URL: https://issues.apache.org/jira/browse/XERCESC-1870
> Project: Xerces-C++
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.8.0, 3.0.1
> Environment: Platform Windows XP
> MSVC 7.1, 8.0, 9.0
> Reporter: mark hermann
> Fix For: 2.7.0
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> RegularExpression::matches(txt, pMatch) does not work in 2.8, 3.0.1
> since pMatch is not updated correctly anymore.
> // Test code - works with 2.7.0
> XMLCh * txt = L"2004-06-17";
> Match m;
> RegularExpression r("(\\-?\\d+(\\-\\d{2}(\\-\\d{2})?)?)?(T\\d{2}(:\\d{2}(:\\d{2}(:\\d+)?)?)?)?(F\\d+)?((\\-|\\+)\\d{2}:\\d{2})?");
> if(r.matches(txt, &m))
> {
> for(int i = 1; i < m.getNoGroups(); i++)
> {
> int i1 = m.getStartPos(i); // Should be 0
>
> if(i1 < 0) // Is -1
> {
> printf("This is wrong!\n");
> return;
> }
> }
> }
> Problem can be tracked via
> bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
> , const XMLSize_t end, Match* const pMatch
> , MemoryManager* const manager) const;
> which does
> Match* lMatch = pMatch; // use our pMatch
> context.fMatch = lMatch; // put pMatch into context
> /*
> * Straightforward matching
> */
> for (matchStart=context.fStart; matchStart<=limit; matchStart++) {
> if (0 <= (matchEnd = match(&context,fOperations,matchStart)))
> break;
> }
>
> and at the end updates the context fMatch data
> if (matchEnd >= 0) {
> if (context.fMatch != 0) {
> context.fMatch->setStartPos(0, (int)matchStart);
> context.fMatch->setEndPos(0, matchEnd);
> }
> return true;
> }
> But: context.fMatch is NOT the original match pointer (pMatch), but a temporal one.
> So the correct result is not propagated back to the caller anymore.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[jira] Updated: (XERCESC-1870) Xerces 2.8.0 and 3.0.1: Bug in
RegularExpression::matches(txt, pMatch)
Posted by "mark hermann (JIRA)" <xe...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XERCESC-1870?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
mark hermann updated XERCESC-1870:
----------------------------------
Description:
RegularExpression::matches(txt, pMatch) does not work in 2.8, 3.0.1
since pMatch is not updated correctly anymore.
// Test code - works with 2.7.0
XMLCh * txt = L"2004-06-17";
Match m;
RegularExpression r("(\\-?\\d+(\\-\\d{2}(\\-\\d{2})?)?)?(T\\d{2}(:\\d{2}(:\\d{2}(:\\d+)?)?)?)?(F\\d+)?((\\-|\\+)\\d{2}:\\d{2})?");
if(r.matches(txt, &m))
{
for(int i = 1; i < m.getNoGroups(); i++)
{
int i1 = m.getStartPos(i); // Should be 0
if(i1 < 0) // Is -1
{
printf("This is wrong!\n");
return;
}
}
}
Problem can be tracked via
bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
, const XMLSize_t end, Match* const pMatch
, MemoryManager* const manager) const;
which does
Match* lMatch = pMatch; // use our pMatch
context.fMatch = lMatch; // put pMatch into context
/*
* Straightforward matching
*/
for (matchStart=context.fStart; matchStart<=limit; matchStart++) {
if (0 <= (matchEnd = match(&context,fOperations,matchStart)))
break;
}
and at the end updates the context fMatch data
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
}
return true;
}
But: context.fMatch is NOT the original match pointer (pMatch), but a temporal one.
So the correct result is not propagated back to the caller anymore.
was:
RegularExpression::matches(txt, pMatch) does not work anymore in 2.8, 3.0.1
since pMatch is not updated correctly anymore.
// Test code - works with 2.7.0
XMLCh * txt = L"2004-06-17";
Match m;
RegularExpression r("(\\-?\\d+(\\-\\d{2}(\\-\\d{2})?)?)?(T\\d{2}(:\\d{2}(:\\d{2}(:\\d+)?)?)?)?(F\\d+)?((\\-|\\+)\\d{2}:\\d{2})?");
if(r.matches(txt, &m))
{
for(int i = 1; i < m.getNoGroups(); i++)
{
int i1 = m.getStartPos(i); // Should be 0
if(i1 < 0) // Is -1
{
printf("This is wrong!\n");
return;
}
}
}
Problem can be tracked via
bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
, const XMLSize_t end, Match* const pMatch
, MemoryManager* const manager) const;
which does
Match* lMatch = pMatch; // use our pMatch
context.fMatch = lMatch; // put pMatch into context
/*
* Straightforward matching
*/
for (matchStart=context.fStart; matchStart<=limit; matchStart++) {
if (0 <= (matchEnd = match(&context,fOperations,matchStart)))
break;
}
and at the end updates the context fMatch data
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
}
return true;
}
But: context.fMatch is NOT the original match pointer (pMatch), but a temporal one.
So the correct result is not propagated back to the caller anymore.
> Xerces 2.8.0 and 3.0.1: Bug in RegularExpression::matches(txt, pMatch)
> ----------------------------------------------------------------------
>
> Key: XERCESC-1870
> URL: https://issues.apache.org/jira/browse/XERCESC-1870
> Project: Xerces-C++
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.8.0, 3.0.1
> Environment: Platform Windows XP
> MSVC 7.1, 8.0, 9.0
> Reporter: mark hermann
> Fix For: 2.7.0
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> RegularExpression::matches(txt, pMatch) does not work in 2.8, 3.0.1
> since pMatch is not updated correctly anymore.
> // Test code - works with 2.7.0
> XMLCh * txt = L"2004-06-17";
> Match m;
> RegularExpression r("(\\-?\\d+(\\-\\d{2}(\\-\\d{2})?)?)?(T\\d{2}(:\\d{2}(:\\d{2}(:\\d+)?)?)?)?(F\\d+)?((\\-|\\+)\\d{2}:\\d{2})?");
> if(r.matches(txt, &m))
> {
> for(int i = 1; i < m.getNoGroups(); i++)
> {
> int i1 = m.getStartPos(i); // Should be 0
>
> if(i1 < 0) // Is -1
> {
> printf("This is wrong!\n");
> return;
> }
> }
> }
> Problem can be tracked via
> bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
> , const XMLSize_t end, Match* const pMatch
> , MemoryManager* const manager) const;
> which does
> Match* lMatch = pMatch; // use our pMatch
> context.fMatch = lMatch; // put pMatch into context
> /*
> * Straightforward matching
> */
> for (matchStart=context.fStart; matchStart<=limit; matchStart++) {
> if (0 <= (matchEnd = match(&context,fOperations,matchStart)))
> break;
> }
>
> and at the end updates the context fMatch data
> if (matchEnd >= 0) {
> if (context.fMatch != 0) {
> context.fMatch->setStartPos(0, (int)matchStart);
> context.fMatch->setEndPos(0, matchEnd);
> }
> return true;
> }
> But: context.fMatch is NOT the original match pointer (pMatch), but a temporal one.
> So the correct result is not propagated back to the caller anymore.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[jira] Updated: (XERCESC-1870) Xerces 2.8.0 and 3.0.1: Bug in
RegularExpression::matches(txt, pMatch)
Posted by "mark hermann (JIRA)" <xe...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XERCESC-1870?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
mark hermann updated XERCESC-1870:
----------------------------------
Description:
RegularExpression::matches(txt, pMatch) does not work anymore in 2.8, 3.0.1
since pMatch is not updated correctly anymore.
// Test code - works with 2.7.0
XMLCh * txt = L"2004-06-17";
Match m;
RegularExpression r("(\\-?\\d+(\\-\\d{2}(\\-\\d{2})?)?)?(T\\d{2}(:\\d{2}(:\\d{2}(:\\d+)?)?)?)?(F\\d+)?((\\-|\\+)\\d{2}:\\d{2})?");
if(r.matches(txt, &m))
{
for(int i = 1; i < m.getNoGroups(); i++)
{
int i1 = m.getStartPos(i); // Should be 0
if(i1 < 0) // Is -1
{
printf("This is wrong!\n");
return;
}
}
}
Problem can be tracked via
bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
, const XMLSize_t end, Match* const pMatch
, MemoryManager* const manager) const;
which does
Match* lMatch = pMatch; // use our pMatch
context.fMatch = lMatch; // put pMatch into context
/*
* Straightforward matching
*/
for (matchStart=context.fStart; matchStart<=limit; matchStart++) {
if (0 <= (matchEnd = match(&context,fOperations,matchStart)))
break;
}
and at the end updates the context fMatch data
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
}
return true;
}
But: context.fMatch is NOT the original match pointer (pMatch), but a temporal one.
So the correct result is not propagated back to the caller anymore.
was:
RegularExpression::matches(txt, pMatch) does not work anymore in 2.8, 3.0.1
since pMatch is not updated correctly anymore.
// Test code - works with 2.7.0
XMLCh * txt = L"2004-06-17";
Match m;
RegularExpression r("(\\-?\\d+(\\-\\d{2}(\\-\\d{2})?)?)?(T\\d{2}(:\\d{2}(:\\d{2}(:\\d+)?)?)?)?(F\\d+)?((\\-|\\+)\\d{2}:\\d{2})?");
if(r.matches(txt, &m))
{
for(int i = 1; i < m.getNoGroups(); i++)
{
int i1 = m.getStartPos(i); // Should be 0
int i2 = Mp7JrsUtil::GetNextEndPos(m, i); // Should be 4
if(i1 == i2) // Is -1
{
printf("This is wrong!\n");
return;
}
}
}
Problem can be tracked via
bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
, const XMLSize_t end, Match* const pMatch
, MemoryManager* const manager) const;
which does
Match* lMatch = pMatch; // use our pMatch
context.fMatch = lMatch; // put pMatch into context
/*
* Straightforward matching
*/
for (matchStart=context.fStart; matchStart<=limit; matchStart++) {
if (0 <= (matchEnd = match(&context,fOperations,matchStart)))
break;
}
and at the end updates the context fMatch data
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
}
return true;
}
But: context.fMatch is NOT the original match pointer (pMatch), but a temporal one.
So the correct result is not propagated back to the caller anymore.
> Xerces 2.8.0 and 3.0.1: Bug in RegularExpression::matches(txt, pMatch)
> ----------------------------------------------------------------------
>
> Key: XERCESC-1870
> URL: https://issues.apache.org/jira/browse/XERCESC-1870
> Project: Xerces-C++
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.8.0, 3.0.1
> Environment: Platform Windows XP
> MSVC 7.1, 8.0, 9.0
> Reporter: mark hermann
> Fix For: 2.7.0
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> RegularExpression::matches(txt, pMatch) does not work anymore in 2.8, 3.0.1
> since pMatch is not updated correctly anymore.
> // Test code - works with 2.7.0
> XMLCh * txt = L"2004-06-17";
> Match m;
> RegularExpression r("(\\-?\\d+(\\-\\d{2}(\\-\\d{2})?)?)?(T\\d{2}(:\\d{2}(:\\d{2}(:\\d+)?)?)?)?(F\\d+)?((\\-|\\+)\\d{2}:\\d{2})?");
> if(r.matches(txt, &m))
> {
> for(int i = 1; i < m.getNoGroups(); i++)
> {
> int i1 = m.getStartPos(i); // Should be 0
>
> if(i1 < 0) // Is -1
> {
> printf("This is wrong!\n");
> return;
> }
> }
> }
> Problem can be tracked via
> bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
> , const XMLSize_t end, Match* const pMatch
> , MemoryManager* const manager) const;
> which does
> Match* lMatch = pMatch; // use our pMatch
> context.fMatch = lMatch; // put pMatch into context
> /*
> * Straightforward matching
> */
> for (matchStart=context.fStart; matchStart<=limit; matchStart++) {
> if (0 <= (matchEnd = match(&context,fOperations,matchStart)))
> break;
> }
>
> and at the end updates the context fMatch data
> if (matchEnd >= 0) {
> if (context.fMatch != 0) {
> context.fMatch->setStartPos(0, (int)matchStart);
> context.fMatch->setEndPos(0, matchEnd);
> }
> return true;
> }
> But: context.fMatch is NOT the original match pointer (pMatch), but a temporal one.
> So the correct result is not propagated back to the caller anymore.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[jira] Commented: (XERCESC-1870) Xerces 2.8.0 and 3.0.1: Bug in
RegularExpression::matches(txt, pMatch)
Posted by "mark hermann (JIRA)" <xe...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XERCESC-1870?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12725999#action_12725999 ]
mark hermann commented on XERCESC-1870:
---------------------------------------
A simple fix seems to be:
in method
bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
, const XMLSize_t end, Match* const pMatch
, MemoryManager* const manager) const
at the very end of method body
add a line of code
<Orginal-Buggy>
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
}
return true;
}
</Origina-Buggyl>
<Fixed>
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
if(pMatch != 0) *pMatch = *(context.fMatch);
}
return true;
}
</Fixed>
> Xerces 2.8.0 and 3.0.1: Bug in RegularExpression::matches(txt, pMatch)
> ----------------------------------------------------------------------
>
> Key: XERCESC-1870
> URL: https://issues.apache.org/jira/browse/XERCESC-1870
> Project: Xerces-C++
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.8.0, 3.0.1
> Environment: Platform Windows XP
> MSVC 7.1, 8.0, 9.0
> Reporter: mark hermann
> Fix For: 2.7.0
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> RegularExpression::matches(txt, pMatch) does not work in 2.8, 3.0.1
> since pMatch is not updated correctly anymore.
> // Test code - works with 2.7.0
> XMLCh * txt = L"2004-06-17";
> Match m;
> RegularExpression r("(\\-?\\d+(\\-\\d{2}(\\-\\d{2})?)?)?(T\\d{2}(:\\d{2}(:\\d{2}(:\\d+)?)?)?)?(F\\d+)?((\\-|\\+)\\d{2}:\\d{2})?");
> if(r.matches(txt, &m))
> {
> for(int i = 1; i < m.getNoGroups(); i++)
> {
> int i1 = m.getStartPos(i); // Should be 0
>
> if(i1 < 0) // Is -1
> {
> printf("This is wrong!\n");
> return;
> }
> }
> }
> Problem can be tracked via
> bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
> , const XMLSize_t end, Match* const pMatch
> , MemoryManager* const manager) const;
> which does
> Match* lMatch = pMatch; // use our pMatch
> context.fMatch = lMatch; // put pMatch into context
> /*
> * Straightforward matching
> */
> for (matchStart=context.fStart; matchStart<=limit; matchStart++) {
> if (0 <= (matchEnd = match(&context,fOperations,matchStart)))
> break;
> }
>
> and at the end updates the context fMatch data
> if (matchEnd >= 0) {
> if (context.fMatch != 0) {
> context.fMatch->setStartPos(0, (int)matchStart);
> context.fMatch->setEndPos(0, matchEnd);
> }
> return true;
> }
> But: context.fMatch is NOT the original match pointer (pMatch), but a temporal one.
> So the correct result is not propagated back to the caller anymore.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org
[jira] Issue Comment Edited: (XERCESC-1870) Xerces 2.8.0 and 3.0.1:
Bug in RegularExpression::matches(txt, pMatch)
Posted by "mark hermann (JIRA)" <xe...@xml.apache.org>.
[ https://issues.apache.org/jira/browse/XERCESC-1870?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12725999#action_12725999 ]
mark hermann edited comment on XERCESC-1870 at 7/2/09 7:42 AM:
---------------------------------------------------------------
A simple fix seems to be:
in method
bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
, const XMLSize_t end, Match* const pMatch
, MemoryManager* const manager) const
at the very end of method body
add lines of code
<Orginal-Buggy>
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
}
return true;
}
</Original-Buggy>
<Fixed>
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
////////////////////////////////////////////////////////////////////// Added code
lMatch = context.fMatch;
if(pMatch != 0 && pMatch != lMatch){
for(int i = 1; i < pMatch->getNoGroups(); ++i){
int p = lMatch->getStartPos(i);
pMatch->setStartPos(i, p);
p = lMatch->getEndPos(i);
pMatch->setEndPos(i, p);
}
}
////////////////////////////////////////////////////////////////////// End of added code
}
return true;
}
</Fixed>
was (Author: marher):
A simple fix seems to be:
in method
bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
, const XMLSize_t end, Match* const pMatch
, MemoryManager* const manager) const
at the very end of method body
add a line of code
<Orginal-Buggy>
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
}
return true;
}
</Origina-Buggyl>
<Fixed>
if (matchEnd >= 0) {
if (context.fMatch != 0) {
context.fMatch->setStartPos(0, (int)matchStart);
context.fMatch->setEndPos(0, matchEnd);
if(pMatch != 0) *pMatch = *(context.fMatch);
}
return true;
}
</Fixed>
> Xerces 2.8.0 and 3.0.1: Bug in RegularExpression::matches(txt, pMatch)
> ----------------------------------------------------------------------
>
> Key: XERCESC-1870
> URL: https://issues.apache.org/jira/browse/XERCESC-1870
> Project: Xerces-C++
> Issue Type: Bug
> Components: Utilities
> Affects Versions: 2.8.0, 3.0.1
> Environment: Platform Windows XP
> MSVC 7.1, 8.0, 9.0
> Reporter: mark hermann
> Fix For: 2.7.0
>
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> RegularExpression::matches(txt, pMatch) does not work in 2.8, 3.0.1
> since pMatch is not updated correctly anymore.
> // Test code - works with 2.7.0
> XMLCh * txt = L"2004-06-17";
> Match m;
> RegularExpression r("(\\-?\\d+(\\-\\d{2}(\\-\\d{2})?)?)?(T\\d{2}(:\\d{2}(:\\d{2}(:\\d+)?)?)?)?(F\\d+)?((\\-|\\+)\\d{2}:\\d{2})?");
> if(r.matches(txt, &m))
> {
> for(int i = 1; i < m.getNoGroups(); i++)
> {
> int i1 = m.getStartPos(i); // Should be 0
>
> if(i1 < 0) // Is -1
> {
> printf("This is wrong!\n");
> return;
> }
> }
> }
> Problem can be tracked via
> bool RegularExpression::matches(const XMLCh* const expression, const XMLSize_t start
> , const XMLSize_t end, Match* const pMatch
> , MemoryManager* const manager) const;
> which does
> Match* lMatch = pMatch; // use our pMatch
> context.fMatch = lMatch; // put pMatch into context
> /*
> * Straightforward matching
> */
> for (matchStart=context.fStart; matchStart<=limit; matchStart++) {
> if (0 <= (matchEnd = match(&context,fOperations,matchStart)))
> break;
> }
>
> and at the end updates the context fMatch data
> if (matchEnd >= 0) {
> if (context.fMatch != 0) {
> context.fMatch->setStartPos(0, (int)matchStart);
> context.fMatch->setEndPos(0, matchEnd);
> }
> return true;
> }
> But: context.fMatch is NOT the original match pointer (pMatch), but a temporal one.
> So the correct result is not propagated back to the caller anymore.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: c-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: c-dev-help@xerces.apache.org