Skip to content

Commit af09fd6

Browse files
authored
Issue #184 : Fixed all -Wzero-as-null-pointer-constant warnings (#185)
1 parent 701e5e7 commit af09fd6

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

double-conversion/double-to-string.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,15 @@ bool DoubleToStringConverter::HandleSpecialValues(
5656
StringBuilder* result_builder) const {
5757
Double double_inspect(value);
5858
if (double_inspect.IsInfinite()) {
59-
if (infinity_symbol_ == NULL) return false;
59+
if (infinity_symbol_ == DOUBLE_CONVERSION_NULLPTR) return false;
6060
if (value < 0) {
6161
result_builder->AddCharacter('-');
6262
}
6363
result_builder->AddString(infinity_symbol_);
6464
return true;
6565
}
6666
if (double_inspect.IsNan()) {
67-
if (nan_symbol_ == NULL) return false;
67+
if (nan_symbol_ == DOUBLE_CONVERSION_NULLPTR) return false;
6868
result_builder->AddString(nan_symbol_);
6969
return true;
7070
}

double-conversion/string-to-double.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ double StringToDoubleConverter::StringToIeee(
474474
current = next_non_space;
475475
}
476476

477-
if (infinity_symbol_ != NULL) {
477+
if (infinity_symbol_ != DOUBLE_CONVERSION_NULLPTR) {
478478
if (ConsumeFirstCharacter(*current, infinity_symbol_, allow_case_insensitivity)) {
479479
if (!ConsumeSubString(&current, end, infinity_symbol_, allow_case_insensitivity)) {
480480
return junk_string_value_;
@@ -492,7 +492,7 @@ double StringToDoubleConverter::StringToIeee(
492492
}
493493
}
494494

495-
if (nan_symbol_ != NULL) {
495+
if (nan_symbol_ != DOUBLE_CONVERSION_NULLPTR) {
496496
if (ConsumeFirstCharacter(*current, nan_symbol_, allow_case_insensitivity)) {
497497
if (!ConsumeSubString(&current, end, nan_symbol_, allow_case_insensitivity)) {
498498
return junk_string_value_;

double-conversion/utils.h

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
#include <cstdlib>
3535
#include <cstring>
3636

37+
// For pre-C++11 compatibility
38+
#if __cplusplus >= 201103L
39+
#define DOUBLE_CONVERSION_NULLPTR nullptr
40+
#else
41+
#define DOUBLE_CONVERSION_NULLPTR NULL
42+
#endif
43+
3744
#include <cassert>
3845
#ifndef DOUBLE_CONVERSION_ASSERT
3946
#define DOUBLE_CONVERSION_ASSERT(condition) \
@@ -241,9 +248,9 @@ inline int StrLength(const char* string) {
241248
template <typename T>
242249
class Vector {
243250
public:
244-
Vector() : start_(NULL), length_(0) {}
251+
Vector() : start_(DOUBLE_CONVERSION_NULLPTR), length_(0) {}
245252
Vector(T* data, int len) : start_(data), length_(len) {
246-
DOUBLE_CONVERSION_ASSERT(len == 0 || (len > 0 && data != NULL));
253+
DOUBLE_CONVERSION_ASSERT(len == 0 || (len > 0 && data != DOUBLE_CONVERSION_NULLPTR));
247254
}
248255

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

0 commit comments

Comments
 (0)