[libc++] Replace several uses of 0 by nullptr
Differential Revision: https://reviews.llvm.org/D43159
GitOrigin-RevId: 527a7fdfbd7461e2aaa9eb279543c5d9dc8efa5a
diff --git a/include/fstream b/include/fstream
index 1e2d607..af8476c 100644
--- a/include/fstream
+++ b/include/fstream
@@ -287,13 +287,13 @@
template <class _CharT, class _Traits>
basic_filebuf<_CharT, _Traits>::basic_filebuf()
- : __extbuf_(0),
- __extbufnext_(0),
- __extbufend_(0),
+ : __extbuf_(nullptr),
+ __extbufnext_(nullptr),
+ __extbufend_(nullptr),
__ebs_(0),
- __intbuf_(0),
+ __intbuf_(nullptr),
__ibs_(0),
- __file_(0),
+ __file_(nullptr),
__cv_(nullptr),
__st_(),
__st_last_(),
@@ -308,7 +308,7 @@
__cv_ = &use_facet<codecvt<char_type, char, state_type> >(this->getloc());
__always_noconv_ = __cv_->always_noconv();
}
- setbuf(0, 4096);
+ setbuf(nullptr, 4096);
}
#ifndef _LIBCPP_CXX03_LANG
@@ -360,13 +360,13 @@
(char_type*)__extbuf_ + (__rhs.gptr() - __rhs.eback()),
(char_type*)__extbuf_ + (__rhs.egptr() - __rhs.eback()));
}
- __rhs.__extbuf_ = 0;
- __rhs.__extbufnext_ = 0;
- __rhs.__extbufend_ = 0;
+ __rhs.__extbuf_ = nullptr;
+ __rhs.__extbufnext_ = nullptr;
+ __rhs.__extbufend_ = nullptr;
__rhs.__ebs_ = 0;
__rhs.__intbuf_ = 0;
__rhs.__ibs_ = 0;
- __rhs.__file_ = 0;
+ __rhs.__file_ = nullptr;
__rhs.__st_ = state_type();
__rhs.__st_last_ = state_type();
__rhs.__om_ = 0;
@@ -500,7 +500,7 @@
bool
basic_filebuf<_CharT, _Traits>::is_open() const
{
- return __file_ != 0;
+ return __file_ != nullptr;
}
template <class _CharT, class _Traits>
@@ -548,8 +548,8 @@
basic_filebuf<_CharT, _Traits>*
basic_filebuf<_CharT, _Traits>::open(const char* __s, ios_base::openmode __mode)
{
- basic_filebuf<_CharT, _Traits>* __rt = 0;
- if (__file_ == 0)
+ basic_filebuf<_CharT, _Traits>* __rt = nullptr;
+ if (__file_ == nullptr)
{
if (const char* __mdstr = __make_mdstring(__mode)) {
__rt = this;
@@ -559,12 +559,12 @@
if (__mode & ios_base::ate) {
if (fseek(__file_, 0, SEEK_END)) {
fclose(__file_);
- __file_ = 0;
- __rt = 0;
+ __file_ = nullptr;
+ __rt = nullptr;
}
}
} else
- __rt = 0;
+ __rt = nullptr;
}
}
return __rt;
@@ -574,8 +574,8 @@
inline _LIBCPP_INLINE_VISIBILITY
basic_filebuf<_CharT, _Traits>*
basic_filebuf<_CharT, _Traits>::__open(int __fd, ios_base::openmode __mode) {
- basic_filebuf<_CharT, _Traits>* __rt = 0;
- if (__file_ == 0) {
+ basic_filebuf<_CharT, _Traits>* __rt = nullptr;
+ if (__file_ == nullptr) {
if (const char* __mdstr = __make_mdstring(__mode)) {
__rt = this;
__file_ = fdopen(__fd, __mdstr);
@@ -584,12 +584,12 @@
if (__mode & ios_base::ate) {
if (fseek(__file_, 0, SEEK_END)) {
fclose(__file_);
- __file_ = 0;
- __rt = 0;
+ __file_ = nullptr;
+ __rt = nullptr;
}
}
} else
- __rt = 0;
+ __rt = nullptr;
}
}
return __rt;
@@ -602,8 +602,8 @@
basic_filebuf<_CharT, _Traits>*
basic_filebuf<_CharT, _Traits>::open(const wchar_t* __s, ios_base::openmode __mode)
{
- basic_filebuf<_CharT, _Traits>* __rt = 0;
- if (__file_ == 0)
+ basic_filebuf<_CharT, _Traits>* __rt = nullptr;
+ if (__file_ == nullptr)
{
__rt = this;
const wchar_t* __mdstr;
@@ -652,7 +652,7 @@
__mdstr = L"a+b";
break;
default:
- __rt = 0;
+ __rt = nullptr;
break;
}
if (__rt)
@@ -666,13 +666,13 @@
if (fseek(__file_, 0, SEEK_END))
{
fclose(__file_);
- __file_ = 0;
- __rt = 0;
+ __file_ = nullptr;
+ __rt = nullptr;
}
}
}
else
- __rt = 0;
+ __rt = nullptr;
}
}
return __rt;
@@ -692,16 +692,16 @@
basic_filebuf<_CharT, _Traits>*
basic_filebuf<_CharT, _Traits>::close()
{
- basic_filebuf<_CharT, _Traits>* __rt = 0;
+ basic_filebuf<_CharT, _Traits>* __rt = nullptr;
if (__file_)
{
__rt = this;
unique_ptr<FILE, int(*)(FILE*)> __h(__file_, fclose);
if (sync())
- __rt = 0;
+ __rt = nullptr;
if (fclose(__h.release()))
- __rt = 0;
- __file_ = 0;
+ __rt = nullptr;
+ __file_ = nullptr;
setbuf(0, 0);
}
return __rt;
@@ -711,11 +711,11 @@
typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::underflow()
{
- if (__file_ == 0)
+ if (__file_ == nullptr)
return traits_type::eof();
bool __initial = __read_mode();
char_type __1buf;
- if (this->gptr() == 0)
+ if (this->gptr() == nullptr)
this->setg(&__1buf, &__1buf+1, &__1buf+1);
const size_t __unget_sz = __initial ? 0 : min<size_t>((this->egptr() - this->eback()) / 2, 4);
int_type __c = traits_type::eof();
@@ -773,7 +773,7 @@
else
__c = traits_type::to_int_type(*this->gptr());
if (this->eback() == &__1buf)
- this->setg(0, 0, 0);
+ this->setg(nullptr, nullptr, nullptr);
return __c;
}
@@ -803,7 +803,7 @@
typename basic_filebuf<_CharT, _Traits>::int_type
basic_filebuf<_CharT, _Traits>::overflow(int_type __c)
{
- if (__file_ == 0)
+ if (__file_ == nullptr)
return traits_type::eof();
__write_mode();
char_type __1buf;
@@ -811,7 +811,7 @@
char_type* __epb_save = this->epptr();
if (!traits_type::eq_int_type(__c, traits_type::eof()))
{
- if (this->pptr() == 0)
+ if (this->pptr() == nullptr)
this->setp(&__1buf, &__1buf+1);
*this->pptr() = traits_type::to_char_type(__c);
this->pbump(1);
@@ -868,8 +868,8 @@
basic_streambuf<_CharT, _Traits>*
basic_filebuf<_CharT, _Traits>::setbuf(char_type* __s, streamsize __n)
{
- this->setg(0, 0, 0);
- this->setp(0, 0);
+ this->setg(nullptr, nullptr, nullptr);
+ this->setp(nullptr, nullptr);
if (__owns_eb_)
delete [] __extbuf_;
if (__owns_ib_)
@@ -911,7 +911,7 @@
else
{
__ibs_ = 0;
- __intbuf_ = 0;
+ __intbuf_ = nullptr;
__owns_ib_ = false;
}
return this;
@@ -926,7 +926,7 @@
__throw_bad_cast();
int __width = __cv_->encoding();
- if (__file_ == 0 || (__width <= 0 && __off != 0) || sync())
+ if (__file_ == nullptr || (__width <= 0 && __off != 0) || sync())
return pos_type(off_type(-1));
// __width > 0 || __off == 0
int __whence;
@@ -961,7 +961,7 @@
typename basic_filebuf<_CharT, _Traits>::pos_type
basic_filebuf<_CharT, _Traits>::seekpos(pos_type __sp, ios_base::openmode)
{
- if (__file_ == 0 || sync())
+ if (__file_ == nullptr || sync())
return pos_type(off_type(-1));
#if defined(_LIBCPP_HAS_NO_OFF_T_FUNCTIONS)
if (fseek(__file_, __sp, SEEK_SET))
@@ -978,7 +978,7 @@
int
basic_filebuf<_CharT, _Traits>::sync()
{
- if (__file_ == 0)
+ if (__file_ == nullptr)
return 0;
if (!__cv_)
__throw_bad_cast();
@@ -1037,7 +1037,7 @@
if (__update_st)
__st_ = __state;
__extbufnext_ = __extbufend_ = __extbuf_;
- this->setg(0, 0, 0);
+ this->setg(nullptr, nullptr, nullptr);
__cm_ = 0;
}
return 0;
@@ -1053,8 +1053,8 @@
__always_noconv_ = __cv_->always_noconv();
if (__old_anc != __always_noconv_)
{
- this->setg(0, 0, 0);
- this->setp(0, 0);
+ this->setg(nullptr, nullptr, nullptr);
+ this->setp(nullptr, nullptr);
// invariant, char_type is char, else we couldn't get here
if (__always_noconv_) // need to dump __intbuf_
{
@@ -1064,7 +1064,7 @@
__ebs_ = __ibs_;
__extbuf_ = (char*)__intbuf_;
__ibs_ = 0;
- __intbuf_ = 0;
+ __intbuf_ = nullptr;
__owns_ib_ = false;
}
else // need to obtain an __intbuf_.
@@ -1093,7 +1093,7 @@
{
if (!(__cm_ & ios_base::in))
{
- this->setp(0, 0);
+ this->setp(nullptr, nullptr);
if (__always_noconv_)
this->setg((char_type*)__extbuf_,
(char_type*)__extbuf_ + __ebs_,
@@ -1112,7 +1112,7 @@
{
if (!(__cm_ & ios_base::out))
{
- this->setg(0, 0, 0);
+ this->setg(nullptr, nullptr, nullptr);
if (__ebs_ > sizeof(__extbuf_min_))
{
if (__always_noconv_)
@@ -1122,7 +1122,7 @@
this->setp(__intbuf_, __intbuf_ + (__ibs_ - 1));
}
else
- this->setp(0, 0);
+ this->setp(nullptr, nullptr);
__cm_ = ios_base::out;
}
}
@@ -1208,7 +1208,7 @@
basic_ifstream<_CharT, _Traits>::basic_ifstream(const char* __s, ios_base::openmode __mode)
: basic_istream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode | ios_base::in) == 0)
+ if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
this->setstate(ios_base::failbit);
}
@@ -1218,7 +1218,7 @@
basic_ifstream<_CharT, _Traits>::basic_ifstream(const wchar_t* __s, ios_base::openmode __mode)
: basic_istream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode | ios_base::in) == 0)
+ if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
this->setstate(ios_base::failbit);
}
#endif
@@ -1228,7 +1228,7 @@
basic_ifstream<_CharT, _Traits>::basic_ifstream(const string& __s, ios_base::openmode __mode)
: basic_istream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode | ios_base::in) == 0)
+ if (__sb_.open(__s, __mode | ios_base::in) == nullptr)
this->setstate(ios_base::failbit);
}
#endif
@@ -1421,7 +1421,7 @@
basic_ofstream<_CharT, _Traits>::basic_ofstream(const char* __s, ios_base::openmode __mode)
: basic_ostream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode | ios_base::out) == 0)
+ if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
this->setstate(ios_base::failbit);
}
@@ -1431,7 +1431,7 @@
basic_ofstream<_CharT, _Traits>::basic_ofstream(const wchar_t* __s, ios_base::openmode __mode)
: basic_ostream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode | ios_base::out) == 0)
+ if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
this->setstate(ios_base::failbit);
}
#endif
@@ -1441,7 +1441,7 @@
basic_ofstream<_CharT, _Traits>::basic_ofstream(const string& __s, ios_base::openmode __mode)
: basic_ostream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode | ios_base::out) == 0)
+ if (__sb_.open(__s, __mode | ios_base::out) == nullptr)
this->setstate(ios_base::failbit);
}
#endif
@@ -1550,7 +1550,7 @@
void
basic_ofstream<_CharT, _Traits>::close()
{
- if (__sb_.close() == 0)
+ if (__sb_.close() == nullptr)
this->setstate(ios_base::failbit);
}
@@ -1634,7 +1634,7 @@
basic_fstream<_CharT, _Traits>::basic_fstream(const char* __s, ios_base::openmode __mode)
: basic_iostream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode) == 0)
+ if (__sb_.open(__s, __mode) == nullptr)
this->setstate(ios_base::failbit);
}
@@ -1644,7 +1644,7 @@
basic_fstream<_CharT, _Traits>::basic_fstream(const wchar_t* __s, ios_base::openmode __mode)
: basic_iostream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode) == 0)
+ if (__sb_.open(__s, __mode) == nullptr)
this->setstate(ios_base::failbit);
}
#endif
@@ -1654,7 +1654,7 @@
basic_fstream<_CharT, _Traits>::basic_fstream(const string& __s, ios_base::openmode __mode)
: basic_iostream<char_type, traits_type>(&__sb_)
{
- if (__sb_.open(__s, __mode) == 0)
+ if (__sb_.open(__s, __mode) == nullptr)
this->setstate(ios_base::failbit);
}
#endif
@@ -1754,7 +1754,7 @@
void
basic_fstream<_CharT, _Traits>::close()
{
- if (__sb_.close() == 0)
+ if (__sb_.close() == nullptr)
this->setstate(ios_base::failbit);
}