39
39
class Pcre2MatchContextPtr {
40
40
public:
41
41
Pcre2MatchContextPtr ()
42
- : m_match_context(pcre2_match_context_create(NULL )) {}
42
+ : m_match_context(pcre2_match_context_create(nullptr )) {}
43
43
44
44
Pcre2MatchContextPtr (const Pcre2MatchContextPtr&) = delete ;
45
45
Pcre2MatchContextPtr& operator =(const Pcre2MatchContextPtr&) = delete ;
@@ -48,7 +48,7 @@ class Pcre2MatchContextPtr {
48
48
pcre2_match_context_free (m_match_context);
49
49
}
50
50
51
- operator pcre2_match_context*() const {
51
+ explicit operator pcre2_match_context*() const {
52
52
return m_match_context;
53
53
}
54
54
@@ -98,18 +98,18 @@ Regex::Regex(const std::string& pattern_, bool ignoreCase)
98
98
int errornumber = 0 ;
99
99
PCRE2_SIZE erroroffset = 0 ;
100
100
m_pc = pcre2_compile (pcre2_pattern, PCRE2_ZERO_TERMINATED,
101
- pcre2_options, &errornumber, &erroroffset, NULL );
101
+ pcre2_options, &errornumber, &erroroffset, nullptr );
102
102
m_pcje = pcre2_jit_compile (m_pc, PCRE2_JIT_COMPLETE);
103
103
#else
104
- const char *errptr = NULL ;
104
+ const char *errptr = nullptr ;
105
105
int erroffset;
106
106
int flags = (PCRE_DOTALL|PCRE_MULTILINE);
107
107
108
108
if (ignoreCase == true ) {
109
109
flags |= PCRE_CASELESS;
110
110
}
111
111
m_pc = pcre_compile (pattern.c_str (), flags,
112
- &errptr, &erroffset, NULL );
112
+ &errptr, &erroffset, nullptr );
113
113
114
114
m_pce = pcre_study (m_pc, pcre_study_opt, &errptr);
115
115
#endif
@@ -120,17 +120,17 @@ Regex::~Regex() {
120
120
#ifndef WITH_PCRE
121
121
pcre2_code_free (m_pc);
122
122
#else
123
- if (m_pc != NULL ) {
123
+ if (m_pc != nullptr ) {
124
124
pcre_free (m_pc);
125
- m_pc = NULL ;
125
+ m_pc = nullptr ;
126
126
}
127
- if (m_pce != NULL ) {
127
+ if (m_pce != nullptr ) {
128
128
#if PCRE_HAVE_JIT
129
129
pcre_free_study (m_pce);
130
130
#else
131
131
pcre_free (m_pce);
132
132
#endif
133
- m_pce = NULL ;
133
+ m_pce = nullptr ;
134
134
}
135
135
#endif
136
136
}
@@ -143,16 +143,16 @@ std::list<SMatch> Regex::searchAll(const std::string& s) const {
143
143
PCRE2_SPTR pcre2_s = reinterpret_cast <PCRE2_SPTR>(s.c_str ());
144
144
PCRE2_SIZE offset = 0 ;
145
145
146
- pcre2_match_data *match_data = pcre2_match_data_create_from_pattern (m_pc, NULL );
146
+ pcre2_match_data *match_data = pcre2_match_data_create_from_pattern (m_pc, nullptr );
147
147
do {
148
148
if (m_pcje == 0 ) {
149
149
rc = pcre2_jit_match (m_pc, pcre2_s, s.length (),
150
- offset, 0 , match_data, NULL );
150
+ offset, 0 , match_data, nullptr );
151
151
}
152
152
153
153
if (m_pcje != 0 || rc == PCRE2_ERROR_JIT_STACKLIMIT) {
154
154
rc = pcre2_match (m_pc, pcre2_s, s.length (),
155
- offset, PCRE2_NO_JIT, match_data, NULL );
155
+ offset, PCRE2_NO_JIT, match_data, nullptr );
156
156
}
157
157
const PCRE2_SIZE *ovector = pcre2_get_ovector_pointer (match_data);
158
158
#else
@@ -194,18 +194,18 @@ RegexResult Regex::searchOneMatch(const std::string& s, std::vector<SMatchCaptur
194
194
Pcre2MatchContextPtr match_context;
195
195
if (match_limit > 0 ) {
196
196
// TODO: What if setting the match limit fails?
197
- pcre2_set_match_limit (match_context, match_limit);
197
+ pcre2_set_match_limit (static_cast <pcre2_match_context*>( match_context) , match_limit);
198
198
}
199
199
200
200
PCRE2_SPTR pcre2_s = reinterpret_cast <PCRE2_SPTR>(s.c_str ());
201
- pcre2_match_data *match_data = pcre2_match_data_create_from_pattern (m_pc, NULL );
201
+ pcre2_match_data *match_data = pcre2_match_data_create_from_pattern (m_pc, nullptr );
202
202
int rc = 0 ;
203
203
if (m_pcje == 0 ) {
204
- rc = pcre2_jit_match (m_pc, pcre2_s, s.length (), 0 , 0 , match_data, match_context);
204
+ rc = pcre2_jit_match (m_pc, pcre2_s, s.length (), 0 , 0 , match_data, static_cast <pcre2_match_context*>( match_context) );
205
205
}
206
206
207
207
if (m_pcje != 0 || rc == PCRE2_ERROR_JIT_STACKLIMIT) {
208
- rc = pcre2_match (m_pc, pcre2_s, s.length (), 0 , PCRE2_NO_JIT, match_data, match_context);
208
+ rc = pcre2_match (m_pc, pcre2_s, s.length (), 0 , PCRE2_NO_JIT, match_data, static_cast <pcre2_match_context*>( match_context) );
209
209
}
210
210
const PCRE2_SIZE *ovector = pcre2_get_ovector_pointer (match_data);
211
211
#else
@@ -214,7 +214,7 @@ RegexResult Regex::searchOneMatch(const std::string& s, std::vector<SMatchCaptur
214
214
pcre_extra local_pce;
215
215
pcre_extra *pce = m_pce;
216
216
217
- if (m_pce != NULL && match_limit > 0 ) {
217
+ if (m_pce != nullptr && match_limit > 0 ) {
218
218
local_pce = *m_pce;
219
219
local_pce.match_limit = match_limit;
220
220
local_pce.flags |= PCRE_EXTRA_MATCH_LIMIT;
@@ -247,28 +247,28 @@ RegexResult Regex::searchGlobal(const std::string& s, std::vector<SMatchCapture>
247
247
Pcre2MatchContextPtr match_context;
248
248
if (match_limit > 0 ) {
249
249
// TODO: What if setting the match limit fails?
250
- pcre2_set_match_limit (match_context, match_limit);
250
+ pcre2_set_match_limit (static_cast <pcre2_match_context*>( match_context) , match_limit);
251
251
}
252
252
253
253
PCRE2_SPTR pcre2_s = reinterpret_cast <PCRE2_SPTR>(s.c_str ());
254
254
PCRE2_SIZE startOffset = 0 ;
255
255
256
- pcre2_match_data *match_data = pcre2_match_data_create_from_pattern (m_pc, NULL );
256
+ pcre2_match_data *match_data = pcre2_match_data_create_from_pattern (m_pc, nullptr );
257
257
while (startOffset <= s.length ()) {
258
258
uint32_t pcre2_options = 0 ;
259
259
if (prev_match_zero_length) {
260
260
pcre2_options = PCRE2_NOTEMPTY_ATSTART | PCRE2_ANCHORED;
261
261
}
262
262
int rc = pcre2_match (m_pc, pcre2_s, s.length (),
263
- startOffset, pcre2_options, match_data, match_context);
263
+ startOffset, pcre2_options, match_data, static_cast <pcre2_match_context*>( match_context) );
264
264
const PCRE2_SIZE *ovector = pcre2_get_ovector_pointer (match_data);
265
265
266
266
#else
267
267
const char *subject = s.c_str ();
268
268
pcre_extra local_pce;
269
269
pcre_extra *pce = m_pce;
270
270
271
- if (m_pce != NULL && match_limit > 0 ) {
271
+ if (m_pce != nullptr && match_limit > 0 ) {
272
272
local_pce = *m_pce;
273
273
local_pce.match_limit = match_limit;
274
274
local_pce.flags |= PCRE_EXTRA_MATCH_LIMIT;
@@ -346,16 +346,16 @@ RegexResult Regex::searchGlobal(const std::string& s, std::vector<SMatchCapture>
346
346
int Regex::search (const std::string& s, SMatch *match) const {
347
347
#ifndef WITH_PCRE
348
348
PCRE2_SPTR pcre2_s = reinterpret_cast <PCRE2_SPTR>(s.c_str ());
349
- pcre2_match_data *match_data = pcre2_match_data_create_from_pattern (m_pc, NULL );
349
+ pcre2_match_data *match_data = pcre2_match_data_create_from_pattern (m_pc, nullptr );
350
350
int ret = 0 ;
351
351
if (m_pcje == 0 ) {
352
352
ret = pcre2_match (m_pc, pcre2_s, s.length (),
353
- 0 , 0 , match_data, NULL ) > 0 ;
353
+ 0 , 0 , match_data, nullptr ) > 0 ;
354
354
}
355
355
356
356
if (m_pcje != 0 || ret == PCRE2_ERROR_JIT_STACKLIMIT) {
357
357
ret = pcre2_match (m_pc, pcre2_s, s.length (),
358
- 0 , PCRE2_NO_JIT, match_data, NULL ) > 0 ;
358
+ 0 , PCRE2_NO_JIT, match_data, nullptr ) > 0 ;
359
359
}
360
360
if (ret > 0 ) { // match
361
361
PCRE2_SIZE *ovector = pcre2_get_ovector_pointer (match_data);
@@ -380,14 +380,14 @@ int Regex::search(const std::string& s, SMatch *match) const {
380
380
int Regex::search (const std::string& s) const {
381
381
#ifndef WITH_PCRE
382
382
PCRE2_SPTR pcre2_s = reinterpret_cast <PCRE2_SPTR>(s.c_str ());
383
- pcre2_match_data *match_data = pcre2_match_data_create_from_pattern (m_pc, NULL );
383
+ pcre2_match_data *match_data = pcre2_match_data_create_from_pattern (m_pc, nullptr );
384
384
int rc = 0 ;
385
385
if (m_pcje == 0 ) {
386
- rc = pcre2_jit_match (m_pc, pcre2_s, s.length (), 0 , 0 , match_data, NULL );
386
+ rc = pcre2_jit_match (m_pc, pcre2_s, s.length (), 0 , 0 , match_data, nullptr );
387
387
}
388
388
389
389
if (m_pcje != 0 || rc == PCRE2_ERROR_JIT_STACKLIMIT) {
390
- rc = pcre2_match (m_pc, pcre2_s, s.length (), 0 , PCRE2_NO_JIT, match_data, NULL );
390
+ rc = pcre2_match (m_pc, pcre2_s, s.length (), 0 , PCRE2_NO_JIT, match_data, nullptr );
391
391
}
392
392
pcre2_match_data_free (match_data);
393
393
if (rc > 0 ) {
0 commit comments