diff --git a/double-conversion/double-to-string.cc b/double-conversion/double-to-string.cc index 9255bce1..bb369fe8 100644 --- a/double-conversion/double-to-string.cc +++ b/double-conversion/double-to-string.cc @@ -56,7 +56,7 @@ 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('-'); } @@ -64,7 +64,7 @@ bool DoubleToStringConverter::HandleSpecialValues( 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; } diff --git a/double-conversion/string-to-double.cc b/double-conversion/string-to-double.cc index fe633aac..972956ca 100644 --- a/double-conversion/string-to-double.cc +++ b/double-conversion/string-to-double.cc @@ -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(¤t, end, infinity_symbol_, allow_case_insensitivity)) { return junk_string_value_; @@ -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(¤t, end, nan_symbol_, allow_case_insensitivity)) { return junk_string_value_; diff --git a/double-conversion/utils.h b/double-conversion/utils.h index 868770d2..4f4dd71b 100644 --- a/double-conversion/utils.h +++ b/double-conversion/utils.h @@ -34,6 +34,13 @@ #include #include +// For pre-C++11 compatibility +#if __cplusplus >= 201103L +#define DOUBLE_CONVERSION_NULLPTR nullptr +#else +#define DOUBLE_CONVERSION_NULLPTR NULL +#endif + #include #ifndef DOUBLE_CONVERSION_ASSERT #define DOUBLE_CONVERSION_ASSERT(condition) \ @@ -241,9 +248,9 @@ inline int StrLength(const char* string) { template 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,