Skip to content

Commit 23e95f3

Browse files
authored
Merge pull request #60 from cgkantidis/main
2 parents 44a7a29 + bb6b473 commit 23e95f3

File tree

4 files changed

+13
-39
lines changed

4 files changed

+13
-39
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ find_package(nlohmann_json 3.11.3 REQUIRED)
2727
target_link_libraries(duplo PRIVATE nlohmann_json::nlohmann_json)
2828

2929
if(NOT MSVC)
30-
target_compile_options(duplo PRIVATE -Wall -Werror)
30+
target_compile_options(duplo PRIVATE -Wall -Wextra -pedantic -Werror)
3131
endif()

src/JsonExporter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ void JsonExporter::WriteHeader() {
1515
}
1616

1717
void JsonExporter::WriteFooter(
18-
const Options& options,
19-
int files,
20-
long locsTotal,
21-
const ProcessResult& processResult) {
18+
const Options& /*options*/,
19+
int /*files*/,
20+
long /*locsTotal*/,
21+
const ProcessResult& /*processResult*/) {
2222
Out() << m_json.dump(2);
2323
}
2424

src/StringUtil.cpp

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,39 +8,13 @@ namespace {
88
}
99

1010
std::string StringUtil::Trim(const std::string& input) {
11-
// If string is empty, there is nothing to look for.
12-
if (input.length() == 0) {
11+
auto l_idx = input.find_first_not_of(" \t");
12+
if (l_idx == std::string::npos) {
1313
return "";
1414
}
1515

16-
// Set up temporary
17-
std::string final = input;
18-
19-
// Remove spaces at beginning
20-
decltype(input.length()) i = 0;
21-
while (i < input.length() && input[i] <= ' ') {
22-
i++;
23-
}
24-
25-
// String full of spaces, return nothing.
26-
if (i >= input.length()) {
27-
return "";
28-
}
29-
30-
if (i > 0) {
31-
final = input.substr(i, input.length() - i);
32-
}
33-
34-
// Remove spaces at end
35-
i = final.length() - 1;
36-
while (i >= 0 && final[i] <= ' ') {
37-
i--;
38-
}
39-
40-
final = final.substr(0, i + 1);
41-
42-
// Return the new string
43-
return final;
16+
auto r_idx = input.find_last_not_of(" \t");
17+
return input.substr(l_idx, r_idx - l_idx + 1);
4418
}
4519

4620
int StringUtil::Split(const std::string& input, const std::string& delimiter, std::vector<std::string>& results, bool doTrim) {

src/XmlExporter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ void XmlExporter::WriteHeader() {
2020
}
2121

2222
void XmlExporter::WriteFooter(
23-
const Options& options,
24-
int files,
25-
long locsTotal,
26-
const ProcessResult& processResult) {
23+
const Options& /*options*/,
24+
int /*files*/,
25+
long /*locsTotal*/,
26+
const ProcessResult& /*processResult*/) {
2727
Out()
2828
<< "</duplo>"
2929
<< std::endl;

0 commit comments

Comments
 (0)