Codechange: Use null pointer literal instead of the NULL macro

This commit is contained in:
Henry Wilson
2019-04-10 22:07:06 +01:00
committed by Michael Lutz
parent 3b4f224c0b
commit 7c8e7c6b6e
463 changed files with 5674 additions and 5674 deletions

View File

@@ -174,7 +174,7 @@ public:
std::unique_ptr<const Line> NextLine(int max_width) override
{
icu::ParagraphLayout::Line *l = p->nextLine(max_width);
return std::unique_ptr<const Line>(l == NULL ? NULL : new ICULine(l));
return std::unique_ptr<const Line>(l == nullptr ? nullptr : new ICULine(l));
}
};
@@ -208,10 +208,10 @@ public:
LEErrorCode status = LE_NO_ERROR;
/* ParagraphLayout does not copy "buff", so it must stay valid.
* "runs" is copied according to the ICU source, but the documentation does not specify anything, so this might break somewhen. */
icu::ParagraphLayout *p = new icu::ParagraphLayout(buff, length, &runs, NULL, NULL, NULL, _current_text_dir == TD_RTL ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR, false, status);
icu::ParagraphLayout *p = new icu::ParagraphLayout(buff, length, &runs, nullptr, nullptr, nullptr, _current_text_dir == TD_RTL ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR, false, status);
if (status != LE_NO_ERROR) {
delete p;
return NULL;
return nullptr;
}
return new ICUParagraphLayout(p);
@@ -234,7 +234,7 @@ public:
* visual runs.
*
* One constructs this class with the text that needs to be split into
* lines. Then nextLine is called with the maximum width until NULL is
* lines. Then nextLine is called with the maximum width until nullptr is
* returned. Each nextLine call creates VisualRuns which contain the
* length of text that are to be drawn with the same font. In other
* words, the result of this class is a list of sub strings with their
@@ -358,9 +358,9 @@ FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(FallbackVisualRun
this->glyph_to_char = other.glyph_to_char;
this->glyphs = other.glyphs;
other.positions = NULL;
other.glyph_to_char = NULL;
other.glyphs = NULL;
other.positions = nullptr;
other.glyph_to_char = nullptr;
other.glyphs = nullptr;
}
/** Free all data. */
@@ -496,7 +496,7 @@ void FallbackParagraphLayout::Reflow()
/**
* Construct a new line with a maximum width.
* @param max_width The maximum width of the string.
* @return A Line, or NULL when at the end of the paragraph.
* @return A Line, or nullptr when at the end of the paragraph.
*/
std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine(int max_width)
{
@@ -504,13 +504,13 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
* - split a line at a newline character, or at a space where we can break a line.
* - split for a visual run whenever a new line happens, or the font changes.
*/
if (this->buffer == NULL) return NULL;
if (this->buffer == nullptr) return nullptr;
std::unique_ptr<FallbackLine> l(new FallbackLine());
if (*this->buffer == '\0') {
/* Only a newline. */
this->buffer = NULL;
this->buffer = nullptr;
l->emplace_back(this->runs.front().second, this->buffer, 0, 0);
return std::move(l); // Not supposed to be needed, but clang-3.8 barfs otherwise.
}
@@ -526,7 +526,7 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
const WChar *next_run = this->buffer_begin + iter->first;
const WChar *begin = this->buffer;
const WChar *last_space = NULL;
const WChar *last_space = nullptr;
const WChar *last_char;
int width = 0;
for (;;) {
@@ -534,7 +534,7 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
last_char = this->buffer;
if (c == '\0') {
this->buffer = NULL;
this->buffer = nullptr;
break;
}
@@ -547,7 +547,7 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
next_run = this->buffer_begin + iter->first;
begin = this->buffer;
last_space = NULL;
last_space = nullptr;
}
if (IsWhitespace(c)) last_space = this->buffer;
@@ -561,11 +561,11 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
if (width == char_width) {
/* The character is wider than allowed width; don't know
* what to do with this case... bail out! */
this->buffer = NULL;
this->buffer = nullptr;
return std::move(l); // Not supposed to be needed, but clang-3.8 barfs otherwise.
}
if (last_space == NULL) {
if (last_space == nullptr) {
/* No space has been found. Just terminate at our current
* location. This usually happens for languages that do not
* require spaces in strings, like Chinese, Japanese and
@@ -595,7 +595,7 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
/**
* Helper for getting a ParagraphLayouter of the given type.
*
* @note In case no ParagraphLayouter could be constructed, line.layout will be NULL.
* @note In case no ParagraphLayouter could be constructed, line.layout will be nullptr.
* @param line The cache item to store our layouter in.
* @param str The string to create a layouter for.
* @param state The state of the font and color.
@@ -604,7 +604,7 @@ std::unique_ptr<const ParagraphLayouter::Line> FallbackParagraphLayout::NextLine
template <typename T>
static inline void GetLayouter(Layouter::LineCacheItem &line, const char *&str, FontState &state)
{
if (line.buffer != NULL) free(line.buffer);
if (line.buffer != nullptr) free(line.buffer);
typename T::CharType *buff_begin = MallocT<typename T::CharType>(DRAW_STRING_BUFFER);
const typename T::CharType *buffer_last = buff_begin + DRAW_STRING_BUFFER;
@@ -679,7 +679,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
}
LineCacheItem& line = GetCachedParagraphLayout(str, lineend - str, state);
if (line.layout != NULL) {
if (line.layout != nullptr) {
/* Line is in cache */
str = lineend + 1;
state = line.state_after;
@@ -693,7 +693,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
#ifdef WITH_ICU_LX
GetLayouter<ICUParagraphLayoutFactory>(line, str, state);
if (line.layout == NULL) {
if (line.layout == nullptr) {
static bool warned = false;
if (!warned) {
DEBUG(misc, 0, "ICU layouter bailed on the font. Falling back to the fallback layouter");
@@ -706,9 +706,9 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
#endif
#ifdef WITH_UNISCRIBE
if (line.layout == NULL) {
if (line.layout == nullptr) {
GetLayouter<UniscribeParagraphLayoutFactory>(line, str, state);
if (line.layout == NULL) {
if (line.layout == nullptr) {
state = old_state;
str = old_str;
}
@@ -716,16 +716,16 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
#endif
#ifdef WITH_COCOA
if (line.layout == NULL) {
if (line.layout == nullptr) {
GetLayouter<CoreTextParagraphLayoutFactory>(line, str, state);
if (line.layout == NULL) {
if (line.layout == nullptr) {
state = old_state;
str = old_str;
}
}
#endif
if (line.layout == NULL) {
if (line.layout == nullptr) {
GetLayouter<FallbackParagraphLayoutFactory>(line, str, state);
}
}
@@ -733,7 +733,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
/* Move all lines into a local cache so we can reuse them later on more easily. */
for (;;) {
auto l = line.layout->NextLine(maxw);
if (l == NULL) break;
if (l == nullptr) break;
this->push_back(std::move(l));
}
} while (c != '\0');
@@ -804,7 +804,7 @@ Point Layouter::GetCharPosition(const char *ch) const
/**
* Get the character that is at a position.
* @param x Position in the string.
* @return Pointer to the character at the position or NULL if no character is at the position.
* @return Pointer to the character at the position or nullptr if no character is at the position.
*/
const char *Layouter::GetCharAtPosition(int x) const
{
@@ -835,7 +835,7 @@ const char *Layouter::GetCharAtPosition(int x) const
}
}
return NULL;
return nullptr;
}
/**
@@ -883,7 +883,7 @@ void Layouter::ResetFontCache(FontSize size)
*/
Layouter::LineCacheItem &Layouter::GetCachedParagraphLayout(const char *str, size_t len, const FontState &state)
{
if (linecache == NULL) {
if (linecache == nullptr) {
/* Create linecache on first access to avoid trouble with initialisation order of static variables. */
linecache = new LineCache();
}
@@ -899,7 +899,7 @@ Layouter::LineCacheItem &Layouter::GetCachedParagraphLayout(const char *str, siz
*/
void Layouter::ResetLineCache()
{
if (linecache != NULL) linecache->clear();
if (linecache != nullptr) linecache->clear();
}
/**
@@ -907,7 +907,7 @@ void Layouter::ResetLineCache()
*/
void Layouter::ReduceLineCache()
{
if (linecache != NULL) {
if (linecache != nullptr) {
/* TODO LRU cache would be fancy, but not exactly necessary */
if (linecache->size() > 4096) ResetLineCache();
}