Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57718 - in trunk: boost/spirit/home/qi/string libs/spirit/test/qi
From: daniel_james_at_[hidden]
Date: 2009-11-16 18:56:20


Author: danieljames
Date: 2009-11-16 18:56:20 EST (Mon, 16 Nov 2009)
New Revision: 57718
URL: http://svn.boost.org/trac/boost/changeset/57718

Log:
Don't match substrings in symbols::find.
Text files modified:
   trunk/boost/spirit/home/qi/string/symbols.hpp | 6 ++++--
   trunk/libs/spirit/test/qi/symbols.cpp | 17 ++++++++++++++---
   2 files changed, 18 insertions(+), 5 deletions(-)

Modified: trunk/boost/spirit/home/qi/string/symbols.hpp
==============================================================================
--- trunk/boost/spirit/home/qi/string/symbols.hpp (original)
+++ trunk/boost/spirit/home/qi/string/symbols.hpp 2009-11-16 18:56:20 EST (Mon, 16 Nov 2009)
@@ -205,13 +205,15 @@
         template <typename Iterator>
         value_type* find_impl(Iterator begin, Iterator end)
         {
- return lookup->find(begin, end, Filter());
+ value_type* r = lookup->find(begin, end, Filter());
+ return begin == end ? r : 0;
         }
 
         template <typename Iterator>
         value_type const* find_impl(Iterator begin, Iterator end) const
         {
- return lookup->find(begin, end, Filter());
+ value_type const* r = lookup->find(begin, end, Filter());
+ return begin == end ? r : 0;
         }
 
 public:

Modified: trunk/libs/spirit/test/qi/symbols.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/symbols.cpp (original)
+++ trunk/libs/spirit/test/qi/symbols.cpp 2009-11-16 18:56:20 EST (Mon, 16 Nov 2009)
@@ -304,9 +304,20 @@
         BOOST_TEST(const_sym.find("a") && *const_sym.find("a") == 1);
         BOOST_TEST(const_sym.find("b") && *const_sym.find("b") == 2);
         BOOST_TEST(const_sym.find("c") && *const_sym.find("c") == 0);
- BOOST_TEST(!const_sym.find("d"));
-
-
+ BOOST_TEST(!const_sym.find("d"));
+ }
+
+ { // Don't find substring
+
+ symbols<char, int> sym;
+ BOOST_TEST(sym.at("foo") == 0);
+ sym.at("foo") = 1;
+ BOOST_TEST(sym.at("foo") == 1);
+ BOOST_TEST(sym.at("fool") == 0);
+ sym.at("fool") = 2;
+ BOOST_TEST(sym.find("foo") && *sym.find("foo") == 1);
+ BOOST_TEST(sym.find("fool") && *sym.find("foo") == 2);
+ BOOST_TEST(!sym.find("foolish"));
     }
 
     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