Debian Codegraph @

kwsCheckTabs.cxx

raw
1 /*=========================================================================
2
3 Program: KWStyle - Kitware Style Checker
4 Module: kwsCheckTabs.cxx
5
6 Copyright (c) Kitware, Inc. All rights reserved.
7 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notices for more information.
12
13 =========================================================================*/
14 #include "kwsParser.h"
15
16 #include "kwsPushBoostWarnings.h"
17 #include <boost/xpressive/xpressive.hpp>
18 #include "kwsPopBoostWarnings.h"
19
20 using namespace boost::xpressive;
21
22 namespace kws {
23
24 /** Check if the file contains tabs */
25 bool Parser::CheckTabs()
26 {
27 m_TestsDone[TABS] = true;
28 m_TestsDescription[TABS] = "The file should not have any tabs";
29
30 bool hasError = false;
31
32 sregex lineWithTabRegex = sregex::compile(R"(^[^\r\n]*?(\t)[^\r\n]*$)");
33 sregex_iterator currentTabIterator(m_Buffer.begin(), m_Buffer.end(), lineWithTabRegex);
34 sregex_iterator end;
35
36 for (; currentTabIterator != end; ++currentTabIterator)
37 {
38 Error error;
39 smatch const &currentMatch = *currentTabIterator;
40 error.line = this->GetLineNumber(currentMatch.position(1), false);
41 error.line2 = error.line;
42 error.number = TABS;
43 error.description = "Tabs identified";
44 m_ErrorList.push_back(error);
45 hasError = true;
46 }
47
48 return !hasError;
49 }
50 } // end namespace kws