Revision: 75798
http://sourceforge.net/p/brlcad/code/75798
Author: starseeker
Date: 2020-05-14 14:04:14 +0000 (Thu, 14 May 2020)
Log Message:
-----------
compile regexes once, use for all tests
Modified Paths:
--------------
brlcad/trunk/regress/repository/repocheck.cpp
Modified: brlcad/trunk/regress/repository/repocheck.cpp
===================================================================
--- brlcad/trunk/regress/repository/repocheck.cpp 2020-05-14 12:57:10 UTC
(rev 75797)
+++ brlcad/trunk/regress/repository/repocheck.cpp 2020-05-14 14:04:14 UTC
(rev 75798)
@@ -51,12 +51,40 @@
#include <sstream>
#include <string>
#define MAX_LINES_CHECK 500
-#define EXPECTED_PLATFORM_SYMBOLS 206
+#define EXPECTED_PLATFORM_SYMBOLS 205
-class repo_log_t {
+class repo_info_t {
public:
+
+ /* Standard regex patterns uses in searches */
+
+ std::regex inc_regex;
+
+ /* bio.h */
+ std::regex bio_regex;
+ std::map<std::string, std::regex> bio_filters;
+
+ /* bnetwork.h */
+ std::regex bnetwork_regex;
+ std::map<std::string, std::regex> bnetwork_filters;
+
+ /* common.h */
+ std::regex common_regex;
+ std::vector<std::regex> common_exempt_filters;
+
+ /* api usage */
+ std::vector<std::regex> api_file_filters;
+ std::map<std::string, std::vector<std::regex>> api_exemptions;
+ std::map<std::string, std::regex> api_func_filters;
+
+ /* platform symbols */
+ std::map<std::pair<std::string, std::string>, std::regex>
platform_checks;
+ std::vector<std::regex> platform_file_filters;
+
+
std::string path_root;
+ // Outputs
std::vector<std::string> api_log;
std::vector<std::string> bio_log;
std::vector<std::string> bnet_log;
@@ -66,31 +94,167 @@
std::vector<std::string> symbol_bld_log;
};
-bool
-bio_redundant_check(repo_log_t &l, std::vector<std::string> &srcs)
-{
- bool ret = false;
- std::regex bio_regex("#[[:space:]]*include[[:space:]]*\"bio.h\".*");
- std::regex inc_regex("#[[:space:]]*include.*");
- const char *redundant_filters[] {
- ".*<stdio.h>.*",
- ".*<windows.h>.*",
- ".*<io.h>.*",
- ".*<unistd.h>.*",
- ".*<fcntl.h>.*",
- NULL
- };
- std::map<std::string, std::regex> filters;
+void
+regex_init(repo_info_t &r) {
int cnt = 0;
- const char *rf = redundant_filters[cnt];
- while (rf) {
- filters[std::string(rf)] = std::regex(rf);
- cnt++;
- rf = redundant_filters[cnt];
+ const char *rf;
+ r.inc_regex = std::regex("#[[:space:]]*include.*");
+
+ /* bio.h regex */
+ {
+ r.bio_regex = std::regex("#[[:space:]]*include[[:space:]]*\"bio.h\".*");
+ const char *bio_filter_strs[] {
+ "stdio.h", "windows.h", "io.h", "unistd.h", "fcntl.h",
+ NULL
+ };
+ cnt = 0;
+ rf = bio_filter_strs[cnt];
+ while (rf) {
+ std::string rrf = std::string(".*<") + std::string(rf) +
std::string(">.*");
+ r.bio_filters[std::string(rf)] = std::regex(rrf);
+ cnt++;
+ rf = bio_filter_strs[cnt];
+ }
}
+ /* bnetwork.h regex */
+ {
+ r.bnetwork_regex =
std::regex("#[[:space:]]*include[[:space:]]*\"bnetwork.h\".*");
+ const char *bnetwork_filter_strs[] {
+ "winsock2.h", "netinet/in.h", "netinet/tcp.h", "arpa/inet.h",
+ NULL
+ };
+ cnt = 0;
+ rf = bnetwork_filter_strs[cnt];
+ while (rf) {
+ std::string rrf = std::string(".*<") + std::string(rf) +
std::string(">.*");
+ r.bnetwork_filters[std::string(rf)] = std::regex(rrf);
+ cnt++;
+ rf = bnetwork_filter_strs[cnt];
+ }
+ }
+ /* common.h regex */
+ {
+ r.common_regex =
std::regex("#[[:space:]]*include[[:space:]]*\"common.h\".*");
+ const char *common_exempt_filter_strs[] {
+ "bio.h", "bnetwork.h", "config_win.h", "csg_parser.c",
+ "csg_scanner.h", "obj_grammar.c", "obj_grammar.cpp",
+ "obj_libgcv_grammar.cpp", "obj_obj-g_grammar.cpp",
+ "obj_parser.h", "obj_rules.cpp", "obj_rules.l",
+ "obj_scanner.h", "obj_util.h", "optionparser.h", "pinttypes.h",
+ "points_scan.c", "pstdint.h", "schema.h", "script.c", "ttcp.c",
+ "uce-dirent.h",
+ NULL
+ };
+ cnt = 0;
+ rf = common_exempt_filter_strs[cnt];
+ while (rf) {
+ std::string rrf = std::string(".*/") + std::string(rf) +
std::string("$");
+ r.common_exempt_filters.push_back(std::regex(rrf));
+ cnt++;
+ rf = common_exempt_filter_strs[cnt];
+ }
+
+ }
+
+ /* API usage check regex */
+ {
+ const char *api_file_exemption_strs[] {
+ "CONFIG_CONTROL_DESIGN.*", ".bu/log[.]h$", ".bu/path[.]h$",
+ ".bu/str[.]h$", ".cursor[.]c$", ".ttcp[.]c$",
+ ".misc/CMake/compat/.*",
+ NULL
+ };
+ cnt = 0;
+ rf = api_file_exemption_strs[cnt];
+ while (rf) {
+ std::string rrf = std::string(".*/") + std::string(rf);
+ r.api_file_filters.push_back(std::regex(rrf));
+ cnt++;
+ rf = api_file_exemption_strs[cnt];
+ }
+
+ const char *api_func_strs[] {
+ "abort", "dirname", "fgets", "getopt", "qsort", "remove", "rmdir",
+ "strcasecmp", "strcat", "strcmp", "strcpy", "strdup",
+ "stricmp", "strlcat", "strlcpy", "strncasecmp", "strncat",
+ "strncmp", "strncpy", "unlink",
+ NULL
+ };
+ cnt = 0;
+ rf = api_func_strs[cnt];
+ while (rf) {
+ std::string rrf = std::string(".*[^a-zA-Z0-9_:]") + std::string(rf)
+ std::string("[(].*");
+ r.api_func_filters[std::string(rf)] = std::regex(rrf);
+ cnt++;
+ rf = api_func_strs[cnt];
+ }
+
+
r.api_exemptions[std::string("abort")].push_back(std::regex(".*/bomb[.]c$"));
+
r.api_exemptions[std::string("dirname")].push_back(std::regex(".*/tests/dirname[.]c$"));
+
r.api_exemptions[std::string("remove")].push_back(std::regex(".*/file[.]c$"));
+
r.api_exemptions[std::string("strcasecmp")].push_back(std::regex(".*/str[.]c$"));
+
r.api_exemptions[std::string("strcmp")].push_back(std::regex(".*/str[.]c$"));
+
r.api_exemptions[std::string("strdup")].push_back(std::regex(".*/str[.]c$"));
+
r.api_exemptions[std::string("strlcat")].push_back(std::regex(".*/str[.]c$"));
+
r.api_exemptions[std::string("strlcpy")].push_back(std::regex(".*/str[.]c$"));
+
r.api_exemptions[std::string("strncasecmp")].push_back(std::regex(".*/str[.]c$"));
+
r.api_exemptions[std::string("strncat")].push_back(std::regex(".*/str[.]c$"));
+
r.api_exemptions[std::string("strncmp")].push_back(std::regex(".*/str[.]c$"));
+
r.api_exemptions[std::string("strncpy")].push_back(std::regex(".*/rt/db4[.]h$"));
+
r.api_exemptions[std::string("strncpy")].push_back(std::regex(".*/str[.]c$"));
+
r.api_exemptions[std::string("strncpy")].push_back(std::regex(".*/vls[.]c$"));
+
r.api_exemptions[std::string("strncpy")].push_back(std::regex(".*/wfobj/obj_util[.]cpp$"));
+ }
+
+ /* Platform symbol usage check regex */
+ {
+ const char *platform_strs[] {
+ "AIX", "APPLE", "CYGWIN", "DARWIN", "FREEBSD", "HAIKU", "HPUX",
+ "LINUX", "MINGW", "MSDOS", "QNX", "SGI", "SOLARIS", "SUN",
+ "SUNOS", "SVR4", "SYSV", "ULTRIX", "UNIX", "VMS", "WIN16",
+ "WIN32", "WIN64", "WINE", "WINNT", NULL
+ };
+ cnt = 0;
+ rf = platform_strs[cnt];
+ while (rf) {
+ std::string p_upper(rf);
+ std::string p_lower = p_upper;
+ std::transform(p_lower.begin(), p_lower.end(), p_lower.begin(),
[](unsigned char c){ return std::tolower(c); });
+ std::string rrf =
std::string("^[[:space:]#]*(if|IF).*[[:space:](]_*(") + p_lower +
std::string("|") + p_upper + std::string(")_*([[:space:]]|[)]|$).*$");
+ r.platform_checks[std::make_pair(p_lower,p_upper)] =
std::regex(rrf);
+ cnt++;
+ rf = platform_strs[cnt];
+ }
+
+ const char *platform_exemption_strs[] {
+ ".*/pstdint[.]h$",
+ ".*/pinttypes[.]h$",
+ ".*/uce-dirent[.]h$",
+ NULL
+ };
+ cnt = 0;
+ rf = platform_exemption_strs[cnt];
+ while (rf) {
+ r.platform_file_filters.push_back(std::regex(rf));
+ cnt++;
+ rf = platform_exemption_strs[cnt];
+ }
+ }
+}
+
+
+
+
+
+
+int
+bio_redundant_check(repo_info_t &r, std::vector<std::string> &srcs)
+{
+ int ret = 0;
+
for (size_t i = 0; i < srcs.size(); i++) {
std::string sline;
@@ -107,13 +271,13 @@
bool have_bio = false;
while (std::getline(fs, sline) && lcnt < MAX_LINES_CHECK) {
lcnt++;
- if (std::regex_match(sline, bio_regex)) {
+ if (std::regex_match(sline, r.bio_regex)) {
have_bio = true;
continue;
}
std::map<std::string, std::regex>::iterator f_it;
- for (f_it = filters.begin(); f_it != filters.end(); f_it++) {
+ for (f_it = r.bio_filters.begin(); f_it != r.bio_filters.end();
f_it++) {
if (std::regex_match(sline, f_it->second)) {
match_line_nums[f_it->first].insert(lcnt);
continue;
@@ -126,10 +290,10 @@
for (m_it = match_line_nums.begin(); m_it != match_line_nums.end();
m_it++) {
if (m_it->second.size()) {
std::set<int>::iterator l_it;
- ret = true;
+ ret = 1;
for (l_it = m_it->second.begin(); l_it !=
m_it->second.end(); l_it++) {
- std::string lstr =
srcs[i].substr(l.path_root.length()+1) + std::string(" has bio.h, but also
matches regex ") + m_it->first + std::string(" on line ") +
std::to_string(lcnt) + std::string("\n");
- l.bio_log.push_back(lstr);
+ std::string lstr =
srcs[i].substr(r.path_root.length()+1) + std::string(" has bio.h, but also
includes ") + m_it->first + std::string(" on line ") + std::to_string(*l_it) +
std::string("\n");
+ r.bio_log.push_back(lstr);
}
}
}
@@ -139,30 +303,11 @@
return ret;
}
-bool
-bnetwork_redundant_check(repo_log_t &l, std::vector<std::string> &srcs)
+int
+bnetwork_redundant_check(repo_info_t &r, std::vector<std::string> &srcs)
{
- bool ret = false;
- std::regex
bnetwork_regex("#[[:space:]]*include[[:space:]]*\"bnetwork.h\".*");
- std::regex inc_regex("#[[:space:]]*include.*");
- const char *redundant_filters[] {
- ".*<winsock2.h>.*",
- ".*<netinet/in.h>.*",
- ".*<netinet/tcp.h>.*",
- ".*<arpa/inet.h>.*",
- NULL
- };
+ int ret = 0;
- std::map<std::string, std::regex> filters;
- int cnt = 0;
- const char *rf = redundant_filters[cnt];
- while (rf) {
- filters[std::string(rf)] = std::regex(rf);
- cnt++;
- rf = redundant_filters[cnt];
- }
-
-
for (size_t i = 0; i < srcs.size(); i++) {
std::string sline;
@@ -179,13 +324,13 @@
bool have_bnetwork = false;
while (std::getline(fs, sline) && lcnt < MAX_LINES_CHECK) {
lcnt++;
- if (std::regex_match(sline, bnetwork_regex)) {
+ if (std::regex_match(sline, r.bnetwork_regex)) {
have_bnetwork = true;
continue;
}
std::map<std::string, std::regex>::iterator f_it;
- for (f_it = filters.begin(); f_it != filters.end(); f_it++) {
+ for (f_it = r.bnetwork_filters.begin(); f_it !=
r.bnetwork_filters.end(); f_it++) {
if (std::regex_match(sline, f_it->second)) {
match_line_nums[f_it->first].insert(lcnt);
continue;
@@ -198,10 +343,10 @@
for (m_it = match_line_nums.begin(); m_it != match_line_nums.end();
m_it++) {
if (m_it->second.size()) {
std::set<int>::iterator l_it;
- ret = true;
+ ret = 1;
for (l_it = m_it->second.begin(); l_it !=
m_it->second.end(); l_it++) {
- std::string lstr =
srcs[i].substr(l.path_root.length()+1) + std::string(" has bnetwork.h, but also
matches regex ") + m_it->first + std::string(" on line ") +
std::to_string(lcnt) + std::string("\n");
- l.bnet_log.push_back(lstr);
+ std::string lstr =
srcs[i].substr(r.path_root.length()+1) + std::string(" has bnetwork.h, but also
includes ") + m_it->first + std::string(" on line ") + std::to_string(*l_it) +
std::string("\n");
+ r.bnet_log.push_back(lstr);
}
}
}
@@ -213,51 +358,15 @@
-bool
-common_include_first(repo_log_t &l, std::vector<std::string> &srcs)
+int
+common_include_first(repo_info_t &r, std::vector<std::string> &srcs)
{
- bool ret = false;
- std::regex inc_regex("#[[:space:]]*include.*");
- std::regex common_regex("#[[:space:]]*include[[:space:]]*\"common.h\".*");
- const char *exempt_filters[] {
- ".*/bio.h",
- ".*/bnetwork.h",
- ".*/config_win.h",
- ".*/csg_parser.c",
- ".*/csg_scanner.h",
- ".*/obj_grammar.c",
- ".*/obj_grammar.cpp",
- ".*/obj_libgcv_grammar.cpp",
- ".*/obj_obj-g_grammar.cpp",
- ".*/obj_parser.h",
- ".*/obj_rules.cpp",
- ".*/obj_rules.l",
- ".*/obj_scanner.h",
- ".*/obj_util.h",
- ".*/optionparser.h",
- ".*/pinttypes.h",
- ".*/points_scan.c",
- ".*/pstdint.h",
- ".*/schema.h",
- ".*/script.c",
- ".*/ttcp.c",
- ".*/uce-dirent.h",
- NULL
- };
+ int ret = 0;
- std::vector<std::regex> filters;
- int cnt = 0;
- const char *rf = exempt_filters[cnt];
- while (rf) {
- filters.push_back(std::regex(rf));
- cnt++;
- rf = exempt_filters[cnt];
- }
-
for (size_t i = 0; i < srcs.size(); i++) {
bool skip = false;
- for (size_t j = 0; j < filters.size(); j++) {
- if (std::regex_match(srcs[i], filters[j])) {
+ for (size_t j = 0; j < r.common_exempt_filters.size(); j++) {
+ if (std::regex_match(srcs[i], r.common_exempt_filters[j])) {
skip = true;
break;
}
@@ -279,15 +388,15 @@
std::string sline;
while (std::getline(fs, sline) && lcnt < MAX_LINES_CHECK) {
lcnt++;
- if (std::regex_match(sline, common_regex)) {
+ if (std::regex_match(sline, r.common_regex)) {
if (have_inc) {
- std::string lstr = srcs[i].substr(l.path_root.length()+1) +
std::string(" includes common.h on line ") + std::to_string(lcnt) +
std::string(" but a prior #include statement was found at line ") +
std::to_string(first_inc_line) + std::string("\n");
- l.common_log.push_back(lstr);
- ret = true;
+ std::string lstr = srcs[i].substr(r.path_root.length()+1) +
std::string(" includes common.h on line ") + std::to_string(lcnt) +
std::string(" but a prior #include statement was found at line ") +
std::to_string(first_inc_line) + std::string("\n");
+ r.common_log.push_back(lstr);
+ ret = 1;
}
break;
}
- if (!have_inc && std::regex_match(sline, inc_regex)) {
+ if (!have_inc && std::regex_match(sline, r.inc_regex)) {
have_inc = true;
first_inc_line = lcnt;
}
@@ -298,86 +407,15 @@
return ret;
}
-bool
-api_usage(repo_log_t &l, std::vector<std::string> &srcs)
+int
+api_usage(repo_info_t &r, std::vector<std::string> &srcs)
{
- bool ret = false;
- std::map<std::string, std::vector<std::regex>> exemptions;
- exemptions[std::string("abort")].push_back(std::regex(".*/bomb[.]c$"));
-
exemptions[std::string("dirname")].push_back(std::regex(".*/tests/dirname[.]c$"));
- exemptions[std::string("remove")].push_back(std::regex(".*/file[.]c$"));
- exemptions[std::string("strcasecmp")].push_back(std::regex(".*/str[.]c$"));
- exemptions[std::string("strcmp")].push_back(std::regex(".*/str[.]c$"));
- exemptions[std::string("strdup")].push_back(std::regex(".*/str[.]c$"));
- exemptions[std::string("strlcat")].push_back(std::regex(".*/str[.]c$"));
- exemptions[std::string("strlcpy")].push_back(std::regex(".*/str[.]c$"));
-
exemptions[std::string("strncasecmp")].push_back(std::regex(".*/str[.]c$"));
- exemptions[std::string("strncat")].push_back(std::regex(".*/str[.]c$"));
- exemptions[std::string("strncmp")].push_back(std::regex(".*/str[.]c$"));
- exemptions[std::string("strncpy")].push_back(std::regex(".*/rt/db4[.]h$"));
- exemptions[std::string("strncpy")].push_back(std::regex(".*/str[.]c$"));
- exemptions[std::string("strncpy")].push_back(std::regex(".*/vls[.]c$"));
-
exemptions[std::string("strncpy")].push_back(std::regex(".*/wfobj/obj_util[.]cpp$"));
+ int ret = 0;
- const char *file_exemptions[] {
- ".*/CONFIG_CONTROL_DESIGN.*",
- ".*/bu/log[.]h$",
- ".*/bu/path[.]h$",
- ".*/bu/str[.]h$",
- ".*/cursor[.]c$",
- ".*/ttcp[.]c$",
- ".*/misc/CMake/compat/.*",
- NULL
- };
-
- const char *funcs[] {
- "abort",
- "dirname",
- "fgets",
- "getopt",
- "qsort",
- "remove",
- "rmdir",
- "strcasecmp",
- "strcat",
- "strcmp",
- "strcpy",
- "strdup",
- "stricmp",
- "strlcat",
- "strlcpy",
- "strncasecmp",
- "strncat",
- "strncmp",
- "strncpy",
- "unlink",
- NULL
- };
-
- std::vector<std::regex> file_filters;
- int cnt = 0;
- const char *rf = file_exemptions[cnt];
- while (rf) {
- file_filters.push_back(std::regex(rf));
- cnt++;
- rf = file_exemptions[cnt];
- }
-
- std::map<std::string, std::regex> func_filters;
- cnt = 0;
- rf = funcs[cnt];
- while (rf) {
- std::string rrf = std::string(".*[^a-zA-Z0-9_:]") + std::string(rf) +
std::string("[(].*");
- func_filters[std::string(rf)] = std::regex(rrf);
- cnt++;
- rf = funcs[cnt];
- }
-
-
for (size_t i = 0; i < srcs.size(); i++) {
bool skip = false;
- for (size_t j = 0; j < file_filters.size(); j++) {
- if (std::regex_match(srcs[i], file_filters[j])) {
+ for (size_t j = 0; j < r.api_file_filters.size(); j++) {
+ if (std::regex_match(srcs[i], r.api_file_filters[j])) {
skip = true;
break;
}
@@ -400,7 +438,7 @@
while (std::getline(fs, sline)) {
lcnt++;
std::map<std::string, std::regex>::iterator ff_it;
- for (ff_it = func_filters.begin(); ff_it != func_filters.end();
ff_it++) {
+ for (ff_it = r.api_func_filters.begin(); ff_it !=
r.api_func_filters.end(); ff_it++) {
if (!std::strstr(sline.c_str(), ff_it->first.c_str())) {
// Only try the full regex if strstr says there is a chance
continue;
@@ -408,9 +446,9 @@
if (std::regex_match(sline, ff_it->second)) {
// If we have a it, make sure it's not an exemption
bool exempt = false;
- if (exemptions.find(ff_it->first) != exemptions.end()) {
+ if (r.api_exemptions.find(ff_it->first) !=
r.api_exemptions.end()) {
std::vector<std::regex>::iterator e_it;
- for (e_it = exemptions[ff_it->first].begin(); e_it !=
exemptions[ff_it->first].end(); e_it++) {
+ for (e_it = r.api_exemptions[ff_it->first].begin();
e_it != r.api_exemptions[ff_it->first].end(); e_it++) {
if (std::regex_match(srcs[i], *e_it)) {
exempt = true;
break;
@@ -419,7 +457,7 @@
}
if (!exempt) {
instances[ff_it->first].insert(lcnt);
- ret = true;
+ ret = 1;
}
}
}
@@ -430,8 +468,8 @@
for (i_it = instances.begin(); i_it != instances.end(); i_it++) {
std::set<int>::iterator num_it;
for (num_it = i_it->second.begin(); num_it != i_it->second.end();
num_it++) {
- std::string lstr = srcs[i].substr(l.path_root.length()+1) +
std::string(" matches ") + i_it->first + std::string(" on line ") +
std::to_string(*num_it) + std::string("\n");
- l.api_log.push_back(lstr);
+ std::string lstr = srcs[i].substr(r.path_root.length()+1) +
std::string(" has ") + i_it->first + std::string(" on line ") +
std::to_string(*num_it) + std::string("\n");
+ r.api_log.push_back(lstr);
}
}
}
@@ -449,72 +487,14 @@
int
-platform_symbols(repo_log_t &l, std::vector<std::string> &log,
std::vector<std::string> &srcs)
+platform_symbols(repo_info_t &r, std::vector<std::string> &log,
std::vector<std::string> &srcs)
{
- const char *platforms[] {
- "AIX",
- "APPLE",
- "CYGWIN",
- "DARWIN",
- "FREEBSD",
- "HAIKU",
- "HPUX",
- "LINUX",
- "MINGW",
- "MSDOS",
- "QNX",
- "SGI",
- "SOLARIS",
- "SUN",
- "SUNOS",
- "SVR4",
- "SYSV",
- "ULTRIX",
- "UNIX",
- "VMS",
- "WIN16",
- "WIN32",
- "WIN64",
- "WINE",
- "WINNT",
- NULL
- };
- std::map<std::pair<std::string, std::string>, std::regex> platform_checks;
- int cnt = 0;
- const char *rf = platforms[cnt];
- while (rf) {
- cnt++;
- std::string p_upper(rf);
- std::string p_lower = p_upper;
- std::transform(p_lower.begin(), p_lower.end(), p_lower.begin(),
[](unsigned char c){ return std::tolower(c); });
- std::string pregex_str =
std::string("^[[:space:]#]*(if|IF).*[[:space:](]_*(") + p_lower +
std::string("|") + p_upper + std::string(")_*([[:space:]]|[)]|$).*$");
- platform_checks[std::make_pair(p_lower, p_upper)] =
std::regex(pregex_str);
- rf = platforms[cnt];
- }
-
- const char *file_exemptions[] {
- ".*/pstdint[.]h$",
- ".*/pinttypes[.]h$",
- ".*/uce-dirent[.]h$",
- NULL
- };
-
- std::vector<std::regex> file_filters;
- cnt = 0;
- rf = file_exemptions[cnt];
- while (rf) {
- file_filters.push_back(std::regex(rf));
- cnt++;
- rf = file_exemptions[cnt];
- }
-
-
std::map<std::string, std::vector<platform_entry>> instances;
for (size_t i = 0; i < srcs.size(); i++) {
bool skip = false;
- for (size_t j = 0; j < file_filters.size(); j++) {
- if (std::regex_match(srcs[i], file_filters[j])) {
+ for (size_t j = 0; j < r.platform_file_filters.size(); j++) {
+ if (std::regex_match(srcs[i], r.platform_file_filters[j])) {
skip = true;
break;
}
@@ -538,7 +518,7 @@
lcnt++;
std::map<std::pair<std::string, std::string>, std::regex>::iterator
p_it;
- for (p_it = platform_checks.begin(); p_it != platform_checks.end();
p_it++) {
+ for (p_it = r.platform_checks.begin(); p_it !=
r.platform_checks.end(); p_it++) {
if (!std::strstr(sline.c_str(), p_it->first.first.c_str()) &&
!std::strstr(sline.c_str(), p_it->first.second.c_str())) {
// Only try the full regex if strstr says there is a chance
continue;
@@ -547,7 +527,7 @@
//std::cout << "match on line: " << sline << "\n";
platform_entry pe;
pe.symbol = p_it->first.second;
- pe.file = srcs[i].substr(l.path_root.length()+1);
+ pe.file = srcs[i].substr(r.path_root.length()+1);
pe.line_num = lcnt;
pe.line = sline;
instances[p_it->first.second].push_back(pe);
@@ -578,8 +558,9 @@
return -1;
}
- repo_log_t repo_log;
- repo_log.path_root = std::string(argv[2]);
+ repo_info_t repo_info;
+ repo_info.path_root = std::string(argv[2]);
+ regex_init(repo_info);
std::string sfile;
std::ifstream src_file_stream;
@@ -655,81 +636,72 @@
int ret = 0;
- if (bio_redundant_check(repo_log, src_files)) {
- ret = -1;
- }
+ ret += bio_redundant_check(repo_info, inc_files);
+ ret += bio_redundant_check(repo_info, src_files);
+ ret += bnetwork_redundant_check(repo_info, inc_files);
+ ret += bnetwork_redundant_check(repo_info, src_files);
+ ret += common_include_first(repo_info, src_files);
+ ret += api_usage(repo_info, src_files);
- if (bnetwork_redundant_check(repo_log, src_files)) {
- ret = -1;
- }
-
- if (common_include_first(repo_log, src_files)) {
- ret = -1;
- }
-
- if (api_usage(repo_log, src_files)) {
- ret = -1;
- }
-
- int h_cnt = platform_symbols(repo_log, repo_log.symbol_inc_log, inc_files);
- int s_cnt = platform_symbols(repo_log, repo_log.symbol_src_log, src_files);
- int b_cnt = platform_symbols(repo_log, repo_log.symbol_bld_log,
build_files);
+ int h_cnt = platform_symbols(repo_info, repo_info.symbol_inc_log,
inc_files);
+ int s_cnt = platform_symbols(repo_info, repo_info.symbol_src_log,
src_files);
+ int b_cnt = platform_symbols(repo_info, repo_info.symbol_bld_log,
build_files);
int psym_cnt = h_cnt + s_cnt + b_cnt;
int expected_psym_cnt = EXPECTED_PLATFORM_SYMBOLS;
if (psym_cnt > expected_psym_cnt) {
std::cout << "FAILURE: expected " << expected_psym_cnt << " platform
symbols, found " << psym_cnt << "\n";
- ret = -1;
+ ret = 1;
}
- if (ret == -1) {
- std::sort(repo_log.api_log.begin(), repo_log.api_log.end());
- std::sort(repo_log.bio_log.begin(), repo_log.bio_log.end());
- std::sort(repo_log.bnet_log.begin(), repo_log.bnet_log.end());
- std::sort(repo_log.common_log.begin(), repo_log.common_log.end());
- std::sort(repo_log.symbol_inc_log.begin(),
repo_log.symbol_inc_log.end());
- std::sort(repo_log.symbol_src_log.begin(),
repo_log.symbol_src_log.end());
- std::sort(repo_log.symbol_bld_log.begin(),
repo_log.symbol_bld_log.end());
+ if (ret) {
+ std::sort(repo_info.api_log.begin(), repo_info.api_log.end());
+ std::sort(repo_info.bio_log.begin(), repo_info.bio_log.end());
+ std::sort(repo_info.bnet_log.begin(), repo_info.bnet_log.end());
+ std::sort(repo_info.common_log.begin(), repo_info.common_log.end());
+ std::sort(repo_info.symbol_inc_log.begin(),
repo_info.symbol_inc_log.end());
+ std::sort(repo_info.symbol_src_log.begin(),
repo_info.symbol_src_log.end());
+ std::sort(repo_info.symbol_bld_log.begin(),
repo_info.symbol_bld_log.end());
- if (repo_log.api_log.size()) {
- std::cout << "\nFound " << repo_log.api_log.size() << " instances
of unguarded API usage:\n";
- for (size_t i = 0; i < repo_log.api_log.size(); i++) {
- std::cout << repo_log.api_log[i];
+ if (repo_info.api_log.size()) {
+ std::cout << "\nFound " << repo_info.api_log.size() << " instances
of unguarded API usage:\n";
+ for (size_t i = 0; i < repo_info.api_log.size(); i++) {
+ std::cout << repo_info.api_log[i];
}
}
- if (repo_log.bio_log.size()) {
- std::cout << "\nFound " << repo_log.bio_log.size() << " instances
of redundant header inclusions in files using bio.h:\n";
- for (size_t i = 0; i < repo_log.bio_log.size(); i++) {
- std::cout << repo_log.bio_log[i];
+ if (repo_info.bio_log.size()) {
+ std::cout << "\nFound " << repo_info.bio_log.size() << " instances
of redundant header inclusions in files using bio.h:\n";
+ for (size_t i = 0; i < repo_info.bio_log.size(); i++) {
+ std::cout << repo_info.bio_log[i];
}
}
- if (repo_log.bnet_log.size()) {
- std::cout << "\nFound " << repo_log.bnet_log.size() << " instances
of redundant header inclusions in files using bnetwork.h:\n";
- for (size_t i = 0; i < repo_log.bnet_log.size(); i++) {
- std::cout << repo_log.bnet_log[i];
+ if (repo_info.bnet_log.size()) {
+ std::cout << "\nFound " << repo_info.bnet_log.size() << " instances
of redundant header inclusions in files using bnetwork.h:\n";
+ for (size_t i = 0; i < repo_info.bnet_log.size(); i++) {
+ std::cout << repo_info.bnet_log[i];
}
}
- if (repo_log.common_log.size()) {
- std::cout << "\nFound " << repo_log.common_log.size() << "
instances of files using common.h with out-of-order inclusions:\n";
- for (size_t i = 0; i < repo_log.common_log.size(); i++) {
- std::cout << repo_log.common_log[i];
+ if (repo_info.common_log.size()) {
+ std::cout << "\nFound " << repo_info.common_log.size() << "
instances of files using common.h with out-of-order inclusions:\n";
+ for (size_t i = 0; i < repo_info.common_log.size(); i++) {
+ std::cout << repo_info.common_log[i];
}
}
- if (repo_log.symbol_inc_log.size()) {
- std::cout << "\nFound " << repo_log.symbol_inc_log.size() << "
instances of platform symbol usage in header files:\n";
- for (size_t i = 0; i < repo_log.symbol_inc_log.size(); i++) {
- std::cout << repo_log.symbol_inc_log[i];
+ if (repo_info.symbol_inc_log.size()) {
+ std::cout << "\nFound " << repo_info.symbol_inc_log.size() << "
instances of platform symbol usage in header files:\n";
+ for (size_t i = 0; i < repo_info.symbol_inc_log.size(); i++) {
+ std::cout << repo_info.symbol_inc_log[i];
}
}
- if (repo_log.symbol_src_log.size()) {
- std::cout << "\nFound " << repo_log.symbol_src_log.size() << "
instances of platform symbol usage in source files:\n";
- for (size_t i = 0; i < repo_log.symbol_src_log.size(); i++) {
- std::cout << repo_log.symbol_src_log[i];
+ if (repo_info.symbol_src_log.size()) {
+ std::cout << "\nFound " << repo_info.symbol_src_log.size() << "
instances of platform symbol usage in source files:\n";
+ for (size_t i = 0; i < repo_info.symbol_src_log.size(); i++) {
+ std::cout << repo_info.symbol_src_log[i];
}
}
- if (repo_log.symbol_bld_log.size()) {
- std::cout << "\nFound " << repo_log.symbol_bld_log.size() << "
instances of platform symbol usage in build files:\n";
- for (size_t i = 0; i < repo_log.symbol_bld_log.size(); i++) {
- std::cout << repo_log.symbol_bld_log[i];
+ if (repo_info.symbol_bld_log.size()) {
+ std::cout << "\nFound " << repo_info.symbol_bld_log.size() << "
instances of platform symbol usage in build files:\n";
+ for (size_t i = 0; i < repo_info.symbol_bld_log.size(); i++) {
+ std::cout << repo_info.symbol_bld_log[i];
}
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits