diff options
author | Henry Wilson <m3henry@googlemail.com> | 2019-04-10 22:07:06 +0100 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2019-04-10 23:22:20 +0200 |
commit | 7c8e7c6b6e16d4a26259a676db32d8776b99817e (patch) | |
tree | 99f134b7e66367cf11e10bc5061896eab4a3264f /src/stringfilter.cpp | |
parent | 3b4f224c0bc50e7248050d4bcbb6d83fd510c1cc (diff) | |
download | openttd-7c8e7c6b6e16d4a26259a676db32d8776b99817e.tar.xz |
Codechange: Use null pointer literal instead of the NULL macro
Diffstat (limited to 'src/stringfilter.cpp')
-rw-r--r-- | src/stringfilter.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/stringfilter.cpp b/src/stringfilter.cpp index 88eb5f28a..d0bffb270 100644 --- a/src/stringfilter.cpp +++ b/src/stringfilter.cpp @@ -33,14 +33,14 @@ void StringFilter::SetFilterTerm(const char *str) this->word_matches = 0; free(this->filter_buffer); - assert(str != NULL); + assert(str != nullptr); char *dest = MallocT<char>(strlen(str) + 1); this->filter_buffer = dest; WChar state = STATE_WHITESPACE; const char *pos = str; - WordState *word = NULL; + WordState *word = nullptr; size_t len; for (;; pos += len) { WChar c; @@ -48,9 +48,9 @@ void StringFilter::SetFilterTerm(const char *str) if (c == 0 || (state == STATE_WORD && IsWhitespace(c))) { /* Finish word */ - if (word != NULL) { + if (word != nullptr) { *(dest++) = '\0'; - word = NULL; + word = nullptr; } state = STATE_WHITESPACE; if (c != 0) continue; else break; @@ -75,7 +75,7 @@ void StringFilter::SetFilterTerm(const char *str) } /* Add to word */ - if (word == NULL) { + if (word == nullptr) { /*C++17: word = &*/ this->word_index.push_back({dest, false}); word = &this->word_index.back(); } @@ -106,12 +106,12 @@ void StringFilter::ResetState() */ void StringFilter::AddLine(const char *str) { - if (str == NULL) return; + if (str == nullptr) return; - bool match_case = this->case_sensitive != NULL && *this->case_sensitive; + bool match_case = this->case_sensitive != nullptr && *this->case_sensitive; for (WordState &ws : this->word_index) { if (!ws.match) { - if ((match_case ? strstr(str, ws.start) : strcasestr(str, ws.start)) != NULL) { + if ((match_case ? strstr(str, ws.start) : strcasestr(str, ws.start)) != nullptr) { ws.match = true; this->word_matches++; } |