Boost logo

Boost-Commit :

From: hartmut.kaiser_at_[hidden]
Date: 2008-04-27 14:28:04


Author: hkaiser
Date: 2008-04-27 14:28:04 EDT (Sun, 27 Apr 2008)
New Revision: 44823
URL: http://svn.boost.org/trac/boost/changeset/44823

Log:
Spirit.Lex: Fixed a gcc 4.3 warning
Text files modified:
   trunk/boost/spirit/home/lex/lexer/lexertl/iterator_tokenizer.hpp | 22 +++++++++++++++++-
   trunk/boost/spirit/home/support/detail/lexer/char_traits.hpp | 46 ++++++++++++++++++++++++++-------------
   2 files changed, 51 insertions(+), 17 deletions(-)

Modified: trunk/boost/spirit/home/lex/lexer/lexertl/iterator_tokenizer.hpp
==============================================================================
--- trunk/boost/spirit/home/lex/lexer/lexertl/iterator_tokenizer.hpp (original)
+++ trunk/boost/spirit/home/lex/lexer/lexertl/iterator_tokenizer.hpp 2008-04-27 14:28:04 EDT (Sun, 27 Apr 2008)
@@ -6,9 +6,11 @@
 #if !defined(BOOST_SPIRIT_LEXERTL_ITERATOR_TOKENISER_MARCH_22_2007_0859AM)
 #define BOOST_SPIRIT_LEXERTL_ITERATOR_TOKENISER_MARCH_22_2007_0859AM
 
+#include <boost/detail/iterator.hpp>
 #include <boost/spirit/home/support/detail/lexer/state_machine.hpp>
 #include <boost/spirit/home/support/detail/lexer/consts.hpp>
 #include <boost/spirit/home/support/detail/lexer/size_t.hpp>
+#include <boost/spirit/home/support/detail/lexer/char_traits.hpp>
 #include <vector>
 
 namespace boost { namespace spirit { namespace lex
@@ -124,8 +126,16 @@
                 }
                 else
                 {
+ typedef typename
+ boost::iterator_traits<Iterator>::value_type
+ value_type;
+ typedef typename
+ char_traits<value_type>::index_type
+ index_type;
+
+ index_type index = char_traits<value_type>::call(*curr_++);
                     std::size_t const state_ = ptr_[
- lookup_[static_cast<int>(*curr_++)]];
+ lookup_[static_cast<std::size_t>(index)]];
 
                     if (state_ == 0)
                     {
@@ -205,8 +215,16 @@
                 }
                 else
                 {
+ typedef typename
+ boost::iterator_traits<Iterator>::value_type
+ value_type;
+ typedef typename
+ char_traits<value_type>::index_type
+ index_type;
+
+ index_type index = char_traits<value_type>::call(*curr_++);
                     std::size_t const state_ = ptr_[
- lookup_[static_cast<int>(*curr_++)]];
+ lookup_[static_cast<std::size_t>(index)]];
 
                     if (state_ == 0)
                     {

Modified: trunk/boost/spirit/home/support/detail/lexer/char_traits.hpp
==============================================================================
--- trunk/boost/spirit/home/support/detail/lexer/char_traits.hpp (original)
+++ trunk/boost/spirit/home/support/detail/lexer/char_traits.hpp 2008-04-27 14:28:04 EDT (Sun, 27 Apr 2008)
@@ -13,23 +13,39 @@
 {
 namespace lexer
 {
-template<typename CharT>
-struct char_traits
-{
- typedef CharT index_type;
-};
+ template<typename CharT>
+ struct char_traits
+ {
+ typedef CharT index_type;
 
-template<>
-struct char_traits<char>
-{
- typedef unsigned char index_type;
-};
+ index_type call(CharT ch)
+ {
+ return ch;
+ }
+ };
+
+ template<>
+ struct char_traits<char>
+ {
+ typedef unsigned char index_type;
+
+ index_type call(char ch)
+ {
+ return static_cast<index_type>(ch);
+ }
+ };
+
+ template<>
+ struct char_traits<wchar_t>
+ {
+ typedef wchar_t index_type;
+
+ index_type call(wchar_t ch)
+ {
+ return ch;
+ }
+ };
 
-template<>
-struct char_traits<wchar_t>
-{
- typedef wchar_t index_type;
-};
 }
 }
 


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