Commit 526b3501 authored by Dhruv's avatar Dhruv

4593 Replace all occurrences of "NULL" to nullptr in src/google/protobug/stubs

parent e9a5412a
...@@ -113,7 +113,7 @@ char* GrowingArrayByteSink::GetBuffer(size_t* nbytes) { ...@@ -113,7 +113,7 @@ char* GrowingArrayByteSink::GetBuffer(size_t* nbytes) {
ShrinkToFit(); ShrinkToFit();
char* b = buf_; char* b = buf_;
*nbytes = size_; *nbytes = size_;
buf_ = NULL; buf_ = nullptr;
size_ = capacity_ = 0; size_ = capacity_ = 0;
return b; return b;
} }
......
...@@ -89,7 +89,7 @@ inline To down_cast(From* f) { // so we only accept pointers ...@@ -89,7 +89,7 @@ inline To down_cast(From* f) { // so we only accept pointers
} }
#if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI) #if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI)
assert(f == NULL || dynamic_cast<To>(f) != NULL); // RTTI: debug mode only! assert(f == nullptr || dynamic_cast<To>(f) != nullptr); // RTTI: debug mode only!
#endif #endif
return static_cast<To>(f); return static_cast<To>(f);
} }
...@@ -107,7 +107,7 @@ inline To down_cast(From& f) { ...@@ -107,7 +107,7 @@ inline To down_cast(From& f) {
#if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI) #if !defined(NDEBUG) && !defined(GOOGLE_PROTOBUF_NO_RTTI)
// RTTI: debug mode only! // RTTI: debug mode only!
assert(dynamic_cast<ToAsPointer>(&f) != NULL); assert(dynamic_cast<ToAsPointer>(&f) != nullptr);
#endif #endif
return *static_cast<ToAsPointer>(&f); return *static_cast<ToAsPointer>(&f);
} }
......
...@@ -176,12 +176,12 @@ void NullLogHandler(LogLevel /* level */, const char* /* filename */, ...@@ -176,12 +176,12 @@ void NullLogHandler(LogLevel /* level */, const char* /* filename */,
static LogHandler* log_handler_ = &DefaultLogHandler; static LogHandler* log_handler_ = &DefaultLogHandler;
static int log_silencer_count_ = 0; static int log_silencer_count_ = 0;
static Mutex* log_silencer_count_mutex_ = NULL; static Mutex* log_silencer_count_mutex_ = nullptr;
GOOGLE_PROTOBUF_DECLARE_ONCE(log_silencer_count_init_); GOOGLE_PROTOBUF_DECLARE_ONCE(log_silencer_count_init_);
void DeleteLogSilencerCount() { void DeleteLogSilencerCount() {
delete log_silencer_count_mutex_; delete log_silencer_count_mutex_;
log_silencer_count_mutex_ = NULL; log_silencer_count_mutex_ = nullptr;
} }
void InitLogSilencerCount() { void InitLogSilencerCount() {
log_silencer_count_mutex_ = new Mutex; log_silencer_count_mutex_ = new Mutex;
...@@ -282,9 +282,9 @@ void LogFinisher::operator=(LogMessage& other) { ...@@ -282,9 +282,9 @@ void LogFinisher::operator=(LogMessage& other) {
LogHandler* SetLogHandler(LogHandler* new_func) { LogHandler* SetLogHandler(LogHandler* new_func) {
LogHandler* old = internal::log_handler_; LogHandler* old = internal::log_handler_;
if (old == &internal::NullLogHandler) { if (old == &internal::NullLogHandler) {
old = NULL; old = nullptr;
} }
if (new_func == NULL) { if (new_func == nullptr) {
internal::log_handler_ = &internal::NullLogHandler; internal::log_handler_ = &internal::NullLogHandler;
} else { } else {
internal::log_handler_ = new_func; internal::log_handler_ = new_func;
......
...@@ -100,14 +100,14 @@ TEST(LoggingTest, DefaultLogging) { ...@@ -100,14 +100,14 @@ TEST(LoggingTest, DefaultLogging) {
} }
TEST(LoggingTest, NullLogging) { TEST(LoggingTest, NullLogging) {
LogHandler* old_handler = SetLogHandler(NULL); LogHandler* old_handler = SetLogHandler(nullptr);
CaptureTestStderr(); CaptureTestStderr();
GOOGLE_LOG(INFO ) << "A message."; GOOGLE_LOG(INFO ) << "A message.";
GOOGLE_LOG(WARNING) << "A warning."; GOOGLE_LOG(WARNING) << "A warning.";
GOOGLE_LOG(ERROR ) << "An error."; GOOGLE_LOG(ERROR ) << "An error.";
EXPECT_TRUE(SetLogHandler(old_handler) == NULL); EXPECT_TRUE(SetLogHandler(old_handler) == nullptr);
string text = GetCapturedTestStderr(); string text = GetCapturedTestStderr();
EXPECT_EQ("", text); EXPECT_EQ("", text);
...@@ -179,9 +179,9 @@ class ClosureTest : public testing::Test { ...@@ -179,9 +179,9 @@ class ClosureTest : public testing::Test {
virtual void SetUp() { virtual void SetUp() {
current_instance_ = this; current_instance_ = this;
a_ = 0; a_ = 0;
b_ = NULL; b_ = nullptr;
c_.clear(); c_.clear();
permanent_closure_ = NULL; permanent_closure_ = nullptr;
} }
void DeleteClosureInCallback() { void DeleteClosureInCallback() {
...@@ -196,7 +196,7 @@ class ClosureTest : public testing::Test { ...@@ -196,7 +196,7 @@ class ClosureTest : public testing::Test {
static ClosureTest* current_instance_; static ClosureTest* current_instance_;
}; };
ClosureTest* ClosureTest::current_instance_ = NULL; ClosureTest* ClosureTest::current_instance_ = nullptr;
TEST_F(ClosureTest, TestClosureFunction0) { TEST_F(ClosureTest, TestClosureFunction0) {
Closure* closure = NewCallback(&SetA123Function); Closure* closure = NewCallback(&SetA123Function);
...@@ -321,7 +321,7 @@ TEST_F(ClosureTest, TestPermanentClosureFunction2) { ...@@ -321,7 +321,7 @@ TEST_F(ClosureTest, TestPermanentClosureFunction2) {
EXPECT_EQ(789, a_); EXPECT_EQ(789, a_);
EXPECT_EQ(cstr, b_); EXPECT_EQ(cstr, b_);
a_ = 0; a_ = 0;
b_ = NULL; b_ = nullptr;
closure->Run(); closure->Run();
EXPECT_EQ(789, a_); EXPECT_EQ(789, a_);
EXPECT_EQ(cstr, b_); EXPECT_EQ(cstr, b_);
...@@ -338,7 +338,7 @@ TEST_F(ClosureTest, TestPermanentClosureMethod2) { ...@@ -338,7 +338,7 @@ TEST_F(ClosureTest, TestPermanentClosureMethod2) {
EXPECT_EQ(789, a_); EXPECT_EQ(789, a_);
EXPECT_EQ(cstr, b_); EXPECT_EQ(cstr, b_);
a_ = 0; a_ = 0;
b_ = NULL; b_ = nullptr;
closure->Run(); closure->Run();
EXPECT_EQ(789, a_); EXPECT_EQ(789, a_);
EXPECT_EQ(cstr, b_); EXPECT_EQ(cstr, b_);
......
...@@ -91,7 +91,7 @@ struct CharTraits<wchar_t> { ...@@ -91,7 +91,7 @@ struct CharTraits<wchar_t> {
template <typename char_type> template <typename char_type>
bool null_or_empty(const char_type* s) { bool null_or_empty(const char_type* s) {
return s == NULL || *s == 0; return s == nullptr || *s == 0;
} }
// Returns true if the path starts with a drive letter, e.g. "c:". // Returns true if the path starts with a drive letter, e.g. "c:".
...@@ -225,7 +225,7 @@ bool as_windows_path(const char* path, wstring* result) { ...@@ -225,7 +225,7 @@ bool as_windows_path(const char* path, wstring* result) {
if (!is_path_absolute(wpath.c_str())) { if (!is_path_absolute(wpath.c_str())) {
int size = ::GetCurrentDirectoryW(0, NULL); int size = ::GetCurrentDirectoryW(0, nullptr);
if (size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) { if (size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
return false; return false;
} }
...@@ -316,17 +316,17 @@ FILE* fopen(const char* path, const char* mode) { ...@@ -316,17 +316,17 @@ FILE* fopen(const char* path, const char* mode) {
#ifdef SUPPORT_LONGPATHS #ifdef SUPPORT_LONGPATHS
if (null_or_empty(path)) { if (null_or_empty(path)) {
errno = EINVAL; errno = EINVAL;
return NULL; return nullptr;
} }
wstring wpath; wstring wpath;
if (!as_windows_path(path, &wpath)) { if (!as_windows_path(path, &wpath)) {
errno = ENOENT; errno = ENOENT;
return NULL; return nullptr;
} }
wstring wmode; wstring wmode;
if (!strings::utf8_to_wcs(mode, &wmode)) { if (!strings::utf8_to_wcs(mode, &wmode)) {
errno = EINVAL; errno = EINVAL;
return NULL; return nullptr;
} }
return ::_wfopen(wpath.c_str(), wmode.c_str()); return ::_wfopen(wpath.c_str(), wmode.c_str());
#else #else
...@@ -365,15 +365,15 @@ bool wcs_to_mbs(const WCHAR* s, string* out, bool outUtf8) { ...@@ -365,15 +365,15 @@ bool wcs_to_mbs(const WCHAR* s, string* out, bool outUtf8) {
BOOL usedDefaultChar = FALSE; BOOL usedDefaultChar = FALSE;
SetLastError(0); SetLastError(0);
int size = WideCharToMultiByte( int size = WideCharToMultiByte(
outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, NULL, 0, NULL, outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, nullptr, 0, nullptr,
outUtf8 ? NULL : &usedDefaultChar); outUtf8 ? nullptr : &usedDefaultChar);
if ((size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) if ((size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|| usedDefaultChar) { || usedDefaultChar) {
return false; return false;
} }
std::unique_ptr<CHAR[]> astr(new CHAR[size]); std::unique_ptr<CHAR[]> astr(new CHAR[size]);
WideCharToMultiByte( WideCharToMultiByte(
outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, astr.get(), size, NULL, NULL); outUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, astr.get(), size, nullptr, nullptr);
out->assign(astr.get()); out->assign(astr.get());
return true; return true;
} }
...@@ -386,7 +386,7 @@ bool mbs_to_wcs(const char* s, wstring* out, bool inUtf8) { ...@@ -386,7 +386,7 @@ bool mbs_to_wcs(const char* s, wstring* out, bool inUtf8) {
SetLastError(0); SetLastError(0);
int size = int size =
MultiByteToWideChar(inUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, NULL, 0); MultiByteToWideChar(inUtf8 ? CP_UTF8 : CP_ACP, 0, s, -1, nullptr, 0);
if (size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) { if (size == 0 && GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
return false; return false;
} }
......
...@@ -112,7 +112,7 @@ void StripTrailingSlashes(string* str) { ...@@ -112,7 +112,7 @@ void StripTrailingSlashes(string* str) {
} }
bool GetEnvVarAsUtf8(const WCHAR* name, string* result) { bool GetEnvVarAsUtf8(const WCHAR* name, string* result) {
DWORD size = ::GetEnvironmentVariableW(name, NULL, 0); DWORD size = ::GetEnvironmentVariableW(name, nullptr, 0);
if (size > 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND) { if (size > 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND) {
std::unique_ptr<WCHAR[]> wcs(new WCHAR[size]); std::unique_ptr<WCHAR[]> wcs(new WCHAR[size]);
::GetEnvironmentVariableW(name, wcs.get(), size); ::GetEnvironmentVariableW(name, wcs.get(), size);
...@@ -128,7 +128,7 @@ bool GetEnvVarAsUtf8(const WCHAR* name, string* result) { ...@@ -128,7 +128,7 @@ bool GetEnvVarAsUtf8(const WCHAR* name, string* result) {
} }
bool GetCwdAsUtf8(string* result) { bool GetCwdAsUtf8(string* result) {
DWORD size = ::GetCurrentDirectoryW(0, NULL); DWORD size = ::GetCurrentDirectoryW(0, nullptr);
if (size > 0) { if (size > 0) {
std::unique_ptr<WCHAR[]> wcs(new WCHAR[size]); std::unique_ptr<WCHAR[]> wcs(new WCHAR[size]);
::GetCurrentDirectoryW(size, wcs.get()); ::GetCurrentDirectoryW(size, wcs.get());
...@@ -201,7 +201,7 @@ bool IoWin32Test::CreateAllUnder(wstring path) { ...@@ -201,7 +201,7 @@ bool IoWin32Test::CreateAllUnder(wstring path) {
if (path.find(L"\\\\?\\") != 0) { if (path.find(L"\\\\?\\") != 0) {
path = wstring(L"\\\\?\\") + path; path = wstring(L"\\\\?\\") + path;
} }
if (::CreateDirectoryW(path.c_str(), NULL) || if (::CreateDirectoryW(path.c_str(), nullptr) ||
GetLastError() == ERROR_ALREADY_EXISTS || GetLastError() == ERROR_ALREADY_EXISTS ||
GetLastError() == ERROR_ACCESS_DENIED) { GetLastError() == ERROR_ACCESS_DENIED) {
return true; return true;
...@@ -210,7 +210,7 @@ bool IoWin32Test::CreateAllUnder(wstring path) { ...@@ -210,7 +210,7 @@ bool IoWin32Test::CreateAllUnder(wstring path) {
size_t pos = path.find_last_of(L'\\'); size_t pos = path.find_last_of(L'\\');
if (pos != wstring::npos) { if (pos != wstring::npos) {
wstring parent(path, 0, pos); wstring parent(path, 0, pos);
if (CreateAllUnder(parent) && CreateDirectoryW(path.c_str(), NULL)) { if (CreateAllUnder(parent) && CreateDirectoryW(path.c_str(), nullptr)) {
return true; return true;
} }
} }
...@@ -352,8 +352,8 @@ TEST_F(IoWin32Test, MkdirTestNonAscii) { ...@@ -352,8 +352,8 @@ TEST_F(IoWin32Test, MkdirTestNonAscii) {
// Create a non-ASCII path. // Create a non-ASCII path.
// Ensure that we can create the directory using SetCurrentDirectoryW. // Ensure that we can create the directory using SetCurrentDirectoryW.
EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1").c_str(), NULL)); EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1").c_str(), nullptr));
EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1\\" + kUtf16Text).c_str(), NULL)); EXPECT_TRUE(CreateDirectoryW((wtest_tmpdir + L"\\1\\" + kUtf16Text).c_str(), nullptr));
// Ensure that we can create a very similarly named directory using mkdir. // Ensure that we can create a very similarly named directory using mkdir.
// We don't attemp to delete and recreate the same directory, because on // We don't attemp to delete and recreate the same directory, because on
// Windows, deleting files and directories seems to be asynchronous. // Windows, deleting files and directories seems to be asynchronous.
...@@ -386,7 +386,7 @@ TEST_F(IoWin32Test, ChdirTestNonAscii) { ...@@ -386,7 +386,7 @@ TEST_F(IoWin32Test, ChdirTestNonAscii) {
wstring wNonAscii(wtest_tmpdir + L"\\" + kUtf16Text); wstring wNonAscii(wtest_tmpdir + L"\\" + kUtf16Text);
string nonAscii; string nonAscii;
EXPECT_TRUE(strings::wcs_to_utf8(wNonAscii.c_str(), &nonAscii)); EXPECT_TRUE(strings::wcs_to_utf8(wNonAscii.c_str(), &nonAscii));
EXPECT_TRUE(CreateDirectoryW(wNonAscii.c_str(), NULL)); EXPECT_TRUE(CreateDirectoryW(wNonAscii.c_str(), nullptr));
WCHAR cwd[MAX_PATH]; WCHAR cwd[MAX_PATH];
EXPECT_TRUE(GetCurrentDirectoryW(MAX_PATH, cwd)); EXPECT_TRUE(GetCurrentDirectoryW(MAX_PATH, cwd));
// Ensure that we can cd into the path using SetCurrentDirectoryW. // Ensure that we can cd into the path using SetCurrentDirectoryW.
...@@ -400,7 +400,7 @@ TEST_F(IoWin32Test, ChdirTestNonAscii) { ...@@ -400,7 +400,7 @@ TEST_F(IoWin32Test, ChdirTestNonAscii) {
} }
TEST_F(IoWin32Test, AsWindowsPathTest) { TEST_F(IoWin32Test, AsWindowsPathTest) {
DWORD size = GetCurrentDirectoryW(0, NULL); DWORD size = GetCurrentDirectoryW(0, nullptr);
std::unique_ptr<wchar_t[]> cwd_str(new wchar_t[size]); std::unique_ptr<wchar_t[]> cwd_str(new wchar_t[size]);
EXPECT_GT(GetCurrentDirectoryW(size, cwd_str.get()), 0); EXPECT_GT(GetCurrentDirectoryW(size, cwd_str.get()), 0);
wstring cwd = wstring(L"\\\\?\\") + cwd_str.get(); wstring cwd = wstring(L"\\\\?\\") + cwd_str.get();
......
...@@ -162,7 +162,7 @@ namespace internal { ...@@ -162,7 +162,7 @@ namespace internal {
template<typename T> template<typename T>
T* CheckNotNull(const char* /* file */, int /* line */, T* CheckNotNull(const char* /* file */, int /* line */,
const char* name, T* val) { const char* name, T* val) {
if (val == NULL) { if (val == nullptr) {
GOOGLE_LOG(FATAL) << name; GOOGLE_LOG(FATAL) << name;
} }
return val; return val;
...@@ -170,7 +170,7 @@ T* CheckNotNull(const char* /* file */, int /* line */, ...@@ -170,7 +170,7 @@ T* CheckNotNull(const char* /* file */, int /* line */,
} // namespace internal } // namespace internal
#define GOOGLE_CHECK_NOTNULL(A) \ #define GOOGLE_CHECK_NOTNULL(A) \
::google::protobuf::internal::CheckNotNull(\ ::google::protobuf::internal::CheckNotNull(\
__FILE__, __LINE__, "'" #A "' must not be NULL", (A)) __FILE__, __LINE__, "'" #A "' must not be nullptr", (A))
#ifdef NDEBUG #ifdef NDEBUG
...@@ -208,7 +208,7 @@ typedef void LogHandler(LogLevel level, const char* filename, int line, ...@@ -208,7 +208,7 @@ typedef void LogHandler(LogLevel level, const char* filename, int line,
// also help end users figure out a problem. If you would prefer that // also help end users figure out a problem. If you would prefer that
// these messages be sent somewhere other than stderr, call SetLogHandler() // these messages be sent somewhere other than stderr, call SetLogHandler()
// to set your own handler. This returns the old handler. Set the handler // to set your own handler. This returns the old handler. Set the handler
// to NULL to ignore log messages (but see also LogSilencer, below). // to nullptr to ignore log messages (but see also LogSilencer, below).
// //
// Obviously, SetLogHandler is not thread-safe. You should only call it // Obviously, SetLogHandler is not thread-safe. You should only call it
// at initialization time, and probably not from library code. If you // at initialization time, and probably not from library code. If you
......
...@@ -131,7 +131,7 @@ FindWithDefault(const Collection& collection, ...@@ -131,7 +131,7 @@ FindWithDefault(const Collection& collection,
} }
// Returns a pointer to the const value associated with the given key if it // Returns a pointer to the const value associated with the given key if it
// exists, or NULL otherwise. // exists, or nullptr otherwise.
template <class Collection> template <class Collection>
const typename Collection::value_type::second_type* const typename Collection::value_type::second_type*
FindOrNull(const Collection& collection, FindOrNull(const Collection& collection,
...@@ -156,11 +156,11 @@ FindOrNull(Collection& collection, // NOLINT ...@@ -156,11 +156,11 @@ FindOrNull(Collection& collection, // NOLINT
} }
// Returns the pointer value associated with the given key. If none is found, // Returns the pointer value associated with the given key. If none is found,
// NULL is returned. The function is designed to be used with a map of keys to // nullptr is returned. The function is designed to be used with a map of keys to
// pointers. // pointers.
// //
// This function does not distinguish between a missing key and a key mapped // This function does not distinguish between a missing key and a key mapped
// to a NULL value. // to nullptr.
template <class Collection> template <class Collection>
typename Collection::value_type::second_type typename Collection::value_type::second_type
FindPtrOrNull(const Collection& collection, FindPtrOrNull(const Collection& collection,
...@@ -188,7 +188,7 @@ FindPtrOrNull(Collection& collection, // NOLINT ...@@ -188,7 +188,7 @@ FindPtrOrNull(Collection& collection, // NOLINT
} }
// Finds the pointer value associated with the given key in a map whose values // Finds the pointer value associated with the given key in a map whose values
// are linked_ptrs. Returns NULL if key is not found. // are linked_ptrs. Returns nullptr if key is not found.
template <class Collection> template <class Collection>
typename Collection::value_type::second_type::element_type* typename Collection::value_type::second_type::element_type*
FindLinkedPtrOrNull(const Collection& collection, FindLinkedPtrOrNull(const Collection& collection,
...@@ -215,7 +215,7 @@ FindLinkedPtrOrDie(const Collection& collection, ...@@ -215,7 +215,7 @@ FindLinkedPtrOrDie(const Collection& collection,
} }
// Finds the value associated with the given key and copies it to *value (if not // Finds the value associated with the given key and copies it to *value (if not
// NULL). Returns false if the key was not found, true otherwise. // nullptr). Returns false if the key was not found, true otherwise.
template <class Collection, class Key, class Value> template <class Collection, class Key, class Value>
bool FindCopy(const Collection& collection, bool FindCopy(const Collection& collection,
const Key& key, const Key& key,
...@@ -447,7 +447,7 @@ LookupOrInsertNew(Collection* const collection, ...@@ -447,7 +447,7 @@ LookupOrInsertNew(Collection* const collection,
std::pair<typename Collection::iterator, bool> ret = std::pair<typename Collection::iterator, bool> ret =
collection->insert(typename Collection::value_type( collection->insert(typename Collection::value_type(
key, key,
static_cast<typename Collection::value_type::second_type>(NULL))); static_cast<typename Collection::value_type::second_type>(nullptr)));
if (ret.second) { if (ret.second) {
ret.first->second = new Element(); ret.first->second = new Element();
} }
...@@ -466,7 +466,7 @@ LookupOrInsertNew(Collection* const collection, ...@@ -466,7 +466,7 @@ LookupOrInsertNew(Collection* const collection,
std::pair<typename Collection::iterator, bool> ret = std::pair<typename Collection::iterator, bool> ret =
collection->insert(typename Collection::value_type( collection->insert(typename Collection::value_type(
key, key,
static_cast<typename Collection::value_type::second_type>(NULL))); static_cast<typename Collection::value_type::second_type>(nullptr)));
if (ret.second) { if (ret.second) {
ret.first->second = new Element(arg); ret.first->second = new Element(arg);
} }
...@@ -612,7 +612,7 @@ bool UpdateReturnCopy(Collection* const collection, ...@@ -612,7 +612,7 @@ bool UpdateReturnCopy(Collection* const collection,
return false; return false;
} }
// Tries to insert the given key-value pair into the collection. Returns NULL if // Tries to insert the given key-value pair into the collection. Returns nullptr if
// the insert succeeds. Otherwise, returns a pointer to the existing value. // the insert succeeds. Otherwise, returns a pointer to the existing value.
// //
// This complements UpdateReturnCopy in that it allows to update only after // This complements UpdateReturnCopy in that it allows to update only after
...@@ -625,7 +625,7 @@ InsertOrReturnExisting(Collection* const collection, ...@@ -625,7 +625,7 @@ InsertOrReturnExisting(Collection* const collection,
const typename Collection::value_type& vt) { const typename Collection::value_type& vt) {
std::pair<typename Collection::iterator, bool> ret = collection->insert(vt); std::pair<typename Collection::iterator, bool> ret = collection->insert(vt);
if (ret.second) { if (ret.second) {
return NULL; // Inserted, no existing previous value. return nullptr; // Inserted, no existing previous value.
} else { } else {
return &ret.first->second; // Return address of already existing value. return &ret.first->second; // Return address of already existing value.
} }
...@@ -644,7 +644,7 @@ InsertOrReturnExisting( ...@@ -644,7 +644,7 @@ InsertOrReturnExisting(
// Erases the collection item identified by the given key, and returns the value // Erases the collection item identified by the given key, and returns the value
// associated with that key. It is assumed that the value (i.e., the // associated with that key. It is assumed that the value (i.e., the
// mapped_type) is a pointer. Returns NULL if the key was not found in the // mapped_type) is a pointer. Returns nullptr if the key was not found in the
// collection. // collection.
// //
// Examples: // Examples:
...@@ -665,7 +665,7 @@ typename Collection::value_type::second_type EraseKeyReturnValuePtr( ...@@ -665,7 +665,7 @@ typename Collection::value_type::second_type EraseKeyReturnValuePtr(
const typename Collection::value_type::first_type& key) { const typename Collection::value_type::first_type& key) {
typename Collection::iterator it = collection->find(key); typename Collection::iterator it = collection->find(key);
if (it == collection->end()) { if (it == collection->end()) {
return NULL; return nullptr;
} }
typename Collection::value_type::second_type v = it->second; typename Collection::value_type::second_type v = it->second;
collection->erase(it); collection->erase(it);
...@@ -679,7 +679,7 @@ typename Collection::value_type::second_type EraseKeyReturnValuePtr( ...@@ -679,7 +679,7 @@ typename Collection::value_type::second_type EraseKeyReturnValuePtr(
template <class MapContainer, class KeyContainer> template <class MapContainer, class KeyContainer>
void InsertKeysFromMap(const MapContainer& map_container, void InsertKeysFromMap(const MapContainer& map_container,
KeyContainer* key_container) { KeyContainer* key_container) {
GOOGLE_CHECK(key_container != NULL); GOOGLE_CHECK(key_container != nullptr);
for (typename MapContainer::const_iterator it = map_container.begin(); for (typename MapContainer::const_iterator it = map_container.begin();
it != map_container.end(); ++it) { it != map_container.end(); ++it) {
key_container->insert(it->first); key_container->insert(it->first);
...@@ -693,7 +693,7 @@ void InsertKeysFromMap(const MapContainer& map_container, ...@@ -693,7 +693,7 @@ void InsertKeysFromMap(const MapContainer& map_container,
template <class MapContainer, class KeyContainer> template <class MapContainer, class KeyContainer>
void AppendKeysFromMap(const MapContainer& map_container, void AppendKeysFromMap(const MapContainer& map_container,
KeyContainer* key_container) { KeyContainer* key_container) {
GOOGLE_CHECK(key_container != NULL); GOOGLE_CHECK(key_container != nullptr);
for (typename MapContainer::const_iterator it = map_container.begin(); for (typename MapContainer::const_iterator it = map_container.begin();
it != map_container.end(); ++it) { it != map_container.end(); ++it) {
key_container->push_back(it->first); key_container->push_back(it->first);
...@@ -710,7 +710,7 @@ void AppendKeysFromMap(const MapContainer& map_container, ...@@ -710,7 +710,7 @@ void AppendKeysFromMap(const MapContainer& map_container,
template <class MapContainer, class KeyType> template <class MapContainer, class KeyType>
void AppendKeysFromMap(const MapContainer& map_container, void AppendKeysFromMap(const MapContainer& map_container,
std::vector<KeyType>* key_container) { std::vector<KeyType>* key_container) {
GOOGLE_CHECK(key_container != NULL); GOOGLE_CHECK(key_container != nullptr);
// We now have the opportunity to call reserve(). Calling reserve() every // We now have the opportunity to call reserve(). Calling reserve() every
// time is a bad idea for some use cases: libstdc++'s implementation of // time is a bad idea for some use cases: libstdc++'s implementation of
// vector<>::reserve() resizes the vector's backing store to exactly the // vector<>::reserve() resizes the vector's backing store to exactly the
...@@ -737,7 +737,7 @@ void AppendKeysFromMap(const MapContainer& map_container, ...@@ -737,7 +737,7 @@ void AppendKeysFromMap(const MapContainer& map_container,
template <class MapContainer, class ValueContainer> template <class MapContainer, class ValueContainer>
void AppendValuesFromMap(const MapContainer& map_container, void AppendValuesFromMap(const MapContainer& map_container,
ValueContainer* value_container) { ValueContainer* value_container) {
GOOGLE_CHECK(value_container != NULL); GOOGLE_CHECK(value_container != nullptr);
for (typename MapContainer::const_iterator it = map_container.begin(); for (typename MapContainer::const_iterator it = map_container.begin();
it != map_container.end(); ++it) { it != map_container.end(); ++it) {
value_container->push_back(it->second); value_container->push_back(it->second);
...@@ -754,7 +754,7 @@ void AppendValuesFromMap(const MapContainer& map_container, ...@@ -754,7 +754,7 @@ void AppendValuesFromMap(const MapContainer& map_container,
template <class MapContainer, class ValueType> template <class MapContainer, class ValueType>
void AppendValuesFromMap(const MapContainer& map_container, void AppendValuesFromMap(const MapContainer& map_container,
std::vector<ValueType>* value_container) { std::vector<ValueType>* value_container) {
GOOGLE_CHECK(value_container != NULL); GOOGLE_CHECK(value_container != nullptr);
// See AppendKeysFromMap for why this is done. // See AppendKeysFromMap for why this is done.
if (value_container->empty()) { if (value_container->empty()) {
value_container->reserve(map_container.size()); value_container->reserve(map_container.size());
......
...@@ -86,12 +86,12 @@ class LIBPROTOBUF_EXPORT MutexLock { ...@@ -86,12 +86,12 @@ class LIBPROTOBUF_EXPORT MutexLock {
typedef MutexLock ReaderMutexLock; typedef MutexLock ReaderMutexLock;
typedef MutexLock WriterMutexLock; typedef MutexLock WriterMutexLock;
// MutexLockMaybe is like MutexLock, but is a no-op when mu is NULL. // MutexLockMaybe is like MutexLock, but is a no-op when mu is nullptr.
class LIBPROTOBUF_EXPORT MutexLockMaybe { class LIBPROTOBUF_EXPORT MutexLockMaybe {
public: public:
explicit MutexLockMaybe(Mutex *mu) : explicit MutexLockMaybe(Mutex *mu) :
mu_(mu) { if (this->mu_ != NULL) { this->mu_->Lock(); } } mu_(mu) { if (this->mu_ != nullptr) { this->mu_->Lock(); } }
~MutexLockMaybe() { if (this->mu_ != NULL) { this->mu_->Unlock(); } } ~MutexLockMaybe() { if (this->mu_ != nullptr) { this->mu_->Unlock(); } }
private: private:
Mutex *const mu_; Mutex *const mu_;
GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLockMaybe); GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MutexLockMaybe);
...@@ -109,7 +109,7 @@ class ThreadLocalStorage { ...@@ -109,7 +109,7 @@ class ThreadLocalStorage {
} }
T* Get() { T* Get() {
T* result = static_cast<T*>(pthread_getspecific(key_)); T* result = static_cast<T*>(pthread_getspecific(key_));
if (result == NULL) { if (result == nullptr) {
result = new T(); result = new T();
pthread_setspecific(key_, result); pthread_setspecific(key_, result);
} }
......
...@@ -45,7 +45,7 @@ class Singleton { ...@@ -45,7 +45,7 @@ class Singleton {
} }
static void ShutDown() { static void ShutDown() {
delete instance_; delete instance_;
instance_ = NULL; instance_ = nullptr;
} }
private: private:
static void Init() { static void Init() {
...@@ -59,7 +59,7 @@ template<typename T> ...@@ -59,7 +59,7 @@ template<typename T>
ProtobufOnceType Singleton<T>::once_; ProtobufOnceType Singleton<T>::once_;
template<typename T> template<typename T>
T* Singleton<T>::instance_ = NULL; T* Singleton<T>::instance_ = nullptr;
} // namespace internal } // namespace internal
} // namespace protobuf } // namespace protobuf
} // namespace google } // namespace google
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
// usable value, or an error Status explaining why such a value is // usable value, or an error Status explaining why such a value is
// not present. To this end, StatusOr<T> does not allow its Status // not present. To this end, StatusOr<T> does not allow its Status
// value to be Status::OK. Further, StatusOr<T*> does not allow the // value to be Status::OK. Further, StatusOr<T*> does not allow the
// contained pointer to be NULL. // contained pointer to be nullptr.
// //
// The primary use-case for StatusOr<T> is as the return value of a // The primary use-case for StatusOr<T> is as the return value of a
// function which may fail. // function which may fail.
...@@ -114,15 +114,15 @@ class StatusOr { ...@@ -114,15 +114,15 @@ class StatusOr {
StatusOr(const Status& status); // NOLINT StatusOr(const Status& status); // NOLINT
// Construct a new StatusOr with the given value. If T is a plain pointer, // Construct a new StatusOr with the given value. If T is a plain pointer,
// value must not be NULL. After calling this constructor, calls to // value must not be nullptr. After calling this constructor, calls to
// ValueOrDie() will succeed, and calls to status() will return OK. // ValueOrDie() will succeed, and calls to status() will return OK.
// //
// NOTE: Not explicit - we want to use StatusOr<T> as a return type // NOTE: Not explicit - we want to use StatusOr<T> as a return type
// so it is convenient and sensible to be able to do 'return T()' // so it is convenient and sensible to be able to do 'return T()'
// when when the return type is StatusOr<T>. // when when the return type is StatusOr<T>.
// //
// REQUIRES: if T is a plain pointer, value != NULL. This requirement is // REQUIRES: if T is a plain pointer, value != nullptr. This requirement is
// DCHECKed. In optimized builds, passing a NULL pointer here will have // DCHECKed. In optimized builds, passing a null pointer here will have
// the effect of passing PosixErrorSpace::EINVAL as a fallback. // the effect of passing PosixErrorSpace::EINVAL as a fallback.
StatusOr(const T& value); // NOLINT StatusOr(const T& value); // NOLINT
...@@ -174,13 +174,13 @@ class LIBPROTOBUF_EXPORT StatusOrHelper { ...@@ -174,13 +174,13 @@ class LIBPROTOBUF_EXPORT StatusOrHelper {
template<typename T> template<typename T>
struct StatusOrHelper::Specialize { struct StatusOrHelper::Specialize {
// For non-pointer T, a reference can never be NULL. // For non-pointer T, a reference can never be nullptr.
static inline bool IsValueNull(const T& t) { return false; } static inline bool IsValueNull(const T& t) { return false; }
}; };
template<typename T> template<typename T>
struct StatusOrHelper::Specialize<T*> { struct StatusOrHelper::Specialize<T*> {
static inline bool IsValueNull(const T* t) { return t == NULL; } static inline bool IsValueNull(const T* t) { return t == nullptr; }
}; };
} // namespace internal } // namespace internal
...@@ -202,7 +202,7 @@ inline StatusOr<T>::StatusOr(const Status& status) { ...@@ -202,7 +202,7 @@ inline StatusOr<T>::StatusOr(const Status& status) {
template<typename T> template<typename T>
inline StatusOr<T>::StatusOr(const T& value) { inline StatusOr<T>::StatusOr(const T& value) {
if (internal::StatusOrHelper::Specialize<T>::IsValueNull(value)) { if (internal::StatusOrHelper::Specialize<T>::IsValueNull(value)) {
status_ = Status(error::INTERNAL, "NULL is not a vaild argument."); status_ = Status(error::INTERNAL, "nullptr is not a vaild argument.");
} else { } else {
status_ = Status::OK; status_ = Status::OK;
value_ = value; value_ = value;
......
...@@ -82,7 +82,7 @@ inline void STLStringResizeUninitialized(string* s, size_t new_size) { ...@@ -82,7 +82,7 @@ inline void STLStringResizeUninitialized(string* s, size_t new_size) {
// already work on all current implementations. // already work on all current implementations.
inline char* string_as_array(string* str) { inline char* string_as_array(string* str) {
// DO NOT USE const_cast<char*>(str->data())! See the unittest for why. // DO NOT USE const_cast<char*>(str->data())! See the unittest for why.
return str->empty() ? NULL : &*str->begin(); return str->empty() ? nullptr : &*str->begin();
} }
// STLDeleteElements() deletes all the elements in an STL container and clears // STLDeleteElements() deletes all the elements in an STL container and clears
...@@ -90,7 +90,7 @@ inline char* string_as_array(string* str) { ...@@ -90,7 +90,7 @@ inline char* string_as_array(string* str) {
// hash_set, or any other STL container which defines sensible begin(), end(), // hash_set, or any other STL container which defines sensible begin(), end(),
// and clear() methods. // and clear() methods.
// //
// If container is NULL, this function is a no-op. // If container is nullptr, this function is a no-op.
// //
// As an alternative to calling STLDeleteElements() directly, consider // As an alternative to calling STLDeleteElements() directly, consider
// ElementDeleter (defined below), which ensures that your container's elements // ElementDeleter (defined below), which ensures that your container's elements
...@@ -104,7 +104,7 @@ void STLDeleteElements(T *container) { ...@@ -104,7 +104,7 @@ void STLDeleteElements(T *container) {
// Given an STL container consisting of (key, value) pairs, STLDeleteValues // Given an STL container consisting of (key, value) pairs, STLDeleteValues
// deletes all the "value" components and clears the container. Does nothing // deletes all the "value" components and clears the container. Does nothing
// in the case it's given a NULL pointer. // in the case it's given a null pointer.
template <class T> template <class T>
void STLDeleteValues(T *v) { void STLDeleteValues(T *v) {
......
...@@ -115,7 +115,7 @@ stringpiece_ssize_type StringPiece::find(char c, size_type pos) const { ...@@ -115,7 +115,7 @@ stringpiece_ssize_type StringPiece::find(char c, size_type pos) const {
} }
const char* result = static_cast<const char*>( const char* result = static_cast<const char*>(
memchr(ptr_ + pos, c, length_ - pos)); memchr(ptr_ + pos, c, length_ - pos));
return result != NULL ? result - ptr_ : npos; return result != nullptr ? result - ptr_ : npos;
} }
stringpiece_ssize_type StringPiece::rfind(StringPiece s, size_type pos) const { stringpiece_ssize_type StringPiece::rfind(StringPiece s, size_type pos) const {
......
...@@ -76,30 +76,30 @@ ...@@ -76,30 +76,30 @@
// //
// There are several ways to create a null StringPiece: // There are several ways to create a null StringPiece:
// StringPiece() // StringPiece()
// StringPiece(NULL) // StringPiece(nullptr)
// StringPiece(NULL, 0) // StringPiece(nullptr, 0)
// For all of the above, sp.data() == NULL, sp.length() == 0, // For all of the above, sp.data() == nullptr, sp.length() == 0,
// and sp.empty() == true. Also, if you create a StringPiece with // and sp.empty() == true. Also, if you create a StringPiece with
// a non-NULL pointer then sp.data() != NULL. Once created, // a non-null pointer then sp.data() != nullptr. Once created,
// sp.data() will stay either NULL or not-NULL, except if you call // sp.data() will stay either nullptr or not-nullptr, except if you call
// sp.clear() or sp.set(). // sp.clear() or sp.set().
// //
// Thus, you can use StringPiece(NULL) to signal an out-of-band value // Thus, you can use StringPiece(nullptr) to signal an out-of-band value
// that is different from other StringPiece values. This is similar // that is different from other StringPiece values. This is similar
// to the way that const char* p1 = NULL; is different from // to the way that const char* p1 = nullptr; is different from
// const char* p2 = "";. // const char* p2 = "";.
// //
// There are many ways to create an empty StringPiece: // There are many ways to create an empty StringPiece:
// StringPiece() // StringPiece()
// StringPiece(NULL) // StringPiece(nullptr)
// StringPiece(NULL, 0) // StringPiece(nullptr, 0)
// StringPiece("") // StringPiece("")
// StringPiece("", 0) // StringPiece("", 0)
// StringPiece("abcdef", 0) // StringPiece("abcdef", 0)
// StringPiece("abcdef"+6, 0) // StringPiece("abcdef"+6, 0)
// For all of the above, sp.length() will be 0 and sp.empty() will be true. // For all of the above, sp.length() will be 0 and sp.empty() will be true.
// For some empty StringPiece values, sp.data() will be NULL. // For some empty StringPiece values, sp.data() will be nullptr.
// For some empty StringPiece values, sp.data() will not be NULL. // For some empty StringPiece values, sp.data() will not be nullptr.
// //
// Be careful not to confuse: null StringPiece and empty StringPiece. // Be careful not to confuse: null StringPiece and empty StringPiece.
// The set of empty StringPieces properly includes the set of null StringPieces. // The set of empty StringPieces properly includes the set of null StringPieces.
...@@ -109,20 +109,20 @@ ...@@ -109,20 +109,20 @@
// All empty StringPiece values compare equal to each other. // All empty StringPiece values compare equal to each other.
// Even a null StringPieces compares equal to a non-null empty StringPiece: // Even a null StringPieces compares equal to a non-null empty StringPiece:
// StringPiece() == StringPiece("", 0) // StringPiece() == StringPiece("", 0)
// StringPiece(NULL) == StringPiece("abc", 0) // StringPiece(nullptr) == StringPiece("abc", 0)
// StringPiece(NULL, 0) == StringPiece("abcdef"+6, 0) // StringPiece(nullptr, 0) == StringPiece("abcdef"+6, 0)
// //
// Look carefully at this example: // Look carefully at this example:
// StringPiece("") == NULL // StringPiece("") == nullptr
// True or false? TRUE, because StringPiece::operator== converts // True or false? TRUE, because StringPiece::operator== converts
// the right-hand side from NULL to StringPiece(NULL), // the right-hand side from nullptr to StringPiece(nullptr),
// and then compares two zero-length spans of characters. // and then compares two zero-length spans of characters.
// However, we are working to make this example produce a compile error. // However, we are working to make this example produce a compile error.
// //
// Suppose you want to write: // Suppose you want to write:
// bool TestWhat?(StringPiece sp) { return sp == NULL; } // BAD // bool TestWhat?(StringPiece sp) { return sp == nullptr; } // BAD
// Do not do that. Write one of these instead: // Do not do that. Write one of these instead:
// bool TestNull(StringPiece sp) { return sp.data() == NULL; } // bool TestNull(StringPiece sp) { return sp.data() == nullptr; }
// bool TestEmpty(StringPiece sp) { return sp.empty(); } // bool TestEmpty(StringPiece sp) { return sp.empty(); }
// The intent of TestWhat? is unclear. Did you mean TestNull or TestEmpty? // The intent of TestWhat? is unclear. Did you mean TestNull or TestEmpty?
// Right now, TestWhat? behaves likes TestEmpty. // Right now, TestWhat? behaves likes TestEmpty.
...@@ -207,11 +207,11 @@ class LIBPROTOBUF_EXPORT StringPiece { ...@@ -207,11 +207,11 @@ class LIBPROTOBUF_EXPORT StringPiece {
// //
// Style guide exception granted: // Style guide exception granted:
// http://goto/style-guide-exception-20978288 // http://goto/style-guide-exception-20978288
StringPiece() : ptr_(NULL), length_(0) {} StringPiece() : ptr_(nullptr), length_(0) {}
StringPiece(const char* str) // NOLINT(runtime/explicit) StringPiece(const char* str) // NOLINT(runtime/explicit)
: ptr_(str), length_(0) { : ptr_(str), length_(0) {
if (str != NULL) { if (str != nullptr) {
length_ = CheckedSsizeTFromSizeT(strlen(str)); length_ = CheckedSsizeTFromSizeT(strlen(str));
} }
} }
...@@ -248,7 +248,7 @@ class LIBPROTOBUF_EXPORT StringPiece { ...@@ -248,7 +248,7 @@ class LIBPROTOBUF_EXPORT StringPiece {
bool empty() const { return length_ == 0; } bool empty() const { return length_ == 0; }
void clear() { void clear() {
ptr_ = NULL; ptr_ = nullptr;
length_ = 0; length_ = 0;
} }
...@@ -260,7 +260,7 @@ class LIBPROTOBUF_EXPORT StringPiece { ...@@ -260,7 +260,7 @@ class LIBPROTOBUF_EXPORT StringPiece {
void set(const char* str) { void set(const char* str) {
ptr_ = str; ptr_ = str;
if (str != NULL) if (str != nullptr)
length_ = CheckedSsizeTFromSizeT(strlen(str)); length_ = CheckedSsizeTFromSizeT(strlen(str));
else else
length_ = 0; length_ = 0;
...@@ -309,7 +309,7 @@ class LIBPROTOBUF_EXPORT StringPiece { ...@@ -309,7 +309,7 @@ class LIBPROTOBUF_EXPORT StringPiece {
// for a StringPiece be called "as_string()". We also leave the // for a StringPiece be called "as_string()". We also leave the
// "as_string()" method defined here for existing code. // "as_string()" method defined here for existing code.
string ToString() const { string ToString() const {
if (ptr_ == NULL) return string(); if (ptr_ == nullptr) return string();
return string(data(), static_cast<size_type>(size())); return string(data(), static_cast<size_type>(size()));
} }
......
...@@ -46,7 +46,7 @@ TEST(StringPiece, Ctor) { ...@@ -46,7 +46,7 @@ TEST(StringPiece, Ctor) {
{ {
// Null. // Null.
StringPiece s10; StringPiece s10;
EXPECT_TRUE(s10.data() == NULL); EXPECT_TRUE(s10.data() == nullptr);
EXPECT_EQ(0, s10.length()); EXPECT_EQ(0, s10.length());
} }
...@@ -148,8 +148,8 @@ TEST(StringPiece, ComparisonOperators) { ...@@ -148,8 +148,8 @@ TEST(StringPiece, ComparisonOperators) {
EXPECT_EQ(result, StringPiece((x)).compare(StringPiece((y))) op 0) EXPECT_EQ(result, StringPiece((x)).compare(StringPiece((y))) op 0)
COMPARE(true, ==, "", ""); COMPARE(true, ==, "", "");
COMPARE(true, ==, "", NULL); COMPARE(true, ==, "", nullptr);
COMPARE(true, ==, NULL, ""); COMPARE(true, ==, nullptr, "");
COMPARE(true, ==, "a", "a"); COMPARE(true, ==, "a", "a");
COMPARE(true, ==, "aa", "aa"); COMPARE(true, ==, "aa", "aa");
COMPARE(false, ==, "a", ""); COMPARE(false, ==, "a", "");
...@@ -253,7 +253,7 @@ TEST(StringPiece, STL1) { ...@@ -253,7 +253,7 @@ TEST(StringPiece, STL1) {
EXPECT_EQ(*d.data(), 'f'); EXPECT_EQ(*d.data(), 'f');
EXPECT_EQ(d.data()[5], 'r'); EXPECT_EQ(d.data()[5], 'r');
EXPECT_TRUE(e.data() == NULL); EXPECT_TRUE(e.data() == nullptr);
EXPECT_EQ(*a.begin(), 'a'); EXPECT_EQ(*a.begin(), 'a');
EXPECT_EQ(*(b.begin() + 2), 'c'); EXPECT_EQ(*(b.begin() + 2), 'c');
...@@ -312,7 +312,7 @@ TEST(StringPiece, STL2) { ...@@ -312,7 +312,7 @@ TEST(StringPiece, STL2) {
d.clear(); d.clear();
EXPECT_EQ(d.size(), 0); EXPECT_EQ(d.size(), 0);
EXPECT_TRUE(d.empty()); EXPECT_TRUE(d.empty());
EXPECT_TRUE(d.data() == NULL); EXPECT_TRUE(d.data() == nullptr);
EXPECT_TRUE(d.begin() == d.end()); EXPECT_TRUE(d.begin() == d.end());
EXPECT_EQ(StringPiece::npos, string::npos); EXPECT_EQ(StringPiece::npos, string::npos);
...@@ -707,17 +707,17 @@ TEST(StringPiece, Contains) { ...@@ -707,17 +707,17 @@ TEST(StringPiece, Contains) {
EXPECT_TRUE(!a.contains(d)); EXPECT_TRUE(!a.contains(d));
} }
TEST(StringPiece, NULLInput) { TEST(StringPiece, NullInput) {
// we used to crash here, but now we don't. // we used to crash here, but now we don't.
StringPiece s(NULL); StringPiece s(nullptr);
EXPECT_EQ(s.data(), (const char*)NULL); EXPECT_EQ(s.data(), (const char*)nullptr);
EXPECT_EQ(s.size(), 0); EXPECT_EQ(s.size(), 0);
s.set(NULL); s.set(nullptr);
EXPECT_EQ(s.data(), (const char*)NULL); EXPECT_EQ(s.data(), (const char*)nullptr);
EXPECT_EQ(s.size(), 0); EXPECT_EQ(s.size(), 0);
// .ToString() on a StringPiece with NULL should produce the empty string. // .ToString() on a StringPiece with nullptr should produce the empty string.
EXPECT_EQ("", s.ToString()); EXPECT_EQ("", s.ToString());
EXPECT_EQ("", s.as_string()); EXPECT_EQ("", s.as_string());
} }
......
...@@ -76,7 +76,7 @@ void StringAppendV(string* dst, const char* format, va_list ap) { ...@@ -76,7 +76,7 @@ void StringAppendV(string* dst, const char* format, va_list ap) {
// Error or MSVC running out of space. MSVC 8.0 and higher // Error or MSVC running out of space. MSVC 8.0 and higher
// can be asked about space needed with the special idiom below: // can be asked about space needed with the special idiom below:
va_copy(backup_ap, ap); va_copy(backup_ap, ap);
result = vsnprintf(NULL, 0, format, backup_ap); result = vsnprintf(nullptr, 0, format, backup_ap);
va_end(backup_ap); va_end(backup_ap);
} }
......
...@@ -91,7 +91,7 @@ TEST(StringPrintfTest, Multibyte) { ...@@ -91,7 +91,7 @@ TEST(StringPrintfTest, Multibyte) {
// out of memory while trying to determine destination buffer size. // out of memory while trying to determine destination buffer size.
// see b/4194543. // see b/4194543.
char* old_locale = setlocale(LC_CTYPE, NULL); char* old_locale = setlocale(LC_CTYPE, nullptr);
// Push locale with multibyte mode // Push locale with multibyte mode
setlocale(LC_CTYPE, "en_US.utf8"); setlocale(LC_CTYPE, "en_US.utf8");
...@@ -120,7 +120,7 @@ TEST(StringPrintfTest, Multibyte) { ...@@ -120,7 +120,7 @@ TEST(StringPrintfTest, Multibyte) {
TEST(StringPrintfTest, NoMultibyte) { TEST(StringPrintfTest, NoMultibyte) {
// No multibyte handling, but the string contains funny chars. // No multibyte handling, but the string contains funny chars.
char* old_locale = setlocale(LC_CTYPE, NULL); char* old_locale = setlocale(LC_CTYPE, nullptr);
setlocale(LC_CTYPE, "POSIX"); setlocale(LC_CTYPE, "POSIX");
string value = StringPrintf("%.*s", 3, "\375\067s"); string value = StringPrintf("%.*s", 3, "\375\067s");
setlocale(LC_CTYPE, old_locale); setlocale(LC_CTYPE, old_locale);
......
...@@ -87,7 +87,7 @@ void StripString(string* s, const char* remove, char replacewith) { ...@@ -87,7 +87,7 @@ void StripString(string* s, const char* remove, char replacewith) {
const char * str_start = s->c_str(); const char * str_start = s->c_str();
const char * str = str_start; const char * str = str_start;
for (str = strpbrk(str, remove); for (str = strpbrk(str, remove);
str != NULL; str != nullptr;
str = strpbrk(str + 1, remove)) { str = strpbrk(str + 1, remove)) {
(*s)[str - str_start] = replacewith; (*s)[str - str_start] = replacewith;
} }
...@@ -102,7 +102,7 @@ void ReplaceCharacters(string *s, const char *remove, char replacewith) { ...@@ -102,7 +102,7 @@ void ReplaceCharacters(string *s, const char *remove, char replacewith) {
const char *str_start = s->c_str(); const char *str_start = s->c_str();
const char *str = str_start; const char *str = str_start;
for (str = strpbrk(str, remove); for (str = strpbrk(str, remove);
str != NULL; str != nullptr;
str = strpbrk(str + 1, remove)) { str = strpbrk(str + 1, remove)) {
(*s)[str - str_start] = replacewith; (*s)[str - str_start] = replacewith;
} }
...@@ -280,7 +280,7 @@ static void JoinStringsIterator(const ITERATOR& start, ...@@ -280,7 +280,7 @@ static void JoinStringsIterator(const ITERATOR& start,
const ITERATOR& end, const ITERATOR& end,
const char* delim, const char* delim,
string* result) { string* result) {
GOOGLE_CHECK(result != NULL); GOOGLE_CHECK(result != nullptr);
result->clear(); result->clear();
int delim_length = strlen(delim); int delim_length = strlen(delim);
...@@ -318,7 +318,7 @@ void JoinStrings(const std::vector<string>& components, ...@@ -318,7 +318,7 @@ void JoinStrings(const std::vector<string>& components,
// result is truncated to 8 bits. // result is truncated to 8 bits.
// //
// The second call stores its errors in a supplied string vector. // The second call stores its errors in a supplied string vector.
// If the string vector pointer is NULL, it reports the errors with LOG(). // If the string vector pointer is nullptr, it reports the errors with LOG().
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
#define IS_OCTAL_DIGIT(c) (((c) >= '0') && ((c) <= '7')) #define IS_OCTAL_DIGIT(c) (((c) >= '0') && ((c) <= '7'))
...@@ -328,12 +328,12 @@ void JoinStrings(const std::vector<string>& components, ...@@ -328,12 +328,12 @@ void JoinStrings(const std::vector<string>& components,
#define LOG_STRING(LEVEL, VECTOR) GOOGLE_LOG_IF(LEVEL, false) #define LOG_STRING(LEVEL, VECTOR) GOOGLE_LOG_IF(LEVEL, false)
int UnescapeCEscapeSequences(const char* source, char* dest) { int UnescapeCEscapeSequences(const char* source, char* dest) {
return UnescapeCEscapeSequences(source, dest, NULL); return UnescapeCEscapeSequences(source, dest, nullptr);
} }
int UnescapeCEscapeSequences(const char* source, char* dest, int UnescapeCEscapeSequences(const char* source, char* dest,
std::vector<string> *errors) { std::vector<string> *errors) {
GOOGLE_DCHECK(errors == NULL) << "Error reporting not implemented."; GOOGLE_DCHECK(errors == nullptr) << "Error reporting not implemented.";
char* d = dest; char* d = dest;
const char* p = source; const char* p = source;
...@@ -458,13 +458,13 @@ int UnescapeCEscapeSequences(const char* source, char* dest, ...@@ -458,13 +458,13 @@ int UnescapeCEscapeSequences(const char* source, char* dest,
// to be the same. // to be the same.
// //
// The second call stores its errors in a supplied string vector. // The second call stores its errors in a supplied string vector.
// If the string vector pointer is NULL, it reports the errors with LOG(). // If the string vector pointer is nullptr, it reports the errors with LOG().
// //
// In the first and second calls, the length of dest is returned. In the // In the first and second calls, the length of dest is returned. In the
// the third call, the new string is returned. // the third call, the new string is returned.
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
int UnescapeCEscapeString(const string& src, string* dest) { int UnescapeCEscapeString(const string& src, string* dest) {
return UnescapeCEscapeString(src, dest, NULL); return UnescapeCEscapeString(src, dest, nullptr);
} }
int UnescapeCEscapeString(const string& src, string* dest, int UnescapeCEscapeString(const string& src, string* dest,
...@@ -478,7 +478,7 @@ int UnescapeCEscapeString(const string& src, string* dest, ...@@ -478,7 +478,7 @@ int UnescapeCEscapeString(const string& src, string* dest,
string UnescapeCEscapeString(const string& src) { string UnescapeCEscapeString(const string& src) {
std::unique_ptr<char[]> unescaped(new char[src.size() + 1]); std::unique_ptr<char[]> unescaped(new char[src.size() + 1]);
int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), NULL); int len = UnescapeCEscapeSequences(src.c_str(), unescaped.get(), nullptr);
return string(unescaped.get(), len); return string(unescaped.get(), len);
} }
...@@ -982,7 +982,7 @@ static const char two_ASCII_digits[100][2] = { ...@@ -982,7 +982,7 @@ static const char two_ASCII_digits[100][2] = {
char* FastUInt32ToBufferLeft(uint32 u, char* buffer) { char* FastUInt32ToBufferLeft(uint32 u, char* buffer) {
uint32 digits; uint32 digits;
const char *ASCII_digits = NULL; const char *ASCII_digits = nullptr;
// The idea of this implementation is to trim the number of divides to as few // The idea of this implementation is to trim the number of divides to as few
// as possible by using multiplication and subtraction rather than mod (%), // as possible by using multiplication and subtraction rather than mod (%),
// and by outputting two digits at a time rather than one. // and by outputting two digits at a time rather than one.
...@@ -1073,7 +1073,7 @@ char* FastInt32ToBufferLeft(int32 i, char* buffer) { ...@@ -1073,7 +1073,7 @@ char* FastInt32ToBufferLeft(int32 i, char* buffer) {
char* FastUInt64ToBufferLeft(uint64 u64, char* buffer) { char* FastUInt64ToBufferLeft(uint64 u64, char* buffer) {
int digits; int digits;
const char *ASCII_digits = NULL; const char *ASCII_digits = nullptr;
uint32 u = static_cast<uint32>(u64); uint32 u = static_cast<uint32>(u64);
if (u == u64) return FastUInt32ToBufferLeft(u, buffer); if (u == u64) return FastUInt32ToBufferLeft(u, buffer);
...@@ -1231,7 +1231,7 @@ static inline bool IsValidFloatChar(char c) { ...@@ -1231,7 +1231,7 @@ static inline bool IsValidFloatChar(char c) {
void DelocalizeRadix(char* buffer) { void DelocalizeRadix(char* buffer) {
// Fast check: if the buffer has a normal decimal point, assume no // Fast check: if the buffer has a normal decimal point, assume no
// translation is needed. // translation is needed.
if (strchr(buffer, '.') != NULL) return; if (strchr(buffer, '.') != nullptr) return;
// Find the first unknown character. // Find the first unknown character.
while (IsValidFloatChar(*buffer)) ++buffer; while (IsValidFloatChar(*buffer)) ++buffer;
...@@ -1286,7 +1286,7 @@ char* DoubleToBuffer(double value, char* buffer) { ...@@ -1286,7 +1286,7 @@ char* DoubleToBuffer(double value, char* buffer) {
// of a double. This long double may have extra bits that make it compare // of a double. This long double may have extra bits that make it compare
// unequal to "value" even though it would be exactly equal if it were // unequal to "value" even though it would be exactly equal if it were
// truncated to a double. // truncated to a double.
volatile double parsed_value = strtod(buffer, NULL); volatile double parsed_value = strtod(buffer, nullptr);
if (parsed_value != value) { if (parsed_value != value) {
int snprintf_result = int snprintf_result =
snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG+2, value); snprintf(buffer, kDoubleToBufferSize, "%.*g", DBL_DIG+2, value);
...@@ -1318,7 +1318,7 @@ inline bool CaseEqual(StringPiece s1, StringPiece s2) { ...@@ -1318,7 +1318,7 @@ inline bool CaseEqual(StringPiece s1, StringPiece s2) {
} }
bool safe_strtob(StringPiece str, bool* value) { bool safe_strtob(StringPiece str, bool* value) {
GOOGLE_CHECK(value != NULL) << "NULL output boolean given."; GOOGLE_CHECK(value != nullptr) << "nullptr output boolean given.";
if (CaseEqual(str, "true") || CaseEqual(str, "t") || if (CaseEqual(str, "true") || CaseEqual(str, "t") ||
CaseEqual(str, "yes") || CaseEqual(str, "y") || CaseEqual(str, "yes") || CaseEqual(str, "y") ||
CaseEqual(str, "1")) { CaseEqual(str, "1")) {
...@@ -1619,7 +1619,7 @@ void StrAppend(string *result, ...@@ -1619,7 +1619,7 @@ void StrAppend(string *result,
int GlobalReplaceSubstring(const string& substring, int GlobalReplaceSubstring(const string& substring,
const string& replacement, const string& replacement,
string* s) { string* s) {
GOOGLE_CHECK(s != NULL); GOOGLE_CHECK(s != nullptr);
if (s->empty() || substring.empty()) if (s->empty() || substring.empty())
return 0; return 0;
string tmp; string tmp;
...@@ -1969,7 +1969,7 @@ int Base64UnescapeInternal(const char *src_param, int szsrc, ...@@ -1969,7 +1969,7 @@ int Base64UnescapeInternal(const char *src_param, int szsrc,
// for (i = 0; i < 255; i += 8) { // for (i = 0; i < 255; i += 8) {
// for (j = i; j < i + 8; j++) { // for (j = i; j < i + 8; j++) {
// pos = strchr(Base64, j); // pos = strchr(Base64, j);
// if ((pos == NULL) || (j == 0)) // if ((pos == nullptr) || (j == 0))
// idx = -1; // idx = -1;
// else // else
// idx = pos - Base64; // idx = pos - Base64;
......
...@@ -285,7 +285,7 @@ inline string JoinStrings(const std::vector<string>& components, ...@@ -285,7 +285,7 @@ inline string JoinStrings(const std::vector<string>& components,
// //
// Errors: In the first form of the call, errors are reported with // Errors: In the first form of the call, errors are reported with
// LOG(ERROR). The same is true for the second form of the call if // LOG(ERROR). The same is true for the second form of the call if
// the pointer to the string std::vector is NULL; otherwise, error // the pointer to the string std::vector is nullptr; otherwise, error
// messages are stored in the std::vector. In either case, the effect on // messages are stored in the std::vector. In either case, the effect on
// the dest array is not defined, but rest of the source will be // the dest array is not defined, but rest of the source will be
// processed. // processed.
...@@ -304,7 +304,7 @@ LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest, ...@@ -304,7 +304,7 @@ LIBPROTOBUF_EXPORT int UnescapeCEscapeSequences(const char* source, char* dest,
// to be the same. // to be the same.
// //
// The second call stores its errors in a supplied string vector. // The second call stores its errors in a supplied string vector.
// If the string vector pointer is NULL, it reports the errors with LOG(). // If the string vector pointer is nullptr, it reports the errors with LOG().
// //
// In the first and second calls, the length of dest is returned. In the // In the first and second calls, the length of dest is returned. In the
// the third call, the new string is returned. // the third call, the new string is returned.
......
...@@ -50,18 +50,18 @@ namespace { ...@@ -50,18 +50,18 @@ namespace {
TEST(StringUtilityTest, ImmuneToLocales) { TEST(StringUtilityTest, ImmuneToLocales) {
// Remember the old locale. // Remember the old locale.
char* old_locale_cstr = setlocale(LC_NUMERIC, NULL); char* old_locale_cstr = setlocale(LC_NUMERIC, nullptr);
ASSERT_TRUE(old_locale_cstr != NULL); ASSERT_TRUE(old_locale_cstr != nullptr);
string old_locale = old_locale_cstr; string old_locale = old_locale_cstr;
// Set the locale to "C". // Set the locale to "C".
ASSERT_TRUE(setlocale(LC_NUMERIC, "C") != NULL); ASSERT_TRUE(setlocale(LC_NUMERIC, "C") != nullptr);
EXPECT_EQ("1.5", SimpleDtoa(1.5)); EXPECT_EQ("1.5", SimpleDtoa(1.5));
EXPECT_EQ("1.5", SimpleFtoa(1.5)); EXPECT_EQ("1.5", SimpleFtoa(1.5));
if (setlocale(LC_NUMERIC, "es_ES") == NULL && if (setlocale(LC_NUMERIC, "es_ES") == nullptr &&
setlocale(LC_NUMERIC, "es_ES.utf8") == NULL) { setlocale(LC_NUMERIC, "es_ES.utf8") == nullptr) {
// Some systems may not have the desired locale available. // Some systems may not have the desired locale available.
GOOGLE_LOG(WARNING) GOOGLE_LOG(WARNING)
<< "Couldn't set locale to es_ES. Skipping this test."; << "Couldn't set locale to es_ES. Skipping this test.";
......
...@@ -44,7 +44,7 @@ using internal::SubstituteArg; ...@@ -44,7 +44,7 @@ using internal::SubstituteArg;
// to Substitute(). // to Substitute().
static int CountSubstituteArgs(const SubstituteArg* const* args_array) { static int CountSubstituteArgs(const SubstituteArg* const* args_array) {
int count = 0; int count = 0;
while (args_array[count] != NULL && args_array[count]->size() != -1) { while (args_array[count] != nullptr && args_array[count]->size() != -1) {
++count; ++count;
} }
return count; return count;
...@@ -71,7 +71,7 @@ void SubstituteAndAppend( ...@@ -71,7 +71,7 @@ void SubstituteAndAppend(
const SubstituteArg& arg6, const SubstituteArg& arg7, const SubstituteArg& arg6, const SubstituteArg& arg7,
const SubstituteArg& arg8, const SubstituteArg& arg9) { const SubstituteArg& arg8, const SubstituteArg& arg9) {
const SubstituteArg* const args_array[] = { const SubstituteArg* const args_array[] = {
&arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, NULL &arg0, &arg1, &arg2, &arg3, &arg4, &arg5, &arg6, &arg7, &arg8, &arg9, nullptr
}; };
// Determine total size needed. // Determine total size needed.
......
...@@ -93,7 +93,7 @@ class SubstituteArg { ...@@ -93,7 +93,7 @@ class SubstituteArg {
// Indicates that no argument was given. // Indicates that no argument was given.
inline explicit SubstituteArg() inline explicit SubstituteArg()
: text_(NULL), size_(-1) {} : text_(nullptr), size_(-1) {}
// Primitives // Primitives
// We don't overload for signed and unsigned char because if people are // We don't overload for signed and unsigned char because if people are
......
...@@ -142,12 +142,12 @@ string FormatNanos(int32 nanos) { ...@@ -142,12 +142,12 @@ string FormatNanos(int32 nanos) {
// Parses an integer from a null-terminated char sequence. The method // Parses an integer from a null-terminated char sequence. The method
// consumes at most "width" chars. Returns a pointer after the consumed // consumes at most "width" chars. Returns a pointer after the consumed
// integer, or NULL if the data does not start with an integer or the // integer, or nullptr if the data does not start with an integer or the
// integer value does not fall in the range of [min_value, max_value]. // integer value does not fall in the range of [min_value, max_value].
const char* ParseInt(const char* data, int width, int min_value, const char* ParseInt(const char* data, int width, int min_value,
int max_value, int* result) { int max_value, int* result) {
if (!ascii_isdigit(*data)) { if (!ascii_isdigit(*data)) {
return NULL; return nullptr;
} }
int value = 0; int value = 0;
for (int i = 0; i < width; ++i, ++data) { for (int i = 0; i < width; ++i, ++data) {
...@@ -161,7 +161,7 @@ const char* ParseInt(const char* data, int width, int min_value, ...@@ -161,7 +161,7 @@ const char* ParseInt(const char* data, int width, int min_value,
*result = value; *result = value;
return data; return data;
} else { } else {
return NULL; return nullptr;
} }
} }
...@@ -169,7 +169,7 @@ const char* ParseInt(const char* data, int width, int min_value, ...@@ -169,7 +169,7 @@ const char* ParseInt(const char* data, int width, int min_value,
// "010" will be parsed to 10000000 nanos. // "010" will be parsed to 10000000 nanos.
const char* ParseNanos(const char* data, int32* nanos) { const char* ParseNanos(const char* data, int32* nanos) {
if (!ascii_isdigit(*data)) { if (!ascii_isdigit(*data)) {
return NULL; return nullptr;
} }
int value = 0; int value = 0;
int len = 0; int len = 0;
...@@ -193,15 +193,15 @@ const char* ParseNanos(const char* data, int32* nanos) { ...@@ -193,15 +193,15 @@ const char* ParseNanos(const char* data, int32* nanos) {
const char* ParseTimezoneOffset(const char* data, int64* offset) { const char* ParseTimezoneOffset(const char* data, int64* offset) {
// Accept format "HH:MM". E.g., "08:00" // Accept format "HH:MM". E.g., "08:00"
int hour; int hour;
if ((data = ParseInt(data, 2, 0, 23, &hour)) == NULL) { if ((data = ParseInt(data, 2, 0, 23, &hour)) == nullptr) {
return NULL; return nullptr;
} }
if (*data++ != ':') { if (*data++ != ':') {
return NULL; return nullptr;
} }
int minute; int minute;
if ((data = ParseInt(data, 2, 0, 59, &minute)) == NULL) { if ((data = ParseInt(data, 2, 0, 59, &minute)) == nullptr) {
return NULL; return nullptr;
} }
*offset = (hour * 60 + minute) * 60; *offset = (hour * 60 + minute) * 60;
return data; return data;
...@@ -264,7 +264,7 @@ bool DateTimeToSeconds(const DateTime& time, int64* seconds) { ...@@ -264,7 +264,7 @@ bool DateTimeToSeconds(const DateTime& time, int64* seconds) {
void GetCurrentTime(int64* seconds, int32* nanos) { void GetCurrentTime(int64* seconds, int32* nanos) {
// TODO(xiaofeng): Improve the accuracy of this implementation (or just // TODO(xiaofeng): Improve the accuracy of this implementation (or just
// remove this method from protobuf). // remove this method from protobuf).
*seconds = time(NULL); *seconds = time(nullptr);
*nanos = 0; *nanos = 0;
} }
...@@ -290,37 +290,37 @@ bool ParseTime(const string& value, int64* seconds, int32* nanos) { ...@@ -290,37 +290,37 @@ bool ParseTime(const string& value, int64* seconds, int32* nanos) {
// With UTC offset: 2015-05-20T13:29:35.120-08:00 // With UTC offset: 2015-05-20T13:29:35.120-08:00
// Parse year // Parse year
if ((data = ParseInt(data, 4, 1, 9999, &time.year)) == NULL) { if ((data = ParseInt(data, 4, 1, 9999, &time.year)) == nullptr) {
return false; return false;
} }
// Expect '-' // Expect '-'
if (*data++ != '-') return false; if (*data++ != '-') return false;
// Parse month // Parse month
if ((data = ParseInt(data, 2, 1, 12, &time.month)) == NULL) { if ((data = ParseInt(data, 2, 1, 12, &time.month)) == nullptr) {
return false; return false;
} }
// Expect '-' // Expect '-'
if (*data++ != '-') return false; if (*data++ != '-') return false;
// Parse day // Parse day
if ((data = ParseInt(data, 2, 1, 31, &time.day)) == NULL) { if ((data = ParseInt(data, 2, 1, 31, &time.day)) == nullptr) {
return false; return false;
} }
// Expect 'T' // Expect 'T'
if (*data++ != 'T') return false; if (*data++ != 'T') return false;
// Parse hour // Parse hour
if ((data = ParseInt(data, 2, 0, 23, &time.hour)) == NULL) { if ((data = ParseInt(data, 2, 0, 23, &time.hour)) == nullptr) {
return false; return false;
} }
// Expect ':' // Expect ':'
if (*data++ != ':') return false; if (*data++ != ':') return false;
// Parse minute // Parse minute
if ((data = ParseInt(data, 2, 0, 59, &time.minute)) == NULL) { if ((data = ParseInt(data, 2, 0, 59, &time.minute)) == nullptr) {
return false; return false;
} }
// Expect ':' // Expect ':'
if (*data++ != ':') return false; if (*data++ != ':') return false;
// Parse second // Parse second
if ((data = ParseInt(data, 2, 0, 59, &time.second)) == NULL) { if ((data = ParseInt(data, 2, 0, 59, &time.second)) == nullptr) {
return false; return false;
} }
if (!DateTimeToSeconds(time, seconds)) { if (!DateTimeToSeconds(time, seconds)) {
...@@ -330,7 +330,7 @@ bool ParseTime(const string& value, int64* seconds, int32* nanos) { ...@@ -330,7 +330,7 @@ bool ParseTime(const string& value, int64* seconds, int32* nanos) {
if (*data == '.') { if (*data == '.') {
++data; ++data;
// Parse nanoseconds. // Parse nanoseconds.
if ((data = ParseNanos(data, nanos)) == NULL) { if ((data = ParseNanos(data, nanos)) == nullptr) {
return false; return false;
} }
} else { } else {
...@@ -342,14 +342,14 @@ bool ParseTime(const string& value, int64* seconds, int32* nanos) { ...@@ -342,14 +342,14 @@ bool ParseTime(const string& value, int64* seconds, int32* nanos) {
} else if (*data == '+') { } else if (*data == '+') {
++data; ++data;
int64 offset; int64 offset;
if ((data = ParseTimezoneOffset(data, &offset)) == NULL) { if ((data = ParseTimezoneOffset(data, &offset)) == nullptr) {
return false; return false;
} }
*seconds -= offset; *seconds -= offset;
} else if (*data == '-') { } else if (*data == '-') {
++data; ++data;
int64 offset; int64 offset;
if ((data = ParseTimezoneOffset(data, &offset)) == NULL) { if ((data = ParseTimezoneOffset(data, &offset)) == nullptr) {
return false; return false;
} }
*seconds += offset; *seconds += offset;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment