Boost logo

Boost-Commit :

From: marshall_at_[hidden]
Date: 2008-05-05 23:25:42


Author: marshall
Date: 2008-05-05 23:25:41 EDT (Mon, 05 May 2008)
New Revision: 45162
URL: http://svn.boost.org/trac/boost/changeset/45162

Log:
Added new test 'ascii_check'
Added:
   trunk/tools/inspect/ascii_check.cpp (contents, props changed)
   trunk/tools/inspect/ascii_check.hpp (contents, props changed)
Text files modified:
   trunk/tools/inspect/build/Jamfile.v2 | 2 +-
   trunk/tools/inspect/inspect.cpp | 8 ++++++++
   2 files changed, 9 insertions(+), 1 deletions(-)

Added: trunk/tools/inspect/ascii_check.cpp
==============================================================================
--- (empty file)
+++ trunk/tools/inspect/ascii_check.cpp 2008-05-05 23:25:41 EDT (Mon, 05 May 2008)
@@ -0,0 +1,64 @@
+// ascii_check implementation ------------------------------------------------//
+
+// Copyright Marshall Clow 2007.
+// Based on the tab-check checker by Beman Dawes
+//
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include "ascii_check.hpp"
+#include <functional>
+
+namespace boost
+{
+ namespace inspect
+ {
+
+ static const string gPunct ( "_{}[]#()<>%:;.?*+-/ˆ&|˜!=,\\\"'" );
+
+ // Legal characters for a source file are defined in section 2.2 of the standard
+ struct non_ascii : public std::unary_function<char, bool> {
+ public:
+ non_ascii () {}
+ ~non_ascii () {}
+ bool operator () ( char c ) const
+ {
+ if ( c == ' ' ) return false;
+ if ( c >= 'a' && c <= 'z' ) return false;
+ if ( c >= 'A' && c <= 'Z' ) return false;
+ if ( c >= '0' && c <= '9' ) return false;
+ if ( c == '\t' || c == '\n' || c == '\r' || c == '\v' ) return false;
+ return gPunct.find ( c ) == string::npos;
+ }
+ };
+
+
+ ascii_check::ascii_check() : m_files_with_errors(0)
+ {
+ register_signature( ".c" );
+ register_signature( ".cpp" );
+ register_signature( ".cxx" );
+ register_signature( ".h" );
+ register_signature( ".hpp" );
+ register_signature( ".hxx" );
+ register_signature( ".ipp" );
+ }
+
+ void ascii_check::inspect(
+ const string & library_name,
+ const path & full_path, // example: c:/foo/boost/filesystem/path.hpp
+ const string & contents ) // contents of file to be inspected
+ {
+ if (contents.find( "boostinspect:" "noascii" ) != string::npos) return;
+
+ if ( std::find_if ( contents.begin (), contents.end (), non_ascii ()) != contents.end ())
+ {
+ ++m_files_with_errors;
+ error( library_name, full_path, name() );
+ }
+ }
+ } // namespace inspect
+} // namespace boost
+
+

Added: trunk/tools/inspect/ascii_check.hpp
==============================================================================
--- (empty file)
+++ trunk/tools/inspect/ascii_check.hpp 2008-05-05 23:25:41 EDT (Mon, 05 May 2008)
@@ -0,0 +1,38 @@
+// ascii_check header --------------------------------------------------------//
+
+// Copyright Marshall Clow 2007.
+// Based on the tab-check checker by Beman Dawes
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#ifndef BOOST_ASCII_CHECK_HPP
+#define BOOST_ASCII_CHECK_HPP
+
+#include "inspector.hpp"
+
+namespace boost
+{
+ namespace inspect
+ {
+ class ascii_check : public inspector
+ {
+ long m_files_with_errors;
+ public:
+
+ ascii_check();
+ virtual const char * name() const { return "*A*"; }
+ virtual const char * desc() const { return "non-ASCII chars in file"; }
+
+ virtual void inspect(
+ const std::string & library_name,
+ const path & full_path,
+ const std::string & contents );
+
+ virtual ~ascii_check()
+ { std::cout << " " << m_files_with_errors << " files with non-ASCII chars\n"; }
+ };
+ }
+}
+
+#endif // BOOST_TAB_CHECK_HPP

Modified: trunk/tools/inspect/build/Jamfile.v2
==============================================================================
--- trunk/tools/inspect/build/Jamfile.v2 (original)
+++ trunk/tools/inspect/build/Jamfile.v2 2008-05-05 23:25:41 EDT (Mon, 05 May 2008)
@@ -14,7 +14,7 @@
 
 exe inspect
     :
- inspect.cpp license_check.cpp link_check.cpp long_name_check.cpp tab_check.cpp crlf_check.cpp unnamed_namespace_check.cpp
+ inspect.cpp license_check.cpp link_check.cpp long_name_check.cpp tab_check.cpp ascii_check.cpp crlf_check.cpp unnamed_namespace_check.cpp
     copyright_check.cpp minmax_check.cpp
     /boost//filesystem/<link>static
     /boost//regex/<link>static

Modified: trunk/tools/inspect/inspect.cpp
==============================================================================
--- trunk/tools/inspect/inspect.cpp (original)
+++ trunk/tools/inspect/inspect.cpp 2008-05-05 23:25:41 EDT (Mon, 05 May 2008)
@@ -36,6 +36,7 @@
 #include "link_check.hpp"
 #include "long_name_check.hpp"
 #include "tab_check.hpp"
+#include "ascii_check.hpp"
 #include "minmax_check.hpp"
 #include "unnamed_namespace_check.hpp"
 
@@ -421,6 +422,7 @@
          " -link\n"
          " -long_name\n"
          " -tab\n"
+ " -ascii\n"
          " -minmax\n"
          " -unnamed\n"
          " default is all checks on; otherwise options specify desired checks"
@@ -581,6 +583,7 @@
   bool link_ck = true;
   bool long_name_ck = true;
   bool tab_ck = true;
+ bool ascii_ck = true;
   bool minmax_ck = true;
   bool unnamed_ck = true;
   bool cvs = false;
@@ -611,6 +614,7 @@
     link_ck = false;
     long_name_ck = false;
     tab_ck = false;
+ ascii_ck = false;
     minmax_ck = false;
     unnamed_ck = false;
   }
@@ -632,6 +636,8 @@
       long_name_ck = true;
     else if ( std::strcmp( argv[1], "-tab" ) == 0 )
       tab_ck = true;
+ else if ( std::strcmp( argv[1], "-ascii" ) == 0 )
+ ascii_ck = true;
     else if ( std::strcmp( argv[1], "-minmax" ) == 0 )
         minmax_ck = true;
     else if ( std::strcmp( argv[1], "-unnamed" ) == 0 )
@@ -671,6 +677,8 @@
     inspectors.push_back( inspector_element( new boost::inspect::file_name_check ) );
   if ( tab_ck )
       inspectors.push_back( inspector_element( new boost::inspect::tab_check ) );
+ if ( ascii_ck )
+ inspectors.push_back( inspector_element( new boost::inspect::ascii_check ) );
   if ( minmax_ck )
       inspectors.push_back( inspector_element( new boost::inspect::minmax_check ) );
   if ( unnamed_ck )


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