Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcbc53b8

Browse files
committed
Compiler Warnungen aktiviert.
1 parent3aaeb95 commitcbc53b8

File tree

9 files changed

+31
-22
lines changed

9 files changed

+31
-22
lines changed

‎CMakeLists.txt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ target_compile_features(pcre2 PUBLIC cxx_std_17)
3030
target_compile_features(pcre_jitPUBLIC cxx_std_17)
3131
target_compile_features(pcre2_jitPUBLIC cxx_std_17)
3232

33+
target_compile_options(stdPRIVATE -Wall -Wextra -Wmost -pedantic -Wconversion -Wfloat-equal -Wold-style-cast)
34+
target_compile_options(boostPRIVATE -Wall -Wextra -Wmost -pedantic -Wconversion -Wfloat-equal -Wold-style-cast)
35+
target_compile_options(re2PRIVATE -Wall -Wextra -Wmost -pedantic -Wconversion -Wfloat-equal -Wold-style-cast)
36+
target_compile_options(hyperscanPRIVATE -Wall -Wextra -Wmost -pedantic -Wconversion -Wfloat-equal -Wold-style-cast)
37+
target_compile_options(pcrePRIVATE -Wall -Wextra -Wmost -pedantic -Wconversion -Wfloat-equal -Wold-style-cast)
38+
target_compile_options(pcre2PRIVATE -Wall -Wextra -Wmost -pedantic -Wconversion -Wfloat-equal)
39+
target_compile_options(pcre_jitPRIVATE -Wall -Wextra -Wmost -pedantic -Wconversion -Wfloat-equal -Wold-style-cast)
40+
target_compile_options(pcre2_jitPRIVATE -Wall -Wextra -Wmost -pedantic -Wconversion -Wfloat-equal)
41+
3342
if(CMAKE_BUILD_TYPESTREQUAL"Release")
3443
target_compile_options(boostPRIVATE"-fvisibility=hidden")
3544
endif()

‎boost.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ int main()
2525
for (auto line : lines)
2626
if (boost::regex_match(line, m, re))
2727
if (m.size() >1)
28-
for (int i =1; i < m.size(); ++i)
28+
for (int i =1; i <static_cast<int>(m.size()); ++i)
2929
std::cout <<"MATCH" << i <<":\"" << m[i] <<"\"" << std::endl;
3030
}

‎hyperscan.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#include<string>
44
#include<vector>
55

6-
staticinteventHandler(unsignedint id,unsignedlonglong from,unsignedlonglong to,unsignedint flags,void* ctx)
6+
staticinteventHandler(unsignedint,unsignedlonglong from,unsignedlonglong to,unsignedint,void* ctx)
77
{
8-
std::string* s =(std::string*)ctx;
8+
std::string* s =static_cast<std::string*>(ctx);
99
std::cout <<"MATCH from" << from <<" to" << to <<" in:" << *s << std::endl;
1010
return0;
1111
}
@@ -46,7 +46,7 @@ int main()
4646
}
4747

4848
for (auto line : lines) {
49-
if (hs_scan(database, line.c_str(), line.length(),0, scratch, eventHandler, &line) != HS_SUCCESS) {
49+
if (hs_scan(database, line.c_str(),static_cast<unsignedint>(line.length()),0, scratch, eventHandler, &line) != HS_SUCCESS) {
5050
std::cout <<"Hyperscan scan error." << std::endl;
5151
hs_free_scratch(scratch);
5252
hs_free_database(database);

‎pcre.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@ int main()
4141

4242
for (auto line : lines) {
4343
int ovector[OVECCOUNT];
44-
constint rc =pcre_exec(re, sd, line.c_str(), line.size(),0,0, ovector, OVECCOUNT);
44+
constint rc =pcre_exec(re, sd, line.c_str(),static_cast<int>(line.size()),0,0, ovector, OVECCOUNT);
4545

4646
if (rc >1) {
4747
for (int i =1; i < rc; ++i) {
4848
constchar* substring_start = line.c_str() + ovector[2*i];
4949
constint substring_length = ovector[2*i +1] - ovector[2*i];
50-
const std::string_view s{substring_start,(std::size_t)substring_length};
50+
const std::string_view s{substring_start,static_cast<std::string_view::size_type>(substring_length)};
5151
std::cout <<"MATCH" << i <<":\"" << s <<"\"" << std::endl;
5252
}
5353
}

‎pcre2.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int main()
2424
int errorcode;
2525
PCRE2_SIZE erroroffset;
2626

27-
const PCRE2_SPTR pattern =(PCRE2_SPTR)R"(\[([^ ]{8}) \| ([^\]]{19})\] \((?:[^,]+, )?\d+\) [^ ]+ \[([^\]]+)\] RQST END \[[^\]]+\] *(\d+) ms)";
27+
const PCRE2_SPTR pattern =reinterpret_cast<PCRE2_SPTR>(R"(\[([^ ]{8}) \| ([^\]]{19})\] \((?:[^,]+, )?\d+\) [^ ]+ \[([^\]]+)\] RQST END \[[^\]]+\] *(\d+) ms)");
2828
pcre2_code* re =pcre2_compile(pattern, PCRE2_ZERO_TERMINATED,0, &errorcode, &erroroffset,nullptr);
2929

3030
if (!re) {
@@ -42,16 +42,16 @@ int main()
4242
}
4343

4444
for (auto line : lines) {
45-
const PCRE2_SPTR subject =(PCRE2_SPTR)line.c_str();
45+
const PCRE2_SPTR subject =reinterpret_cast<PCRE2_SPTR>(line.c_str());
4646
constint rc =pcre2_match(re, subject, line.size(),0,0, match_data,nullptr);
4747

4848
if (rc >1) {
4949
const PCRE2_SIZE* ovector =pcre2_get_ovector_pointer(match_data);
5050

5151
for (int i =1; i < rc; ++i) {
5252
const PCRE2_SPTR substring_start = subject + ovector[2*i];
53-
constint substring_length = ovector[2*i +1] - ovector[2*i];
54-
const std::string_view s{(constchar*)substring_start, (std::size_t)substring_length};
53+
constint substring_length =static_cast<int>(ovector[2*i +1] - ovector[2*i]);
54+
const std::string_view s{reinterpret_cast<constchar*>(substring_start),static_cast<std::string_view::size_type>(substring_length)};
5555
std::cout <<"MATCH" << i <<":\"" << s <<"\"" << std::endl;
5656
}
5757
}

‎pcre2_jit.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ int main()
2424
int errorcode;
2525
PCRE2_SIZE erroroffset;
2626

27-
const PCRE2_SPTR pattern =(PCRE2_SPTR)R"(\[([^ ]{8}) \| ([^\]]{19})\] \((?:[^,]+, )?\d+\) [^ ]+ \[([^\]]+)\] RQST END \[[^\]]+\] *(\d+) ms)";
27+
const PCRE2_SPTR pattern =reinterpret_cast<PCRE2_SPTR>(R"(\[([^ ]{8}) \| ([^\]]{19})\] \((?:[^,]+, )?\d+\) [^ ]+ \[([^\]]+)\] RQST END \[[^\]]+\] *(\d+) ms)");
2828
pcre2_code* re =pcre2_compile(pattern, PCRE2_ZERO_TERMINATED,0, &errorcode, &erroroffset,nullptr);
2929

3030
if (!re) {
@@ -65,16 +65,16 @@ int main()
6565
}
6666

6767
for (auto line : lines) {
68-
const PCRE2_SPTR subject =(PCRE2_SPTR)line.c_str();
68+
const PCRE2_SPTR subject =reinterpret_cast<PCRE2_SPTR>(line.c_str());
6969
constint rc =pcre2_jit_match(re, subject, line.size(),0,0, match_data, mcontext);
7070

7171
if (rc >1) {
7272
const PCRE2_SIZE* ovector =pcre2_get_ovector_pointer(match_data);
7373

7474
for (int i =1; i < rc; ++i) {
7575
const PCRE2_SPTR substring_start = subject + ovector[2*i];
76-
constint substring_length = ovector[2*i +1] - ovector[2*i];
77-
const std::string_view s{(constchar*)substring_start, (std::size_t)substring_length};
76+
constint substring_length =static_cast<int>(ovector[2*i +1] - ovector[2*i]);
77+
const std::string_view s{reinterpret_cast<constchar*>(substring_start),static_cast<std::string_view::size_type>(substring_length)};
7878
std::cout <<"MATCH" << i <<":\"" << s <<"\"" << std::endl;
7979
}
8080
}

‎pcre_jit.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ int main()
5050

5151
for (auto line : lines) {
5252
int ovector[OVECCOUNT];
53-
constint rc =pcre_jit_exec(re, sd, line.c_str(), line.size(),0,0, ovector, OVECCOUNT, jit_stack);
53+
constint rc =pcre_jit_exec(re, sd, line.c_str(),static_cast<int>(line.size()),0,0, ovector, OVECCOUNT, jit_stack);
5454

5555
if (rc >1) {
5656
for (int i =1; i < rc; ++i) {
5757
constchar* substring_start = line.c_str() + ovector[2*i];
5858
constint substring_length = ovector[2*i +1] - ovector[2*i];
59-
const std::string_view s{substring_start,(std::size_t)substring_length};
59+
const std::string_view s{substring_start,static_cast<std::string_view::size_type>(substring_length)};
6060
std::cout <<"MATCH" << i <<":\"" << s <<"\"" << std::endl;
6161
}
6262
}

‎re2.cpp‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ int main()
2525
if (!re.ok())
2626
return1;
2727

28-
std::size_t args_count = re.NumberOfCapturingGroups();
28+
std::size_t args_count =static_cast<std::size_t>(re.NumberOfCapturingGroups());
2929

3030
std::vector<RE2::Arg>arguments(args_count);
3131
std::vector<RE2::Arg*>arguments_ptrs(args_count);
3232
std::vector<std::string>results(args_count);
3333

34-
for (auto i =0; i < args_count; ++i) {
34+
for (std::size_t i =0; i < args_count; ++i) {
3535
arguments[i] = &results[i];
3636
arguments_ptrs[i] = &arguments[i];
3737
}
3838

3939
for (auto line : lines)
40-
if (RE2::FullMatchN(line, re, arguments_ptrs.data(), args_count))
41-
for (auto i =0; i < args_count; ++i)
40+
if (RE2::FullMatchN(line, re, arguments_ptrs.data(),static_cast<int>(args_count)))
41+
for (std::size_t i =0; i < args_count; ++i)
4242
std::cout <<"MATCH" << i <<":\"" << results[i] <<"\"" << std::endl;
4343
}

‎std.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ int main()
2525
for (auto line : lines)
2626
if (std::regex_match(line, m, re))
2727
if (m.size() >1)
28-
for (int i =1; i < m.size(); ++i)
29-
std::cout <<"MATCH" << i <<":\"" << m[i] <<"\"" << std::endl;
28+
for (int i =1; i <static_cast<int>(m.size()); ++i)
29+
std::cout <<"MATCH" << i <<":\"" << m[static_cast<std::size_t>(i)] <<"\"" << std::endl;
3030
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp