3939class Pcre2MatchContextPtr {
4040 public:
4141 Pcre2MatchContextPtr ()
42- : m_match_context(pcre2_match_context_create(NULL )) {}
42+ : m_match_context(pcre2_match_context_create(nullptr )) {}
4343
4444 Pcre2MatchContextPtr (const Pcre2MatchContextPtr&) = delete ;
4545 Pcre2MatchContextPtr& operator =(const Pcre2MatchContextPtr&) = delete ;
@@ -48,7 +48,7 @@ class Pcre2MatchContextPtr {
4848 pcre2_match_context_free (m_match_context);
4949 }
5050
51- operator pcre2_match_context*() const {
51+ explicit operator pcre2_match_context*() const {
5252 return m_match_context;
5353 }
5454
@@ -98,18 +98,18 @@ Regex::Regex(const std::string& pattern_, bool ignoreCase)
9898 int errornumber = 0 ;
9999 PCRE2_SIZE erroroffset = 0 ;
100100 m_pc = pcre2_compile (pcre2_pattern, PCRE2_ZERO_TERMINATED,
101- pcre2_options, &errornumber, &erroroffset, NULL );
101+ pcre2_options, &errornumber, &erroroffset, nullptr );
102102 m_pcje = pcre2_jit_compile (m_pc, PCRE2_JIT_COMPLETE);
103103#else
104- const char *errptr = NULL ;
104+ const char *errptr = nullptr ;
105105 int erroffset;
106106 int flags = (PCRE_DOTALL|PCRE_MULTILINE);
107107
108108 if (ignoreCase == true ) {
109109 flags |= PCRE_CASELESS;
110110 }
111111 m_pc = pcre_compile (pattern.c_str (), flags,
112- &errptr, &erroffset, NULL );
112+ &errptr, &erroffset, nullptr );
113113
114114 m_pce = pcre_study (m_pc, pcre_study_opt, &errptr);
115115#endif
@@ -120,17 +120,17 @@ Regex::~Regex() {
120120#ifndef WITH_PCRE
121121 pcre2_code_free (m_pc);
122122#else
123- if (m_pc != NULL ) {
123+ if (m_pc != nullptr ) {
124124 pcre_free (m_pc);
125- m_pc = NULL ;
125+ m_pc = nullptr ;
126126 }
127- if (m_pce != NULL ) {
127+ if (m_pce != nullptr ) {
128128#if PCRE_HAVE_JIT
129129 pcre_free_study (m_pce);
130130#else
131131 pcre_free (m_pce);
132132#endif
133- m_pce = NULL ;
133+ m_pce = nullptr ;
134134 }
135135#endif
136136}
@@ -143,16 +143,16 @@ std::list<SMatch> Regex::searchAll(const std::string& s) const {
143143 PCRE2_SPTR pcre2_s = reinterpret_cast <PCRE2_SPTR>(s.c_str ());
144144 PCRE2_SIZE offset = 0 ;
145145
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 );
147147 do {
148148 if (m_pcje == 0 ) {
149149 rc = pcre2_jit_match (m_pc, pcre2_s, s.length (),
150- offset, 0 , match_data, NULL );
150+ offset, 0 , match_data, nullptr );
151151 }
152152
153153 if (m_pcje != 0 || rc == PCRE2_ERROR_JIT_STACKLIMIT) {
154154 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 );
156156 }
157157 const PCRE2_SIZE *ovector = pcre2_get_ovector_pointer (match_data);
158158#else
@@ -194,18 +194,18 @@ RegexResult Regex::searchOneMatch(const std::string& s, std::vector<SMatchCaptur
194194 Pcre2MatchContextPtr match_context;
195195 if (match_limit > 0 ) {
196196 // 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);
198198 }
199199
200200 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 );
202202 int rc = 0 ;
203203 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) );
205205 }
206206
207207 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) );
209209 }
210210 const PCRE2_SIZE *ovector = pcre2_get_ovector_pointer (match_data);
211211#else
@@ -214,7 +214,7 @@ RegexResult Regex::searchOneMatch(const std::string& s, std::vector<SMatchCaptur
214214 pcre_extra local_pce;
215215 pcre_extra *pce = m_pce;
216216
217- if (m_pce != NULL && match_limit > 0 ) {
217+ if (m_pce != nullptr && match_limit > 0 ) {
218218 local_pce = *m_pce;
219219 local_pce.match_limit = match_limit;
220220 local_pce.flags |= PCRE_EXTRA_MATCH_LIMIT;
@@ -247,28 +247,28 @@ RegexResult Regex::searchGlobal(const std::string& s, std::vector<SMatchCapture>
247247 Pcre2MatchContextPtr match_context;
248248 if (match_limit > 0 ) {
249249 // 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);
251251 }
252252
253253 PCRE2_SPTR pcre2_s = reinterpret_cast <PCRE2_SPTR>(s.c_str ());
254254 PCRE2_SIZE startOffset = 0 ;
255255
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 );
257257 while (startOffset <= s.length ()) {
258258 uint32_t pcre2_options = 0 ;
259259 if (prev_match_zero_length) {
260260 pcre2_options = PCRE2_NOTEMPTY_ATSTART | PCRE2_ANCHORED;
261261 }
262262 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) );
264264 const PCRE2_SIZE *ovector = pcre2_get_ovector_pointer (match_data);
265265
266266#else
267267 const char *subject = s.c_str ();
268268 pcre_extra local_pce;
269269 pcre_extra *pce = m_pce;
270270
271- if (m_pce != NULL && match_limit > 0 ) {
271+ if (m_pce != nullptr && match_limit > 0 ) {
272272 local_pce = *m_pce;
273273 local_pce.match_limit = match_limit;
274274 local_pce.flags |= PCRE_EXTRA_MATCH_LIMIT;
@@ -346,16 +346,16 @@ RegexResult Regex::searchGlobal(const std::string& s, std::vector<SMatchCapture>
346346int Regex::search (const std::string& s, SMatch *match) const {
347347#ifndef WITH_PCRE
348348 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 );
350350 int ret = 0 ;
351351 if (m_pcje == 0 ) {
352352 ret = pcre2_match (m_pc, pcre2_s, s.length (),
353- 0 , 0 , match_data, NULL ) > 0 ;
353+ 0 , 0 , match_data, nullptr ) > 0 ;
354354 }
355355
356356 if (m_pcje != 0 || ret == PCRE2_ERROR_JIT_STACKLIMIT) {
357357 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 ;
359359 }
360360 if (ret > 0 ) { // match
361361 PCRE2_SIZE *ovector = pcre2_get_ovector_pointer (match_data);
@@ -380,14 +380,14 @@ int Regex::search(const std::string& s, SMatch *match) const {
380380int Regex::search (const std::string& s) const {
381381#ifndef WITH_PCRE
382382 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 );
384384 int rc = 0 ;
385385 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 );
387387 }
388388
389389 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 );
391391 }
392392 pcre2_match_data_free (match_data);
393393 if (rc > 0 ) {
0 commit comments