Update of /cvsroot/boost/boost/tools/inspect
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29813
Modified Files:
copyright_check.cpp crlf_check.cpp cvs_iterator.hpp
inspect.cpp inspector.hpp license_check.cpp license_check.hpp
link_check.cpp link_check.hpp long_name_check.cpp
minmax_check.cpp tab_check.cpp
Added Files:
unnamed_namespace_check.cpp unnamed_namespace_check.hpp
Log Message:
added check for unnamed namespaces in included source files (headers); tighten
check on license text; misc cleanup
--- NEW FILE: unnamed_namespace_check.cpp ---
// unnamed_namespace_check -----------------------------------------//
// Copyright Gennaro Prota 2006.
//
// 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 "boost/regex.hpp"
#include "boost/lexical_cast.hpp"
#include "unnamed_namespace_check.hpp"
namespace
{
boost::regex unnamed_namespace_regex(
"namespace\\s(\\?\\?<|\\{)" // trigraph ??< or {
);
} // unnamed namespace (ironical? :-)
namespace boost
{
namespace inspect
{
unnamed_namespace_check::unnamed_namespace_check() : m_errors(0)
{
register_signature( ".h" );
register_signature( ".hh" ); // just in case
register_signature( ".hpp" );
register_signature( ".hxx" ); // just in case
register_signature( ".inc" );
register_signature( ".ipp" );
register_signature( ".inl" );
}
void unnamed_namespace_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:nounnamed" ) != string::npos) return;
boost::sregex_iterator cur(contents.begin(), contents.end(),
unnamed_namespace_regex), end;
for( ; cur != end; ++cur, ++m_errors )
{
std::string linenbr = boost::lexical_cast<string>(
std::count( contents.begin(), (*cur)[0].first, '\n' ) + 1);
error( library_name, full_path, string(name()) + " unnamed namespace at
line " + linenbr );
}
}
} // namespace inspect
} // namespace boost
--- NEW FILE: unnamed_namespace_check.hpp ---
// unnamed_namespace_check -----------------------------------------//
// Copyright Gennaro Prota 2006.
// 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_UNNAMED_NAMESPACE_CHECK_HPP_GP_20060718
#define BOOST_UNNAMED_NAMESPACE_CHECK_HPP_GP_20060718
#include "inspector.hpp"
namespace boost
{
namespace inspect
{
class unnamed_namespace_check : public inspector
{
long m_errors;
public:
unnamed_namespace_check();
virtual const char * name() const { return "*U*"; }
virtual const char * desc() const { return "unnamed namespace in header";
}
virtual void inspect(
const std::string & library_name,
const path & full_path,
const std::string & contents );
virtual ~unnamed_namespace_check()
{ std::cout << " " << m_errors << " usages of unnamed namespaces in
headers (included .ipp files)\n"; }
};
}
}
#endif // include guard
Index: copyright_check.cpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/inspect/copyright_check.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- copyright_check.cpp 16 Jul 2006 16:15:28 -0000 1.9
+++ copyright_check.cpp 18 Jul 2006 03:55:38 -0000 1.10
@@ -14,7 +14,7 @@
copyright_check::copyright_check() : m_files_with_errors(0)
{
}
-
+
void copyright_check::inspect(
const string & library_name,
const path & full_path, // example: c:/foo/boost/filesystem/path.hpp
Index: crlf_check.cpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/inspect/crlf_check.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- crlf_check.cpp 16 Jul 2006 16:15:28 -0000 1.8
+++ crlf_check.cpp 18 Jul 2006 03:55:38 -0000 1.9
@@ -31,7 +31,7 @@
// are commonly edited in both Windows and UNIX environments, and editors
// in those environments generally accept either ending. Even Mac people
// agreed with this policy. --Beman
-
+
// Joerg's original implementation is saved below,
// in case we change our minds!
Index: cvs_iterator.hpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/inspect/cvs_iterator.hpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cvs_iterator.hpp 20 Jul 2004 04:31:53 -0000 1.7
+++ cvs_iterator.hpp 18 Jul 2006 03:55:38 -0000 1.8
@@ -8,14 +8,15 @@
// WARNING: This is just a quick hack. It doesn't conform to C++ Standard
// Library iterator requirements.
-#include <boost/filesystem/path.hpp>
-#include <boost/filesystem/exception.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/fstream.hpp>
-#include <boost/noncopyable.hpp>
#include <string>
#include <cassert>
+#include "boost/filesystem/path.hpp"
+#include "boost/filesystem/exception.hpp"
+#include "boost/filesystem/operations.hpp"
+#include "boost/filesystem/fstream.hpp"
+#include "boost/noncopyable.hpp"
+
namespace hack
{
class cvs_iterator : boost::noncopyable
@@ -31,7 +32,7 @@
cvs_iterator( const boost::filesystem::path & dir_path ) :
dir_path(dir_path)
{
- boost::filesystem::path entries_file_path( dir_path / "CVS/Entries" );
+ boost::filesystem::path entries_file_path( dir_path / "CVS/Entries" );
entries_file.open( entries_file_path );
if ( !entries_file )
throw std::string( "could not open: " ) + entries_file_path.string();
@@ -50,8 +51,8 @@
{
std::getline( entries_file, contents );
if ( entries_file.eof() )
- {
- entries_file.close();
+ {
+ entries_file.close();
value_path = "";
return *this;
}
@@ -61,7 +62,7 @@
/ boost::filesystem::path( contents.substr( 1, contents.find( '/', 1
) ), boost::filesystem::no_check );
// in case entries file is mistaken, do until value_path actually found
- } while ( !boost::filesystem::exists( value_path ) );
+ } while ( !boost::filesystem::exists( value_path ) );
return *this;
}
Index: inspect.cpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/inspect/inspect.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- inspect.cpp 16 Jul 2006 16:15:28 -0000 1.18
+++ inspect.cpp 18 Jul 2006 03:55:38 -0000 1.19
@@ -13,13 +13,7 @@
// See http://www.boost.org/tools/inspect for more information.
-#include <boost/shared_ptr.hpp>
-#include <boost/filesystem/exception.hpp>
-#include <boost/filesystem/operations.hpp>
-#include <boost/filesystem/fstream.hpp>
-#include <boost/format.hpp>
-#include <iostream>
#include <cassert>
#include <vector>
#include <list>
@@ -27,9 +21,15 @@
#include <algorithm>
#include <cstring>
-#include "inspector.hpp" // includes <string>, <boost/filesystem/path.hpp>,
- // <iostream>, <set>
- // and gives using for string and path.
+#include <boost/shared_ptr.hpp>
+#include <boost/filesystem/exception.hpp>
+#include <boost/filesystem/operations.hpp>
+#include <boost/filesystem/fstream.hpp>
+#include <boost/format.hpp>
+
+
+#include "inspector.hpp"
+
#include "copyright_check.hpp"
#include "crlf_check.hpp"
#include "license_check.hpp"
@@ -37,6 +37,8 @@
#include "long_name_check.hpp"
#include "tab_check.hpp"
#include "minmax_check.hpp"
+#include "unnamed_namespace_check.hpp"
+
#include "cvs_iterator.hpp"
namespace fs = boost::filesystem;
@@ -94,7 +96,7 @@
&& leaf != "bin"
&& leaf != "bin.v2"
// this really out of our hands
- && leaf != "jam_src"
+ && leaf != "jam_src"
&& local.find("tools/jam/src") != 0
// too many issues with generated HTML files
&& leaf != "status"
@@ -221,14 +223,14 @@
else
{
std::cout
- << " <tr><td><a href=\"#"
+ << " <tr><td><a href=\"#"
<< current_library
<< "\">" << current_library
<< "</a></td><td align=\"center\">"
<< err_count << "</td></tr>\n";
}
}
-
+
// display_summary
---------------------------------------------------------//
void display_summary()
@@ -249,8 +251,8 @@
" </tr>\n"
;
}
-
- string current_library( msgs.begin()->library );
+
+ string current_library( msgs.begin()->library );
int err_count = 0;
for ( error_msg_vector::iterator itr ( msgs.begin() );
itr != msgs.end(); ++itr )
@@ -363,6 +365,7 @@
" -long_name\n"
" -tab\n"
" -minmax\n"
+ " -unnamed\n"
"default is all checks on; otherwise options specify desired
checks\n";
}
@@ -398,7 +401,7 @@
// << msg << '\n';
}
-
+
source_inspector::source_inspector()
{
// C/C++ source code...
@@ -411,12 +414,12 @@
register_signature( ".hxx" );
register_signature( ".inc" );
register_signature( ".ipp" );
-
+
// Boost.Build BJam source code...
register_signature( "Jamfile" );
register_signature( ".jam" );
register_signature( ".v2" );
-
+
// Other scripts; Python, shell, autoconfig, etc.
register_signature( "configure.in" );
register_signature( "GNUmakefile" );
@@ -426,7 +429,7 @@
register_signature( ".pl" );
register_signature( ".py" );
register_signature( ".sh" );
-
+
// Hypertext, Boost.Book, and other text...
register_signature( "news" );
register_signature( "readme" );
@@ -445,7 +448,7 @@
register_signature( ".xsd" );
register_signature( ".xsl" );
}
-
+
hypertext_inspector::hypertext_inspector()
{
register_signature( ".htm" );
@@ -461,7 +464,7 @@
fs::no_check );
if ( relative.empty() ) return "boost-root";
string first( *relative.begin() );
- string second = // borland 5.61 requires op=
+ string second = // borland 5.61 requires op=
++relative.begin() == relative.end()
? string() : *++relative.begin();
@@ -499,6 +502,7 @@
bool long_name_ck = true;
bool tab_ck = true;
bool minmax_ck = true;
+ bool unnamed_ck = true;
bool cvs = false;
if ( argc > 1 && std::strcmp( argv[1], "-cvs" ) == 0 )
@@ -522,6 +526,7 @@
long_name_ck = false;
tab_ck = false;
minmax_ck = false;
+ unnamed_ck = false;
}
for(; argc > 1; --argc, ++argv )
@@ -540,6 +545,8 @@
tab_ck = true;
else if ( std::strcmp( argv[1], "-minmax" ) == 0 )
minmax_ck = true;
+ else if ( std::strcmp( argv[1], "-unnamed" ) == 0 )
+ unnamed_ck = true;
else
{
std::cerr << "unknown option: " << argv[1]
@@ -565,6 +572,8 @@
inspectors.push_back( inspector_element( new boost::inspect::tab_check )
);
if ( minmax_ck )
inspectors.push_back( inspector_element( new
boost::inspect::minmax_check ) );
+ if ( unnamed_ck )
+ inspectors.push_back( inspector_element( new
boost::inspect::unnamed_namespace_check ) );
// perform the actual inspection, using the requested type of iteration
if ( cvs )
@@ -629,9 +638,9 @@
"<b>Run Date:</b> " << run_date << "\n"
"</td>\n"
"</table>\n"
- "<p>An <a
href=\"http://www.boost.org/tools/inspect/index.html\">inspection\n"
- "program</a> checks each file in the current Boost CVS for various
problems,\n"
- "generating this web page as output. Problems detected include tabs in
files,\n"
+ "<p>An <a
href=\"http://www.boost.org/tools/inspect/index.html\">inspection\n"
+ "program</a> checks each file in the current Boost CVS for various
problems,\n"
+ "generating this web page as output. Problems detected include tabs in
files,\n"
"missing copyrights, broken URL's, and similar misdemeanors.</p>\n"
;
@@ -675,7 +684,7 @@
if ( !msgs.empty() )
{
display_summary();
-
+
if (display_text == display_format)
{
std::cout << "Details:\n" << inspector_keys;
Index: inspector.hpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/inspect/inspector.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- inspector.hpp 15 Jul 2006 20:26:58 -0000 1.6
+++ inspector.hpp 18 Jul 2006 03:55:38 -0000 1.7
@@ -10,9 +10,10 @@
#define BOOST_INSPECTOR_HPP
#include <string>
-#include <iostream>
#include <set>
-#include <boost/filesystem/path.hpp>
+#include <iostream>
+#include <ostream>
+#include "boost/filesystem/path.hpp"
using std::string;
using boost::filesystem::path;
@@ -22,7 +23,7 @@
namespace inspect
{
typedef std::set< string > string_set;
-
+
class inspector
{
public:
@@ -59,7 +60,7 @@
private:
string_set m_signatures;
};
-
+
// for inspection of source code of one form or other
class source_inspector : public inspector
{
@@ -67,7 +68,7 @@
// registers the basic set of known source signatures
source_inspector();
};
-
+
// for inspection of hypertext, specifically html
class hypertext_inspector : public inspector
{
@@ -87,7 +88,7 @@
}
string impute_library( const path & full_dir_path );
-
+
}
}
Index: license_check.cpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/inspect/license_check.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- license_check.cpp 16 Jul 2006 16:15:29 -0000 1.4
+++ license_check.cpp 18 Jul 2006 03:55:38 -0000 1.5
@@ -5,12 +5,14 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#include <boost/regex.hpp>
+#include "boost/regex.hpp"
#include "license_check.hpp"
namespace
{
boost::regex license_regex(
+ "Distributed(\\s+|\\s+#\\s*|\\s+//\\s*)"
+ "under(\\s+|\\s+#\\s*|\\s+//\\s*)the(\\s+|\\s+#\\s*|\\s+//\\s*)"
"boost(\\s+|\\s+#\\s*|\\s+//\\s*)software(\\s+|\\s+#\\s*|\\s+//\\s*)license",
boost::regbase::normal | boost::regbase::icase);
@@ -23,7 +25,7 @@
license_check::license_check() : m_files_with_errors(0)
{
}
-
+
void license_check::inspect(
const string & library_name,
const path & full_path, // example: c:/foo/boost/filesystem/path.hpp
Index: license_check.hpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/inspect/license_check.hpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- license_check.hpp 16 Jul 2006 16:15:29 -0000 1.3
+++ license_check.hpp 18 Jul 2006 03:55:38 -0000 1.4
@@ -22,7 +22,7 @@
license_check();
virtual const char * name() const { return "*L*"; }
- virtual const char * desc() const { return "missing Boost license info";
}
+ virtual const char * desc() const { return "missing Boost license info,
or wrong reference text"; }
virtual void inspect(
const std::string & library_name,
@@ -31,7 +31,7 @@
virtual ~license_check()
{ std::cout << " "
- << m_files_with_errors << " files missing Boost license info\n"; }
+ << m_files_with_errors << " files missing Boost license info or
having wrong reference text\n"; }
};
}
}
Index: link_check.cpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/inspect/link_check.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- link_check.cpp 16 Jul 2006 16:15:29 -0000 1.14
+++ link_check.cpp 18 Jul 2006 03:55:38 -0000 1.15
@@ -27,13 +27,13 @@
{
// link_check constructor
--------------------------------------------------//
-
+
link_check::link_check()
: m_broken_errors(0), m_unlinked_errors(0), m_invalid_errors(0),
m_bookmark_errors(0)
{
}
-
+
// inspect (all)
-----------------------------------------------------------//
void link_check::inspect(
@@ -56,20 +56,20 @@
string::const_iterator start( contents.begin() );
string::const_iterator end( contents.end() );
- boost::match_results< string::const_iterator > what;
- boost::match_flag_type flags = boost::match_default;
+ boost::match_results< string::const_iterator > what;
+ boost::match_flag_type flags = boost::match_default;
- while( boost::regex_search( start, end, what, url_regex, flags) )
- {
+ while( boost::regex_search( start, end, what, url_regex, flags) )
+ {
// what[0] contains the whole string iterators.
- // what[1] contains the URL iterators.
+ // what[1] contains the URL iterators.
do_url( string( what[1].first, what[1].second ),
library_name, full_path );
start = what[0].second; // update search position
flags |= boost::match_prev_avail; // update flags
- flags |= boost::match_not_bob;
- }
+ flags |= boost::match_not_bob;
+ }
}
// do_url
------------------------------------------------------------------//
@@ -99,7 +99,7 @@
++m_invalid_errors;
error( library_name, source_path, string(name()) + " invalid character
in URL: " + url );
}
-
+
// strip url of bookmarks
string plain_url( url );
string::size_type pos( plain_url.find( '#' ) );
@@ -118,7 +118,7 @@
if ( plain_url[0]=='.' && plain_url[1]=='/' ) plain_url.erase( 0, 2 );
// url is relative source_path.branch()
- // convert to target_path, which is_complete()
+ // convert to target_path, which is_complete()
path target_path;
try { target_path = source_path.branch_path() /= path( plain_url,
fs::no_check ); }
catch ( const fs::filesystem_error & )
Index: link_check.hpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/inspect/link_check.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- link_check.hpp 16 Jul 2006 16:15:29 -0000 1.5
+++ link_check.hpp 18 Jul 2006 03:55:38 -0000 1.6
@@ -9,11 +9,11 @@
#ifndef BOOST_LINK_CHECK_HPP
#define BOOST_LINK_CHECK_HPP
-#include "inspector.hpp"
-
#include <map>
#include <utility> // for make_pair()
+#include "inspector.hpp"
+
namespace boost
{
namespace inspect
Index: long_name_check.cpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/inspect/long_name_check.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- long_name_check.cpp 16 Jul 2006 16:15:29 -0000 1.10
+++ long_name_check.cpp 18 Jul 2006 03:55:38 -0000 1.11
@@ -38,7 +38,7 @@
namespace inspect
{
long_name_check::long_name_check() : m_long_name_errors(0) {}
-
+
void long_name_check::inspect(
const string & library_name,
const path & full_path )
@@ -62,7 +62,7 @@
++m_long_name_errors;
error( library_name, full_path, string(name()) + " filename ends with
the dot character ('.')" );
}
-
+
path const relative_path( relative_to( full_path,
filesystem::initial_path() ), &filesystem::no_check );
if ( std::find_if( relative_path.begin(), relative_path.end(),
boost::bind( &aux::starts_with_nonalpha, _1 ) )
Index: minmax_check.cpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/inspect/minmax_check.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- minmax_check.cpp 16 Jul 2006 16:15:29 -0000 1.2
+++ minmax_check.cpp 18 Jul 2006 03:55:38 -0000 1.3
@@ -47,7 +47,7 @@
const string & contents) // contents of file to be inspected
{
if (contents.find( "boostinspect:nominmax" ) != string::npos) return;
-
+
boost::sregex_iterator cur(contents.begin(), contents.end(),
minmax_regex), end;
for( ; cur != end; ++cur, ++m_errors )
Index: tab_check.cpp
===================================================================
RCS file: /cvsroot/boost/boost/tools/inspect/tab_check.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- tab_check.cpp 16 Jul 2006 16:15:29 -0000 1.8
+++ tab_check.cpp 18 Jul 2006 03:55:38 -0000 1.9
@@ -23,7 +23,7 @@
register_signature( "Jamfile" );
register_signature( ".py" );
}
-
+
void tab_check::inspect(
const string & library_name,
const path & full_path, // example: c:/foo/boost/filesystem/path.hpp
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs