diff --git a/include/boost/regex/detail/regex_config.hpp b/include/boost/regex/detail/regex_config.hpp index af74e948..00a6c9f7 100644 --- a/include/boost/regex/detail/regex_config.hpp +++ b/include/boost/regex/detail/regex_config.hpp @@ -154,14 +154,16 @@ full list of macros and their usage. #endif // // import export options: - #ifdef _RTLDLL + #if defined(_RTLDLL) && !defined(BOOST_RE_NO_LIB) #ifdef BOOST_RE_BUILD_DLL #define BOOST_RE_IX_DECL __declspec( dllexport ) #elif !defined(BOOST_REGEX_LIBRARY_INCLUDE_HPP) && !defined(BOOST_RE_NO_LIB) #define BOOST_RE_IX_DECL __declspec( dllimport ) #endif #endif + #ifndef BOOST_RE_NO_LIB #include + #endif #include #include diff --git a/src/cregex.cpp b/src/cregex.cpp index b2ac8de3..14933d97 100644 --- a/src/cregex.cpp +++ b/src/cregex.cpp @@ -505,18 +505,18 @@ unsigned int RegEx::Length(int i)const switch(pdata->t) { 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: - 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: { std::map >::iterator pos = pdata->strings.find(i); if(pos == pdata->strings.end()) - return 0; + return (unsigned)-1; return (*pos).second.size(); } } - return 0; + return (unsigned)-1; } std::string RegEx::What(int i)const diff --git a/test/regress/tests.cpp b/test/regress/tests.cpp index 8e43a40c..f8fb438d 100644 --- a/test/regress/tests.cpp +++ b/test/regress/tests.cpp @@ -535,7 +535,8 @@ void cpp_hl_tests(RegEx& e, bool recurse = true) unsigned int j = 0; 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(); 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; 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(); cout << "RegEx::Match error in subexpression " << i << ": found [" << e.Position(i) << "," << (e.Position(i) + e.Length(i)) << "] expected [" << matches[j] << "," << matches[j+1] << "]" << endl;