LifeV
crlf_check.cpp
Go to the documentation of this file.
1
// crlf_check implementation ------------------------------------------------//
2
3
// Copyright Beman Dawes 2002.
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
// Contributed by Joerg Walter
9
10
#
include
"crlf_check.hpp"
11
12
namespace
boost
13
{
14
namespace
inspect
15
{
16
crlf_check
::
crlf_check
() :
m_files_with_errors
(0)
17
{
18
}
19
20
void
crlf_check
::
inspect
(
21
const
string& library_name,
22
const
path& full_path,
// example: c:/foo/boost/filesystem/path.hpp
23
const
string& contents )
// contents of file to be inspected
24
{
25
26
// The understanding on line endings, as I remember it, was that
27
// either "\n" or "\r\n" is OK, and they can be mixed, but "\r" alone
28
// is not acceptable. Mixed line endings are allowed because Boost files
29
// are commonly edited in both Windows and UNIX environments, and editors
30
// in those environments generally accept either ending. Even Mac people
31
// agreed with this policy. --Beman
32
33
// Joerg's original implementation is saved below,
34
// in case we change our minds!
35
36
for
( std::string::const_iterator itr ( contents.begin() );
37
itr != contents.end(); ++itr )
38
{
39
if
( *itr ==
'\r'
&& ( (itr + 1) == contents.end() || * (itr + 1) !=
'\n'
) )
40
{
41
++m_files_with_errors;
42
error ( library_name, full_path, desc() );
43
break
;
44
}
45
}
46
47
/*
48
size_t cr_count = 0;
49
size_t lf_count = 0;
50
size_t crlf_count = 0;
51
bool had_cr = false;
52
for ( size_t i = 0; i < contents.length(); ++i )
53
{
54
switch ( contents[i] )
55
{
56
case '\r':
57
had_cr = true;
58
++cr_count;
59
break;
60
case '\n':
61
++lf_count;
62
if ( had_cr )
63
++crlf_count;
64
// fallthrough
65
default:
66
had_cr = false;
67
break;
68
}
69
}
70
if ( cr_count > 0 && lf_count != crlf_count )
71
{
72
++m_files_with_errors;
73
error( library_name, full_path, desc() );
74
}
75
*/
76
}
77
}
// namespace inspect
78
}
// namespace boost
boost
Definition:
copyright_check.cpp:10
boost::inspect::crlf_check::m_files_with_errors
long m_files_with_errors
Definition:
crlf_check.hpp:22
boost::inspect::crlf_check::crlf_check
crlf_check()
Definition:
crlf_check.cpp:16
boost::inspect::crlf_check::inspect
virtual void inspect(const std::string &library_name, const path &full_path, const std::string &contents)
Definition:
crlf_check.cpp:20
boost::inspect
Definition:
copyright_check.cpp:12
boost::inspect::crlf_check
Definition:
crlf_check.hpp:20
lifev-release-doc
tools
inspect
crlf_check.cpp
Generated on Wed Mar 7 2018 19:41:11 for LifeV by
1.8.13