Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69195 - trunk/boost/wave/util
From: hartmut.kaiser_at_[hidden]
Date: 2011-02-22 20:30:14


Author: hkaiser
Date: 2011-02-22 20:30:13 EST (Tue, 22 Feb 2011)
New Revision: 69195
URL: http://svn.boost.org/trac/boost/changeset/69195

Log:
Wave: Fixed whitespace handling
Text files modified:
   trunk/boost/wave/util/cpp_macromap_utils.hpp | 50 +++++++++++++++++++++------------------
   1 files changed, 27 insertions(+), 23 deletions(-)

Modified: trunk/boost/wave/util/cpp_macromap_utils.hpp
==============================================================================
--- trunk/boost/wave/util/cpp_macromap_utils.hpp (original)
+++ trunk/boost/wave/util/cpp_macromap_utils.hpp 2011-02-22 20:30:13 EST (Tue, 22 Feb 2011)
@@ -285,7 +285,8 @@
     typename ContainerT::iterator it = replacement_list.begin();
 
         while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) {
- if (T_PLACEHOLDER != token_id(*it)) {
+ token_id id(*it);
+ if (T_PLACEHOLDER != id && T_PLACEMARKER != id) {
                 typename ContainerT::iterator next = it;
                 ++next;
                 replacement_list.erase(it);
@@ -309,7 +310,8 @@
     typename ContainerT::iterator it = rit.base();
 
         while (it != end && IS_CATEGORY(*it, WhiteSpaceTokenType)) {
- if (T_PLACEHOLDER != token_id(*it)) {
+ token_id id(*it);
+ if (T_PLACEHOLDER != id && T_PLACEMARKER != id) {
                 typename ContainerT::iterator next = it;
                 ++next;
                 replacement_list.erase(it);
@@ -324,6 +326,25 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 //
+// Tests, whether the given token sequence consists out of whitespace only
+//
+///////////////////////////////////////////////////////////////////////////////
+template <typename ContainerT>
+inline bool
+is_whitespace_only (ContainerT const &argument)
+{
+ typename ContainerT::const_iterator end = argument.end();
+ for (typename ContainerT::const_iterator it = argument.begin();
+ it != end; ++it)
+ {
+ if (!IS_CATEGORY(*it, WhiteSpaceTokenType))
+ return false;
+ }
+ return true;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
 // Remove all placeholder tokens from the given token sequence
 //
 ///////////////////////////////////////////////////////////////////////////////
@@ -339,7 +360,8 @@
     typename ContainerT::iterator it = replacement_list.begin();
 
         while (it != end) {
- if (T_PLACEHOLDER == token_id(*it)) {
+ token_id id(*it);
+ if (T_PLACEHOLDER == id || T_PLACEMARKER == id) {
                 typename ContainerT::iterator next = it;
                 ++next;
                 replacement_list.erase(it);
@@ -351,7 +373,8 @@
         }
 
     // remove all 'new' leading and trailing whitespace
- trim_replacement_list(replacement_list);
+ if (is_whitespace_only(replacement_list))
+ trim_replacement_list(replacement_list);
     }
 }
 
@@ -408,25 +431,6 @@
 }
 
 ///////////////////////////////////////////////////////////////////////////////
-//
-// Tests, whether the given token sequence consists out of whitespace only
-//
-///////////////////////////////////////////////////////////////////////////////
-template <typename ContainerT>
-inline bool
-is_whitespace_only (ContainerT const &argument)
-{
- typename ContainerT::const_iterator end = argument.end();
- for (typename ContainerT::const_iterator it = argument.begin();
- it != end; ++it)
- {
- if (!IS_CATEGORY(*it, WhiteSpaceTokenType))
- return false;
- }
- return true;
-}
-
-///////////////////////////////////////////////////////////////////////////////
 // call 'skipped_token' preprocessing hook
 template <typename ContextT>
 void call_skipped_token_hook(ContextT& ctx,


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