|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r79885 - in branches/release: . boost boost/xpressive boost/xpressive/detail/static boost/xpressive/traits boost/xpressive/traits/detail libs libs/xpressive/doc libs/xpressive/test
From: eric_at_[hidden]
Date: 2012-08-05 21:10:50
Author: eric_niebler
Date: 2012-08-05 21:10:49 EDT (Sun, 05 Aug 2012)
New Revision: 79885
URL: http://svn.boost.org/trac/boost/changeset/79885
Log:
xpressive bug fixes merged from trunk: [79726], [79732], [79761], [79763], [79765], [79766], [79789]
Added:
branches/release/libs/xpressive/test/c_traits_u.cpp
- copied unchanged from r79766, /trunk/libs/xpressive/test/c_traits_u.cpp
branches/release/libs/xpressive/test/regress_u.cpp
- copied unchanged from r79766, /trunk/libs/xpressive/test/regress_u.cpp
Properties modified:
branches/release/ (props changed)
branches/release/boost/ (props changed)
branches/release/boost/xpressive/ (props changed)
branches/release/libs/ (props changed)
Text files modified:
branches/release/boost/xpressive/detail/static/type_traits.hpp | 55 ++++++++++++++++++++++++++++++++++++++++
branches/release/boost/xpressive/detail/static/width_of.hpp | 19 -------------
branches/release/boost/xpressive/regex_actions.hpp | 34 +++++++++++++----------
branches/release/boost/xpressive/traits/cpp_regex_traits.hpp | 13 +++++++++
branches/release/boost/xpressive/traits/detail/c_ctype.hpp | 12 +++++++-
branches/release/boost/xpressive/xpressive_fwd.hpp | 2
branches/release/libs/xpressive/doc/acknowledgements.qbk | 3 ++
branches/release/libs/xpressive/test/Jamfile.v2 | 6 ++-
branches/release/libs/xpressive/test/regress.ipp | 34 ++++++++----------------
9 files changed, 117 insertions(+), 61 deletions(-)
Modified: branches/release/boost/xpressive/detail/static/type_traits.hpp
==============================================================================
--- branches/release/boost/xpressive/detail/static/type_traits.hpp (original)
+++ branches/release/boost/xpressive/detail/static/type_traits.hpp 2012-08-05 21:10:49 EDT (Sun, 05 Aug 2012)
@@ -13,6 +13,8 @@
# pragma once
#endif
+#include <string>
+#include <boost/config.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/iterator/iterator_traits.hpp>
#include <boost/type_traits/is_convertible.hpp>
@@ -55,6 +57,59 @@
{
};
+//////////////////////////////////////////////////////////////////////////
+// is_string_iterator
+//
+template<typename Iter>
+struct is_string_iterator
+ : mpl::false_
+{
+};
+
+template<>
+struct is_string_iterator<std::string::iterator>
+ : mpl::true_
+{
+};
+
+template<>
+struct is_string_iterator<std::string::const_iterator>
+ : mpl::true_
+{
+};
+
+#ifndef BOOST_NO_STD_WSTRING
+template<>
+struct is_string_iterator<std::wstring::iterator>
+ : mpl::true_
+{
+};
+
+template<>
+struct is_string_iterator<std::wstring::const_iterator>
+ : mpl::true_
+{
+};
+#endif
+
+///////////////////////////////////////////////////////////////////////////////
+// is_char
+//
+template<typename T>
+struct is_char
+ : mpl::false_
+{};
+
+template<>
+struct is_char<char>
+ : mpl::true_
+{};
+
+template<>
+struct is_char<wchar_t>
+ : mpl::true_
+{};
+
}}} // namespace boost::xpressive::detail
#endif
Modified: branches/release/boost/xpressive/detail/static/width_of.hpp
==============================================================================
--- branches/release/boost/xpressive/detail/static/width_of.hpp (original)
+++ branches/release/boost/xpressive/detail/static/width_of.hpp 2012-08-05 21:10:49 EDT (Sun, 05 Aug 2012)
@@ -23,6 +23,7 @@
#include <boost/mpl/equal_to.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/xpressive/detail/detail_fwd.hpp>
+#include <boost/xpressive/detail/static/type_traits.hpp>
#include <boost/proto/traits.hpp>
namespace boost { namespace xpressive { namespace detail
@@ -67,24 +68,6 @@
{};
///////////////////////////////////////////////////////////////////////////////
- // is_char
- //
- template<typename T>
- struct is_char
- : mpl::false_
- {};
-
- template<>
- struct is_char<char>
- : mpl::true_
- {};
-
- template<>
- struct is_char<wchar_t>
- : mpl::true_
- {};
-
- ///////////////////////////////////////////////////////////////////////////////
// width_of_terminal
//
template<typename Expr, typename Char, bool IsXpr = is_xpr<Expr>::value>
Modified: branches/release/boost/xpressive/regex_actions.hpp
==============================================================================
--- branches/release/boost/xpressive/regex_actions.hpp (original)
+++ branches/release/boost/xpressive/regex_actions.hpp 2012-08-05 21:10:49 EDT (Sun, 05 Aug 2012)
@@ -38,6 +38,7 @@
#include <boost/xpressive/detail/core/matcher/attr_begin_matcher.hpp>
#include <boost/xpressive/detail/core/matcher/predicate_matcher.hpp>
#include <boost/xpressive/detail/utility/ignore_unused.hpp>
+#include <boost/xpressive/detail/static/type_traits.hpp>
// These are very often needed by client code.
#include <boost/typeof/std/map.hpp>
@@ -571,26 +572,14 @@
: boost::lexical_cast<T>("");
}
+ #ifndef BOOST_XPRESSIVE_NO_WREGEX
T operator()(wcsub_match const &val) const
{
return val.matched
? boost::lexical_cast<T>(boost::make_iterator_range(val.first, val.second))
- : boost::lexical_cast<T>(L"");
- }
-
- T operator()(ssub_match const &val) const
- {
- return val.matched
- ? boost::lexical_cast<T>(boost::make_iterator_range(&*val.first, &*val.first + (val.second - val.first)))
: boost::lexical_cast<T>("");
}
-
- T operator()(wssub_match const &val) const
- {
- return val.matched
- ? boost::lexical_cast<T>(boost::make_iterator_range(&*val.first, &*val.first + (val.second - val.first)))
- : boost::lexical_cast<T>(L"");
- }
+ #endif
template<typename BidiIter>
T operator()(sub_match<BidiIter> const &val) const
@@ -599,10 +588,25 @@
// to some other type. Xpressive doesn't know how to do that.
typedef typename iterator_value<BidiIter>::type char_type;
BOOST_MPL_ASSERT_MSG(
- (mpl::or_<is_same<char_type, char>, is_same<char_type, wchar_t> >::value)
+ (xpressive::detail::is_char<char_type>::value)
, CAN_ONLY_CONVERT_FROM_CHARACTER_SEQUENCES
, (char_type)
);
+ return this->impl(val, xpressive::detail::is_string_iterator<BidiIter>());
+ }
+
+ private:
+ template<typename RandIter>
+ T impl(sub_match<RandIter> const &val, mpl::true_) const
+ {
+ return val.matched
+ ? boost::lexical_cast<T>(boost::make_iterator_range(&*val.first, &*val.first + (val.second - val.first)))
+ : boost::lexical_cast<T>("");
+ }
+
+ template<typename BidiIter>
+ T impl(sub_match<BidiIter> const &val, mpl::false_) const
+ {
return boost::lexical_cast<T>(val.str());
}
};
Modified: branches/release/boost/xpressive/traits/cpp_regex_traits.hpp
==============================================================================
--- branches/release/boost/xpressive/traits/cpp_regex_traits.hpp (original)
+++ branches/release/boost/xpressive/traits/cpp_regex_traits.hpp 2012-08-05 21:10:49 EDT (Sun, 05 Aug 2012)
@@ -20,6 +20,7 @@
#include <string>
#include <locale>
#include <sstream>
+#include <climits>
#include <boost/config.hpp>
#include <boost/assert.hpp>
#include <boost/integer.hpp>
@@ -122,6 +123,8 @@
umaskex_t const std_ctype_reserved = 0x8000;
#elif defined(_CPPLIB_VER) && defined(BOOST_WINDOWS)
umaskex_t const std_ctype_reserved = 0x8200;
+ #elif defined(_LIBCPP_VERSION)
+ umaskex_t const std_ctype_reserved = 0x8000;
#else
umaskex_t const std_ctype_reserved = 0;
#endif
@@ -206,6 +209,16 @@
return true;
}
+ // HACKHACK Cygwin and mingw have buggy ctype facets for wchar_t
+ #if defined(__CYGWIN__) || defined(__MINGW32_VERSION)
+ if (std::ctype_base::xdigit == ((std::ctype_base::mask)(umask_t)mask & std::ctype_base::xdigit))
+ {
+ typename std::char_traits<Char>::int_type i = std::char_traits<Char>::to_int_type(ch);
+ if(UCHAR_MAX >= i && std::isxdigit(static_cast<int>(i)))
+ return true;
+ }
+ #endif
+
#else
umaskex_t tmp = mask & ~non_std_ctype_masks;
Modified: branches/release/boost/xpressive/traits/detail/c_ctype.hpp
==============================================================================
--- branches/release/boost/xpressive/traits/detail/c_ctype.hpp (original)
+++ branches/release/boost/xpressive/traits/detail/c_ctype.hpp 2012-08-05 21:10:49 EDT (Sun, 05 Aug 2012)
@@ -496,8 +496,7 @@
static bool isctype(char ch, char_class_type mask)
{
- using namespace std;
- if(0 != __isctype(static_cast<unsigned char>(ch), mask))
+ if(glibc_isctype(ch, mask))
{
return true;
}
@@ -511,6 +510,15 @@
return false;
}
+
+ static bool glibc_isctype(char ch, char_class_type mask)
+ {
+ #ifdef __isctype
+ return 0 != __isctype(ch, mask);
+ #else
+ return 0 != ((*__ctype_b_loc())[(int)(ch)] & (unsigned short int)mask);
+ #endif
+ }
};
#ifndef BOOST_XPRESSIVE_NO_WREGEX
Modified: branches/release/boost/xpressive/xpressive_fwd.hpp
==============================================================================
--- branches/release/boost/xpressive/xpressive_fwd.hpp (original)
+++ branches/release/boost/xpressive/xpressive_fwd.hpp 2012-08-05 21:10:49 EDT (Sun, 05 Aug 2012)
@@ -31,7 +31,7 @@
# define BOOST_XPRESSIVE_USE_C_TRAITS
#endif
-#if defined(BOOST_NO_CWCHAR) | defined(BOOST_NO_CWCTYPE) | defined(BOOST_NO_STD_WSTRING)
+#if defined(BOOST_NO_CWCHAR) || defined(BOOST_NO_CWCTYPE) || defined(BOOST_NO_STD_WSTRING)
# ifndef BOOST_XPRESSIVE_NO_WREGEX
# define BOOST_XPRESSIVE_NO_WREGEX
# endif
Modified: branches/release/libs/xpressive/doc/acknowledgements.qbk
==============================================================================
--- branches/release/libs/xpressive/doc/acknowledgements.qbk (original)
+++ branches/release/libs/xpressive/doc/acknowledgements.qbk 2012-08-05 21:10:49 EDT (Sun, 05 Aug 2012)
@@ -29,6 +29,9 @@
parser example in [^libs/xpressive/example/numbers.cpp] and the documentation
for symbol tables and attributes.
+Thanks to John Fletcher for helping track down a runtime assertion when using
+xpressive with Howard Hinnant's most excellent libc++.
+
Finally, I would like to thank [@http://boost.org/people/thomas_witt.html Thomas Witt]
for acting as xpressive's review manager.
Modified: branches/release/libs/xpressive/test/Jamfile.v2
==============================================================================
--- branches/release/libs/xpressive/test/Jamfile.v2 (original)
+++ branches/release/libs/xpressive/test/Jamfile.v2 2012-08-05 21:10:49 EDT (Sun, 05 Aug 2012)
@@ -24,8 +24,10 @@
;
test-suite "xpressive"
- : [ run regress.cpp : : : <dependency>regress.txt ]
- [ run c_traits.cpp : : : <dependency>regress.txt ]
+ : [ run regress.cpp : : : <toolset>msvc:<cxxflags>/bigobj <dependency>regress.txt ]
+ [ run regress_u.cpp : : : <toolset>msvc:<cxxflags>/bigobj <dependency>regress.txt ]
+ [ run c_traits.cpp : : : <toolset>msvc:<cxxflags>/bigobj <dependency>regress.txt ]
+ [ run c_traits_u.cpp : : : <toolset>msvc:<cxxflags>/bigobj <dependency>regress.txt ]
[ run test1.cpp ]
[ run test2.cpp ]
[ run test3.cpp ]
Modified: branches/release/libs/xpressive/test/regress.ipp
==============================================================================
--- branches/release/libs/xpressive/test/regress.ipp (original)
+++ branches/release/libs/xpressive/test/regress.ipp 2012-08-05 21:10:49 EDT (Sun, 05 Aug 2012)
@@ -25,13 +25,13 @@
# include <crtdbg.h>
#endif
-#ifndef BOOST_XPRESSIVE_NO_WREGEX
+#if defined(BOOST_XPRESSIVE_TEST_WREGEX) && !defined(BOOST_XPRESSIVE_NO_WREGEX)
namespace std
{
inline std::ostream &operator <<(std::ostream &sout, std::wstring const &wstr)
{
for(std::size_t n = 0; n < wstr.size(); ++n)
- sout.put(sout.narrow(wstr[n], '?'));
+ sout.put(BOOST_USE_FACET(std::ctype<wchar_t>, std::locale()).narrow(wstr[n], '?'));
return sout;
}
}
@@ -95,7 +95,7 @@
test_case_formatter const case_ = {};
-#ifndef BOOST_XPRESSIVE_NO_WREGEX
+#if defined(BOOST_XPRESSIVE_TEST_WREGEX) && !defined(BOOST_XPRESSIVE_NO_WREGEX)
///////////////////////////////////////////////////////////////////////////////
// widen
// make a std::wstring from a std::string by widening according to the
@@ -316,7 +316,7 @@
for(std::size_t i = 0; i < br.size() && i < test.br.size(); ++i)
{
- BOOST_XPR_CHECK(!br[i].matched && test.br[i] == empty || test.br[i] == br[i].str());
+ BOOST_XPR_CHECK((!br[i].matched && test.br[i] == empty) || test.br[i] == br[i].str());
}
}
@@ -355,7 +355,7 @@
for(std::size_t i = 0; i < what.size() && i < test.br.size(); ++i)
{
- BOOST_XPR_CHECK(!what[i].matched && test.br[i] == empty || test.br[i] == what[i].str());
+ BOOST_XPR_CHECK((!what[i].matched && test.br[i] == empty) || test.br[i] == what[i].str());
}
}
else
@@ -374,31 +374,17 @@
///////////////////////////////////////////////////////////////////////////////
// run_test_impl
// run the current test
-void run_test_a()
-{
- run_test_impl(test);
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// run_test_u
-// widen the current test and run it
-void run_test_u()
+void run_test()
{
- #ifndef BOOST_XPRESSIVE_NO_WREGEX
+ #ifdef BOOST_XPRESSIVE_TEST_WREGEX
xpr_test_case<wchar_t> wtest = ::widen(test);
run_test_impl(wtest);
+ #else
+ run_test_impl(test);
#endif
}
///////////////////////////////////////////////////////////////////////////////
-// run_test
-void run_test()
-{
- run_test_a();
- run_test_u();
-}
-
-///////////////////////////////////////////////////////////////////////////////
// open_test
bool open_test()
{
@@ -425,6 +411,7 @@
// read the tests from the input file and execute them
void test_main()
{
+ #if !defined(BOOST_XPRESSIVE_TEST_WREGEX) || !defined(BOOST_XPRESSIVE_NO_WREGEX)
if(!open_test())
{
BOOST_ERROR("Error: unable to open input file.");
@@ -435,6 +422,7 @@
run_test();
++test_count;
}
+ #endif
std::cout << test_count << " tests completed." << std::endl;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk