Skip to content

Commit 0e74aa5

Browse files
committed
Fix duplicate ware command on windows
* fixed function searching in folder to exclude folders * added handling of pragma once for file header in stylecheck
1 parent 9d6c9b9 commit 0e74aa5

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

cmake/OpenFLUIDTestScript.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ MESSAGE("TEST command: ${CMD}")
219219
EXECUTE_PROCESS(COMMAND ${CMD}
220220
RESULT_VARIABLE CMD_RESULT)
221221
IF(CMD_RESULT)
222-
MESSAGE(FATAL_ERROR "Test error")
222+
MESSAGE(FATAL_ERROR "Test error: ${CMD_RESULT}")
223223
ENDIF()
224224

225225

resources/tools/ofsrc-stylecheck.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -382,15 +382,16 @@ def checkHeaderGuard(self, Filename, Content):
382382

383383
ExpectedGuardName = '__OPENFLUID_'+MiddlePart+LastPart+'__'
384384

385-
386385
if ExpectedGuardName:
387-
Result = re.search( r'#ifndef '+re.escape(ExpectedGuardName)+'\s*\n#define '+re.escape(ExpectedGuardName), Content)
388-
if not Result:
389-
self.addProblem('HGRD',Filename,1,'missing or malformed header guard definition (expected',ExpectedGuardName+')')
390-
391-
Result = re.search( r'#endif /\* '+re.escape(ExpectedGuardName)+ r' \*/\s*\n', Content)
392-
if not Result:
393-
self.addProblem('HGRD',Filename,1,'missing or malformed header guard closing')
386+
ResultPragma = re.search( r'#pragma once', Content)
387+
if not ResultPragma:
388+
Result = re.search( r'#ifndef '+re.escape(ExpectedGuardName)+'\s*\n#define '+re.escape(ExpectedGuardName), Content)
389+
if not Result:
390+
self.addProblem('HGRD',Filename,1,'missing or malformed header guard definition (expected',ExpectedGuardName+')')
391+
392+
Result = re.search( r'#endif /\* '+re.escape(ExpectedGuardName)+ r' \*/\s*\n', Content)
393+
if not Result:
394+
self.addProblem('HGRD',Filename,1,'missing or malformed header guard closing')
394395

395396

396397

src/openfluid/tools/StringHelpers.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,21 @@ std::map<std::string, std::set<std::size_t>> searchInFolder(std::string Folder,
142142
for (const auto& E : std::filesystem::recursive_directory_iterator{Folder})
143143
{
144144
const openfluid::tools::Path FileObj = openfluid::tools::Path::fromStdPath(E.path());
145-
const std::string FileContent = openfluid::tools::Filesystem::readFile(FileObj);
146-
auto It = FileContent.find(String);
147-
148-
while (It != std::string::npos)
145+
if (FileObj.isFile())
149146
{
150-
const std::string PathString = E.path().string();
151-
if (OccurencesPosByFile.find(PathString) == OccurencesPosByFile.end())
147+
const std::string FileContent = openfluid::tools::Filesystem::readFile(FileObj);
148+
auto It = FileContent.find(String);
149+
150+
while (It != std::string::npos)
152151
{
153-
OccurencesPosByFile[PathString] = {};
152+
const std::string PathString = E.path().string();
153+
if (OccurencesPosByFile.find(PathString) == OccurencesPosByFile.end())
154+
{
155+
OccurencesPosByFile[PathString] = {};
156+
}
157+
OccurencesPosByFile[PathString].insert(It);
158+
It = FileContent.find(String, It+String.size());
154159
}
155-
OccurencesPosByFile[PathString].insert(It);
156-
It = FileContent.find(String, It+String.size());
157160
}
158161
}
159162
return OccurencesPosByFile;

src/openfluid/waresdev/WareSrcFactory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,8 @@ void replaceInFolder(std::string Folder, std::string PreviousWareId, std::string
387387
// ignore .git folder and '_' prefixed folders
388388
const auto WareIdPos = std::find(PathParts.begin(), PathParts.end(), NewWareId);
389389
bool IgnoredSubDir = false;
390-
for(auto It = WareIdPos; It <= PathParts.end(); It++ )
391-
{
390+
for(auto It = WareIdPos; It < PathParts.end(); It++ )
391+
{
392392
if ((*It)[0] == '_')
393393
{
394394
IgnoredSubDir = true;

0 commit comments

Comments
 (0)