Fixed RegEx::Length, Fixed Borland config

[SVN r9991]
This commit is contained in:
John Maddock
2001-04-28 12:03:05 +00:00
parent 19dab6c60a
commit 774c7ec4d5
3 changed files with 11 additions and 7 deletions

View File

@ -154,14 +154,16 @@ full list of macros and their usage.
#endif #endif
// //
// import export options: // import export options:
#ifdef _RTLDLL #if defined(_RTLDLL) && !defined(BOOST_RE_NO_LIB)
#ifdef BOOST_RE_BUILD_DLL #ifdef BOOST_RE_BUILD_DLL
#define BOOST_RE_IX_DECL __declspec( dllexport ) #define BOOST_RE_IX_DECL __declspec( dllexport )
#elif !defined(BOOST_REGEX_LIBRARY_INCLUDE_HPP) && !defined(BOOST_RE_NO_LIB) #elif !defined(BOOST_REGEX_LIBRARY_INCLUDE_HPP) && !defined(BOOST_RE_NO_LIB)
#define BOOST_RE_IX_DECL __declspec( dllimport ) #define BOOST_RE_IX_DECL __declspec( dllimport )
#endif #endif
#endif #endif
#ifndef BOOST_RE_NO_LIB
#include <boost/regex/detail/regex_library_include.hpp> #include <boost/regex/detail/regex_library_include.hpp>
#endif
#include <cwchar> #include <cwchar>
#include <cwctype> #include <cwctype>

View File

@ -505,18 +505,18 @@ unsigned int RegEx::Length(int i)const
switch(pdata->t) switch(pdata->t)
{ {
case re_detail::RegExData::type_pc: case re_detail::RegExData::type_pc:
return pdata->m[i].matched ? pdata->m[i].second - pdata->m[i].first : 0; return pdata->m[i].matched ? pdata->m[i].second - pdata->m[i].first : (unsigned)-1;
case re_detail::RegExData::type_pf: case re_detail::RegExData::type_pf:
return pdata->fm[i].matched ? pdata->fm[i].second - pdata->fm[i].first : 0; return pdata->fm[i].matched ? pdata->fm[i].second - pdata->fm[i].first : (unsigned)-1;
case re_detail::RegExData::type_copy: case re_detail::RegExData::type_copy:
{ {
std::map<int, std::string, std::less<int> >::iterator pos = pdata->strings.find(i); std::map<int, std::string, std::less<int> >::iterator pos = pdata->strings.find(i);
if(pos == pdata->strings.end()) if(pos == pdata->strings.end())
return 0; return (unsigned)-1;
return (*pos).second.size(); return (*pos).second.size();
} }
} }
return 0; return (unsigned)-1;
} }
std::string RegEx::What(int i)const std::string RegEx::What(int i)const

View File

@ -535,7 +535,8 @@ void cpp_hl_tests(RegEx& e, bool recurse = true)
unsigned int j = 0; unsigned int j = 0;
while(matches[j] != -2) while(matches[j] != -2)
{ {
if( (matches[j] != (int)e.Position(i)) || (matches[j+1] - matches[j] != (int)e.Length(i)) ) if( (matches[j] != (int)e.Position(i))
|| ((matches[j] != -1) && ((matches[j+1] - matches[j] != (int)e.Length(i)))) )
{ {
begin_error(); begin_error();
cout << "RegEx::Search error in subexpression " << i << ": found [" << e.Position(i) << "," << (e.Position(i) + e.Length(i)) << "] expected [" << matches[j] << "," << matches[j+1] << "]" << endl; cout << "RegEx::Search error in subexpression " << i << ": found [" << e.Position(i) << "," << (e.Position(i) + e.Length(i)) << "] expected [" << matches[j] << "," << matches[j+1] << "]" << endl;
@ -559,7 +560,8 @@ void cpp_hl_tests(RegEx& e, bool recurse = true)
unsigned int j = 0; unsigned int j = 0;
while(matches[j] != -2) while(matches[j] != -2)
{ {
if( (matches[j] != (int)e.Position(i)) || (matches[j+1] - matches[j] != (int)e.Length(i)) ) if( (matches[j] != (int)e.Position(i))
|| ((matches[j] != -1) && ((matches[j+1] - matches[j] != (int)e.Length(i)))) )
{ {
begin_error(); begin_error();
cout << "RegEx::Match error in subexpression " << i << ": found [" << e.Position(i) << "," << (e.Position(i) + e.Length(i)) << "] expected [" << matches[j] << "," << matches[j+1] << "]" << endl; cout << "RegEx::Match error in subexpression " << i << ": found [" << e.Position(i) << "," << (e.Position(i) + e.Length(i)) << "] expected [" << matches[j] << "," << matches[j+1] << "]" << endl;