Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r66507 - trunk/tools/inspect
From: eric_at_[hidden]
Date: 2010-11-11 21:23:36


Author: eric_niebler
Date: 2010-11-11 21:23:34 EST (Thu, 11 Nov 2010)
New Revision: 66507
URL: http://svn.boost.org/trac/boost/changeset/66507

Log:
only check boost and src directories for use of C-style assert
Text files modified:
   trunk/tools/inspect/assert_macro_check.cpp | 27 +++++++++++++++++++--------
   trunk/tools/inspect/assert_macro_check.hpp | 1 +
   2 files changed, 20 insertions(+), 8 deletions(-)

Modified: trunk/tools/inspect/assert_macro_check.cpp
==============================================================================
--- trunk/tools/inspect/assert_macro_check.cpp (original)
+++ trunk/tools/inspect/assert_macro_check.cpp 2010-11-11 21:23:34 EST (Thu, 11 Nov 2010)
@@ -44,7 +44,11 @@
 {
   namespace inspect
   {
- assert_macro_check::assert_macro_check() : m_files_with_errors(0)
+ assert_macro_check::assert_macro_check()
+ : m_files_with_errors(0)
+ , m_from_boost_root(
+ fs::exists(fs::initial_path() / "boost") &&
+ fs::exists(fs::initial_path() / "libs"))
    {
      register_signature( ".c" );
      register_signature( ".cpp" );
@@ -60,15 +64,23 @@
       const path & full_path, // example: c:/foo/boost/filesystem/path.hpp
       const string & contents ) // contents of file to be inspected
     {
- if (contents.find( "boostinspect:" "naassert_macro" ) != string::npos) return;
+ if (contents.find( "boostinspect:" "naassert_macro" ) != string::npos)
+ return;
 
- boost::sregex_iterator cur(contents.begin(), contents.end(), assert_macro_regex), end;
+ // Check files iff (a) they are in the boost directory, or (b) they
+ // are in the src directory under libs.
+ if (m_from_boost_root) {
+ path relative( relative_to( full_path, fs::initial_path() ), fs::no_check );
+ path::const_iterator pbeg = relative.begin(), pend = relative.end();
+ if (pbeg != std::find(pbeg, pend, "boost") &&
+ !(pbeg == std::find(pbeg, pend, "libs") && pend != std::find(pbeg, pend, "src")))
+ return;
+ }
 
       long errors = 0;
-
- for( ; cur != end; ++cur /*, ++m_files_with_errors*/ )
+ boost::sregex_iterator cur(contents.begin(), contents.end(), assert_macro_regex), end;
+ for( ; cur != end; ++cur )
       {
-
         if(!(*cur)[3].matched)
         {
           string::const_iterator it = contents.begin();
@@ -89,9 +101,8 @@
             + boost::lexical_cast<string>( line_number ) );
         }
       }
- if(errors > 0) {
+ if(errors > 0)
         ++m_files_with_errors;
- }
     }
   } // namespace inspect
 } // namespace boost

Modified: trunk/tools/inspect/assert_macro_check.hpp
==============================================================================
--- trunk/tools/inspect/assert_macro_check.hpp (original)
+++ trunk/tools/inspect/assert_macro_check.hpp 2010-11-11 21:23:34 EST (Thu, 11 Nov 2010)
@@ -19,6 +19,7 @@
     class assert_macro_check : public inspector
     {
       long m_files_with_errors;
+ bool m_from_boost_root;
     public:
 
       assert_macro_check();


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