|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67744 - in trunk: boost/spirit/home/support/utree/detail libs/spirit/test/support
From: admin_at_[hidden]
Date: 2011-01-06 20:09:18
Author: wash
Date: 2011-01-06 20:09:17 EST (Thu, 06 Jan 2011)
New Revision: 67744
URL: http://svn.boost.org/trac/boost/changeset/67744
Log:
Fixes for utree tags (tag method won't throw for non-strings utree types, bug
fix from peper for max-size shorts).
Text files modified:
trunk/boost/spirit/home/support/utree/detail/utree_detail2.hpp | 32 ++++++++++++++++++++++++++++----
trunk/libs/spirit/test/support/utree.cpp | 19 +++++++++++++++++++
2 files changed, 47 insertions(+), 4 deletions(-)
Modified: trunk/boost/spirit/home/support/utree/detail/utree_detail2.hpp
==============================================================================
--- trunk/boost/spirit/home/support/utree/detail/utree_detail2.hpp (original)
+++ trunk/boost/spirit/home/support/utree/detail/utree_detail2.hpp 2011-01-06 20:09:17 EST (Thu, 06 Jan 2011)
@@ -45,7 +45,7 @@
{
// warning the tag is not allowed for fast_string!!! it's only
// placed here to avoid excess padding.
- return (int(buff[small_string_size-2]) << 8) + buff[small_string_size-1];
+ return (int(buff[small_string_size-2]) << 8) + (unsigned char)buff[small_string_size-1];
}
inline void fast_string::tag(short tag)
@@ -1328,30 +1328,39 @@
break;
case type::invalid_type:
case type::nil_type:
+ s.tag(other.s.tag());
break;
case type::bool_type:
b = other.b;
+ s.tag(other.s.tag());
break;
case type::int_type:
i = other.i;
+ s.tag(other.s.tag());
break;
case type::double_type:
d = other.d;
+ s.tag(other.s.tag());
break;
case type::reference_type:
p = other.p;
+ s.tag(other.s.tag());
break;
case type::any_type:
v = other.v;
+ s.tag(other.s.tag());
break;
case type::range_type:
r = other.r;
+ s.tag(other.s.tag());
break;
case type::string_range_type:
sr = other.sr;
+ s.tag(other.s.tag());
break;
case type::function_type:
pf = other.pf->clone();
+ s.tag(other.s.tag());
break;
case type::string_type:
case type::symbol_type:
@@ -1444,14 +1453,29 @@
inline short utree::tag() const
{
- if (get_type() != type::list_type)
- boost::throw_exception(bad_type_exception());
+ switch (get_type())
+ {
+ case type::string_type:
+ case type::binary_type:
+ case type::symbol_type:
+ boost::throw_exception(bad_type_exception());
+ default:
+ break;
+ }
return s.tag();
}
inline void utree::tag(short tag)
{
- ensure_list_type();
+ switch (get_type())
+ {
+ case type::string_type:
+ case type::binary_type:
+ case type::symbol_type:
+ boost::throw_exception(bad_type_exception());
+ default:
+ break;
+ }
s.tag(tag);
}
Modified: trunk/libs/spirit/test/support/utree.cpp
==============================================================================
--- trunk/libs/spirit/test/support/utree.cpp (original)
+++ trunk/libs/spirit/test/support/utree.cpp 2011-01-06 20:09:17 EST (Thu, 06 Jan 2011)
@@ -404,5 +404,24 @@
BOOST_TEST(*up.get<int*>() == 123);
}
+ // tags
+ {
+ short min = std::numeric_limits<short>::min();
+ short max = std::numeric_limits<short>::max();
+
+ utree::list_type u;
+ utree u2;
+ bool ok = true;
+
+ for (int t = min ; ok && t <= max ; ++t) {
+ u.tag(t);
+ u2 = u;
+ BOOST_TEST_EQ(t, u.tag());
+ BOOST_TEST_EQ(t, u2.tag());
+ ok = t == u.tag() && t == u2.tag();
+ u2 = utree("12");
+ }
+ }
+
return boost::report_errors();
}
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