Revision: 75799
http://sourceforge.net/p/brlcad/code/75799
Author: starseeker
Date: 2020-05-14 14:31:51 +0000 (Thu, 14 May 2020)
Log Message:
-----------
Try using bu_mapped_file, more strstr prelim checks.
Modified Paths:
--------------
brlcad/trunk/regress/repository/CMakeLists.txt
brlcad/trunk/regress/repository/repocheck.cpp
Modified: brlcad/trunk/regress/repository/CMakeLists.txt
===================================================================
--- brlcad/trunk/regress/repository/CMakeLists.txt 2020-05-14 14:04:14 UTC
(rev 75798)
+++ brlcad/trunk/regress/repository/CMakeLists.txt 2020-05-14 14:31:51 UTC
(rev 75799)
@@ -1,7 +1,7 @@
#set(REPOCHECK_TEST 1)
if (DEFINED REPOCHECK_TEST)
add_executable(repocheck repocheck.cpp)
- target_link_libraries(repocheck ${CMAKE_THREAD_LIBS_INIT})
+ target_link_libraries(repocheck libbu ${CMAKE_THREAD_LIBS_INIT})
if (O3_COMPILER_FLAG)
# This check benefits greatly from optimization. If we have the O3 flag,
use
# it - whether or not the standard build settings would add it.
Modified: brlcad/trunk/regress/repository/repocheck.cpp
===================================================================
--- brlcad/trunk/regress/repository/repocheck.cpp 2020-05-14 14:04:14 UTC
(rev 75798)
+++ brlcad/trunk/regress/repository/repocheck.cpp 2020-05-14 14:31:51 UTC
(rev 75799)
@@ -39,6 +39,8 @@
*
*/
+#include "common.h"
+
#include <cstdio>
#include <algorithm>
#include <locale>
@@ -50,6 +52,9 @@
#include <map>
#include <sstream>
#include <string>
+
+#include "bu/mapped_file.h"
+
#define MAX_LINES_CHECK 500
#define EXPECTED_PLATFORM_SYMBOLS 205
@@ -162,9 +167,9 @@
/* 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/.*",
+ "CONFIG_CONTROL_DESIGN.*", "bu/log[.]h$", "bu/path[.]h$",
+ "bu/str[.]h$", "cursor[.]c$", "ttcp[.]c$",
+ "misc/CMake/compat/.*",
NULL
};
cnt = 0;
@@ -247,9 +252,6 @@
-
-
-
int
bio_redundant_check(repo_info_t &r, std::vector<std::string> &srcs)
{
@@ -260,13 +262,23 @@
std::map<std::string, std::set<int>> match_line_nums;
- std::ifstream fs;
- fs.open(srcs[i]);
- if (!fs.is_open()) {
+
+ struct bu_mapped_file *ifile = bu_open_mapped_file(srcs[i].c_str(),
"bio.h candidate file");
+ if (!ifile) {
std::cerr << "Unable to open " << srcs[i] << " for reading,
skipping\n";
continue;
}
+ // If we have anything in the buffer that looks like it might be
+ // of interest, continue - otherwise we're done
+ if (!std::strstr((const char *)ifile->buf, "bio.h")) {
+ bu_close_mapped_file(ifile);
+ continue;
+ }
+
+ std::string fbuff((char *)ifile->buf);
+ std::istringstream fs(fbuff);
+
int lcnt = 0;
bool have_bio = false;
while (std::getline(fs, sline) && lcnt < MAX_LINES_CHECK) {
@@ -285,6 +297,8 @@
}
}
+ bu_close_mapped_file(ifile);
+
if (have_bio) {
std::map<std::string, std::set<int>>::iterator m_it;
for (m_it = match_line_nums.begin(); m_it != match_line_nums.end();
m_it++) {
@@ -303,6 +317,7 @@
return ret;
}
+
int
bnetwork_redundant_check(repo_info_t &r, std::vector<std::string> &srcs)
{
@@ -313,13 +328,22 @@
std::map<std::string, std::set<int>> match_line_nums;
- std::ifstream fs;
- fs.open(srcs[i]);
- if (!fs.is_open()) {
+ struct bu_mapped_file *ifile = bu_open_mapped_file(srcs[i].c_str(),
"bio.h candidate file");
+ if (!ifile) {
std::cerr << "Unable to open " << srcs[i] << " for reading,
skipping\n";
continue;
}
+ // If we have anything in the buffer that looks like it might be
+ // of interest, continue - otherwise we're done
+ if (!std::strstr((const char *)ifile->buf, "bnetwork.h")) {
+ bu_close_mapped_file(ifile);
+ continue;
+ }
+
+ std::string fbuff((char *)ifile->buf);
+ std::istringstream fs(fbuff);
+
int lcnt = 0;
bool have_bnetwork = false;
while (std::getline(fs, sline) && lcnt < MAX_LINES_CHECK) {
@@ -338,6 +362,8 @@
}
}
+ bu_close_mapped_file(ifile);
+
if (have_bnetwork) {
std::map<std::string, std::set<int>>::iterator m_it;
for (m_it = match_line_nums.begin(); m_it != match_line_nums.end();
m_it++) {
@@ -357,7 +383,6 @@
}
-
int
common_include_first(repo_info_t &r, std::vector<std::string> &srcs)
{
@@ -375,13 +400,22 @@
continue;
}
- std::ifstream fs;
- fs.open(srcs[i]);
- if (!fs.is_open()) {
+ struct bu_mapped_file *ifile = bu_open_mapped_file(srcs[i].c_str(),
"bio.h candidate file");
+ if (!ifile) {
std::cerr << "Unable to open " << srcs[i] << " for reading,
skipping\n";
continue;
}
+ // If we have anything in the buffer that looks like it might be
+ // of interest, continue - otherwise we're done
+ if (!std::strstr((const char *)ifile->buf, "common.h")) {
+ bu_close_mapped_file(ifile);
+ continue;
+ }
+
+ std::string fbuff((char *)ifile->buf);
+ std::istringstream fs(fbuff);
+
int lcnt = 0;
int first_inc_line = -1;
bool have_inc = false;
@@ -401,6 +435,8 @@
first_inc_line = lcnt;
}
}
+
+ bu_close_mapped_file(ifile);
}
@@ -424,13 +460,16 @@
continue;
}
- std::ifstream fs;
- fs.open(srcs[i]);
- if (!fs.is_open()) {
+ struct bu_mapped_file *ifile = bu_open_mapped_file(srcs[i].c_str(),
"bio.h candidate file");
+ if (!ifile) {
std::cerr << "Unable to open " << srcs[i] << " for reading,
skipping\n";
continue;
}
+ std::string fbuff((char *)ifile->buf);
+ std::istringstream fs(fbuff);
+
+
std::map<std::string, std::set<int>> instances;
int lcnt = 0;
@@ -463,6 +502,8 @@
}
}
+ bu_close_mapped_file(ifile);
+
std::map<std::string, std::set<int>>::iterator i_it;
for (i_it = instances.begin(); i_it != instances.end(); i_it++) {
@@ -503,13 +544,15 @@
continue;
}
- std::ifstream fs;
- fs.open(srcs[i]);
- if (!fs.is_open()) {
+ struct bu_mapped_file *ifile = bu_open_mapped_file(srcs[i].c_str(),
"bio.h candidate file");
+ if (!ifile) {
std::cerr << "Unable to open " << srcs[i] << " for reading,
skipping\n";
continue;
}
+ std::string fbuff((char *)ifile->buf);
+ std::istringstream fs(fbuff);
+
//std::cout << "Reading " << srcs[i] << "\n";
int lcnt = 0;
@@ -534,6 +577,8 @@
}
}
}
+
+ bu_close_mapped_file(ifile);
}
std::map<std::string, std::vector<platform_entry>>::iterator m_it;
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