Skip to content

Commit

Permalink
Issue #184 : Fixed all -Wzero-as-null-pointer-constant warnings (#185)
Browse files Browse the repository at this point in the history
  • Loading branch information
seanm authored Jul 7, 2022
1 parent 701e5e7 commit af09fd6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions double-conversion/double-to-string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ bool DoubleToStringConverter::HandleSpecialValues(
StringBuilder* result_builder) const {
Double double_inspect(value);
if (double_inspect.IsInfinite()) {
if (infinity_symbol_ == NULL) return false;
if (infinity_symbol_ == DOUBLE_CONVERSION_NULLPTR) return false;
if (value < 0) {
result_builder->AddCharacter('-');
}
result_builder->AddString(infinity_symbol_);
return true;
}
if (double_inspect.IsNan()) {
if (nan_symbol_ == NULL) return false;
if (nan_symbol_ == DOUBLE_CONVERSION_NULLPTR) return false;
result_builder->AddString(nan_symbol_);
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions double-conversion/string-to-double.cc
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ double StringToDoubleConverter::StringToIeee(
current = next_non_space;
}

if (infinity_symbol_ != NULL) {
if (infinity_symbol_ != DOUBLE_CONVERSION_NULLPTR) {
if (ConsumeFirstCharacter(*current, infinity_symbol_, allow_case_insensitivity)) {
if (!ConsumeSubString(&current, end, infinity_symbol_, allow_case_insensitivity)) {
return junk_string_value_;
Expand All @@ -492,7 +492,7 @@ double StringToDoubleConverter::StringToIeee(
}
}

if (nan_symbol_ != NULL) {
if (nan_symbol_ != DOUBLE_CONVERSION_NULLPTR) {
if (ConsumeFirstCharacter(*current, nan_symbol_, allow_case_insensitivity)) {
if (!ConsumeSubString(&current, end, nan_symbol_, allow_case_insensitivity)) {
return junk_string_value_;
Expand Down
11 changes: 9 additions & 2 deletions double-conversion/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
#include <cstdlib>
#include <cstring>

// For pre-C++11 compatibility
#if __cplusplus >= 201103L
#define DOUBLE_CONVERSION_NULLPTR nullptr
#else
#define DOUBLE_CONVERSION_NULLPTR NULL
#endif

#include <cassert>
#ifndef DOUBLE_CONVERSION_ASSERT
#define DOUBLE_CONVERSION_ASSERT(condition) \
Expand Down Expand Up @@ -241,9 +248,9 @@ inline int StrLength(const char* string) {
template <typename T>
class Vector {
public:
Vector() : start_(NULL), length_(0) {}
Vector() : start_(DOUBLE_CONVERSION_NULLPTR), length_(0) {}
Vector(T* data, int len) : start_(data), length_(len) {
DOUBLE_CONVERSION_ASSERT(len == 0 || (len > 0 && data != NULL));
DOUBLE_CONVERSION_ASSERT(len == 0 || (len > 0 && data != DOUBLE_CONVERSION_NULLPTR));
}

// Returns a vector using the same backing storage as this one,
Expand Down

0 comments on commit af09fd6

Please sign in to comment.