| 1 | //  license_check implementation  --------------------------------------------// | 
|---|
| 2 |  | 
|---|
| 3 | //  Copyright Beman Dawes 2002-2003. | 
|---|
| 4 | //  Distributed under the Boost Software License, Version 1.0. | 
|---|
| 5 | //  (See accompanying file LICENSE_1_0.txt or copy at | 
|---|
| 6 | //  http://www.boost.org/LICENSE_1_0.txt) | 
|---|
| 7 |  | 
|---|
| 8 | #include "boost/regex.hpp" | 
|---|
| 9 | #include "license_check.hpp" | 
|---|
| 10 |  | 
|---|
| 11 | namespace | 
|---|
| 12 | { | 
|---|
| 13 |   boost::regex license_regex( | 
|---|
| 14 |     //~ The next two lines change the regex so that it detects when the license | 
|---|
| 15 |     //~ doesn't follow the prefered statement. Disabled because it currently | 
|---|
| 16 |     //~ generates a large number of issues. | 
|---|
| 17 |     //~ "Distributed[\\s\\W]+" | 
|---|
| 18 |     //~ "under[\\s\\W]+the[\\s\\W]+" | 
|---|
| 19 |     "boost[\\s\\W]+software[\\s\\W]+license", | 
|---|
| 20 |     boost::regbase::normal | boost::regbase::icase); | 
|---|
| 21 |  | 
|---|
| 22 | } // unnamed namespace | 
|---|
| 23 |  | 
|---|
| 24 | namespace boost | 
|---|
| 25 | { | 
|---|
| 26 |   namespace inspect | 
|---|
| 27 |   { | 
|---|
| 28 |    license_check::license_check() : m_files_with_errors(0) | 
|---|
| 29 |    { | 
|---|
| 30 |    } | 
|---|
| 31 |  | 
|---|
| 32 |    void license_check::inspect( | 
|---|
| 33 |       const string & library_name, | 
|---|
| 34 |       const path & full_path,   // example: c:/foo/boost/filesystem/path.hpp | 
|---|
| 35 |       const string & contents )     // contents of file to be inspected | 
|---|
| 36 |     { | 
|---|
| 37 |       if (contents.find( "boostinspect:" "nolicense" ) != string::npos) return; | 
|---|
| 38 |  | 
|---|
| 39 |       if ( !boost::regex_search( contents, license_regex ) ) | 
|---|
| 40 |       { | 
|---|
| 41 |         ++m_files_with_errors; | 
|---|
| 42 |         error( library_name, full_path, name() ); | 
|---|
| 43 |       } | 
|---|
| 44 |     } | 
|---|
| 45 |   } // namespace inspect | 
|---|
| 46 | } // namespace boost | 
|---|
| 47 |  | 
|---|
| 48 |  | 
|---|