18
18
*/
19
19
20
20
#include " csfilter.hh"
21
+ #include " regex.hh"
21
22
22
23
#include < iostream>
23
24
24
- #include < boost/regex.hpp>
25
-
26
25
// Setup verbosity for debugging string substitions while matching them.
27
26
// Verbosity levels are from 0 to 3 (0 is off)
28
27
#define DEBUG_SUBST 0
29
28
30
29
inline std::string regexReplaceWrap (
31
30
const std::string &input,
32
- const boost::regex &re,
31
+ const RE &re,
33
32
const std::string &fmt)
34
33
{
35
34
std::string output (boost::regex_replace (input, re, fmt));
@@ -43,7 +42,7 @@ inline std::string regexReplaceWrap(
43
42
MsgFilter* MsgFilter::self_;
44
43
45
44
struct MsgReplace {
46
- const boost::regex regex;
45
+ const RE regex;
47
46
const std::string replaceWith;
48
47
49
48
MsgReplace (const std::string ®ex_, const std::string &rpl) :
@@ -57,18 +56,18 @@ typedef std::vector<MsgReplace *> TRegexList;
57
56
typedef std::map<const std::string, TRegexList> TMsgFilterMap;
58
57
59
58
struct MsgFilter ::Private {
60
- bool ignorePath;
61
- const std::string strKrn;
62
- const boost::regex reKrn;
63
- const boost::regex reMsgConstExprRes;
64
- const boost::regex reDir;
65
- const boost::regex reFile;
66
- const boost::regex rePath;
67
- const boost::regex reTmpPath;
68
- const boost::regex reTmpCleaner;
59
+ bool ignorePath = false ;
69
60
TMsgFilterMap msgFilterMap;
70
61
TSubstMap fileSubsts;
71
62
63
+ const std::string strKrn = " ^[a-zA-Z+]+" ;
64
+ const RE reKrn = RE(strKrn);
65
+ const RE reDir = RE(" ^([^:]*/)" );
66
+ const RE reFile = RE(" [^/]+$" );
67
+ const RE rePath = RE(" ^(?:/builddir/build/BUILD/)?([^/]+/)(.*)(\\ .[ly])?$" );
68
+ const RE reTmpPath = RE(" ^(/var)?/tmp/(.*)$" );
69
+ const RE reTmpCleaner = RE(" (.*)" );
70
+
72
71
void addMsgFilter (
73
72
const std::string &checker,
74
73
const std::string ®exp,
@@ -77,68 +76,56 @@ struct MsgFilter::Private {
77
76
struct MsgReplace *rpl = new MsgReplace (regexp, replacement);
78
77
msgFilterMap[checker].push_back (rpl);
79
78
}
80
-
81
- Private ():
82
- ignorePath (false ),
83
- strKrn (" ^[a-zA-Z+]+" ),
84
- reKrn (strKrn),
85
- reDir (" ^([^:]*/)" ),
86
- reFile (" [^/]+$" ),
87
- rePath (" ^(?:/builddir/build/BUILD/)?([^/]+/)(.*)(\\ .[ly])?$" ),
88
- reTmpPath (" ^(/var)?/tmp/(.*)$" ),
89
- reTmpCleaner (" (.*)" )
90
- {
91
- addMsgFilter (" " , " [0-9][0-9]* out of [0-9][0-9]* times" );
92
- addMsgFilter (" UNUSED_VALUE" ,
93
- " \\ (instance [0-9]+\\ )" );
94
- addMsgFilter (" STRING_OVERFLOW" ,
95
- " You might overrun the [0-9][0-9]* byte" );
96
- // ignore changes in parameters -> it is still the same UNUSED_VALUE
97
- addMsgFilter (" UNUSED_VALUE" ,
98
- " returned by \" ([^\\ (]+)\\ (.*\\ )\" " ,
99
- " returned by \"\\ 1\\ (\\ )\" " );
100
-
101
- // unify the format of glib/gnome dprecation warnings
102
- // NOTE: "\u007f\u007f\u007f" does not compile on el6
103
- static const char uniApos[] = { 0x7f , 0x7f , 0x7f , 0x00 };
104
- addMsgFilter (" COMPILER_WARNING" , uniApos, " '" );
105
-
106
- // ignore embeded declaration location
107
- addMsgFilter (" COMPILER_WARNING" , " \\ (declared at [^)]*\\ )" , " " );
108
-
109
- // ignore suggestion for deprecation warnings
110
- addMsgFilter (" COMPILER_WARNING" , " : Use '[^']*' instead" , " " );
111
-
112
- // unify (per build random) names of temporary variables
113
- addMsgFilter (" COMPILER_WARNING" , " _tmp[0-9]+_" , " _tmp_" );
114
-
115
- // pylint reports, either raw, or prospector-wrapped
116
- const std::vector<std::string> pylintCheckers= {
117
- " PROSPECTOR_WARNING" ,
118
- " PYLINT_WARNING"
119
- };
120
- for (const std::string &checker : pylintCheckers) {
121
- // "Too many lines in module (1152/1000)" etc.
122
- addMsgFilter (checker, " \\ ([0-9]+/[0-9]+\\ )$" , " " );
123
-
124
- // "... Redefining name 'desc' from outer scope (line 10)" etc.
125
- addMsgFilter (checker, " \\ ((?:imported )?line [0-9]+\\ )$" , " " );
126
- }
127
-
128
- // "__coverity_strcmp" -> "strcmp", etc.
129
- addMsgFilter (" " , " __coverity_" , " " );
130
-
131
- // artificial field names of anonymous unions that Coverity produces
132
- addMsgFilter (" " , " __C[0-9]+" );
133
-
134
- // used by IDENTIFIER_TYPO (but applies generally)
135
- addMsgFilter (" " , " at least [0-9][0-9]* times.$" );
136
- }
137
79
};
138
80
139
81
MsgFilter::MsgFilter ():
140
82
d(new Private)
141
83
{
84
+ d->addMsgFilter (" " , " [0-9][0-9]* out of [0-9][0-9]* times" );
85
+ d->addMsgFilter (" UNUSED_VALUE" ,
86
+ " \\ (instance [0-9]+\\ )" );
87
+ d->addMsgFilter (" STRING_OVERFLOW" ,
88
+ " You might overrun the [0-9][0-9]* byte" );
89
+ // ignore changes in parameters -> it is still the same UNUSED_VALUE
90
+ d->addMsgFilter (" UNUSED_VALUE" ,
91
+ " returned by \" ([^\\ (]+)\\ (.*\\ )\" " ,
92
+ " returned by \"\\ 1\\ (\\ )\" " );
93
+
94
+ // unify the format of glib/gnome dprecation warnings
95
+ // NOTE: "\u007f\u007f\u007f" does not compile on el6
96
+ static const char uniApos[] = { 0x7f , 0x7f , 0x7f , 0x00 };
97
+ d->addMsgFilter (" COMPILER_WARNING" , uniApos, " '" );
98
+
99
+ // ignore embeded declaration location
100
+ d->addMsgFilter (" COMPILER_WARNING" , " \\ (declared at [^)]*\\ )" , " " );
101
+
102
+ // ignore suggestion for deprecation warnings
103
+ d->addMsgFilter (" COMPILER_WARNING" , " : Use '[^']*' instead" , " " );
104
+
105
+ // unify (per build random) names of temporary variables
106
+ d->addMsgFilter (" COMPILER_WARNING" , " _tmp[0-9]+_" , " _tmp_" );
107
+
108
+ // pylint reports, either raw, or prospector-wrapped
109
+ const std::vector<std::string> pylintCheckers= {
110
+ " PROSPECTOR_WARNING" ,
111
+ " PYLINT_WARNING"
112
+ };
113
+ for (const std::string &checker : pylintCheckers) {
114
+ // "Too many lines in module (1152/1000)" etc.
115
+ d->addMsgFilter (checker, " \\ ([0-9]+/[0-9]+\\ )$" , " " );
116
+
117
+ // "... Redefining name 'desc' from outer scope (line 10)" etc.
118
+ d->addMsgFilter (checker, " \\ ((?:imported )?line [0-9]+\\ )$" , " " );
119
+ }
120
+
121
+ // "__coverity_strcmp" -> "strcmp", etc.
122
+ d->addMsgFilter (" " , " __coverity_" , " " );
123
+
124
+ // artificial field names of anonymous unions that Coverity produces
125
+ d->addMsgFilter (" " , " __C[0-9]+" );
126
+
127
+ // used by IDENTIFIER_TYPO (but applies generally)
128
+ d->addMsgFilter (" " , " at least [0-9][0-9]* times.$" );
142
129
}
143
130
144
131
MsgFilter::~MsgFilter ()
@@ -224,7 +211,7 @@ std::string MsgFilter::filterPath(const std::string &origPath)
224
211
std::cerr << " krnPattern: " << krnPattern << " \n " ;
225
212
#endif
226
213
227
- const boost::regex reKill (krnPattern);
214
+ const RE reKill (krnPattern);
228
215
core = boost::regex_replace (core, reKill, " " );
229
216
230
217
// quirk for Coverity inconsistency in handling bison-generated file names
0 commit comments