Revert changes of nullptr
This commit is contained in:
parent
651f8286b1
commit
2fb9ddafc6
@ -117,14 +117,6 @@ if (NOT FMT_VARIADIC_TEMPLATES)
|
||||
add_definitions(-DGTEST_LANG_CXX11=0)
|
||||
endif ()
|
||||
|
||||
# g++ 4.6 supports nullptr with __cplusplus==1
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=1773
|
||||
check_cxx_source_compiles("
|
||||
int main(){int*p=nullptr;}" FMT_NULLPTR)
|
||||
if (FMT_NULLPTR)
|
||||
# add_definitions(-DFMT_USE_NULLPTR=1)
|
||||
endif ()
|
||||
|
||||
check_cxx_source_compiles("
|
||||
struct C{
|
||||
C()=delete;
|
||||
|
||||
16
format.cc
16
format.cc
@ -147,7 +147,7 @@ typedef void (*FormatFunc)(fmt::Writer &, int, fmt::StringRef);
|
||||
// Buffer should be at least of size 1.
|
||||
int safe_strerror(
|
||||
int error_code, char *&buffer, std::size_t buffer_size) FMT_NOEXCEPT {
|
||||
assert(buffer != nullptr && buffer_size != 0);
|
||||
assert(buffer != 0 && buffer_size != 0);
|
||||
int result = 0;
|
||||
#if ((_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && !_GNU_SOURCE) || __ANDROID__
|
||||
// XSI-compliant version of strerror_r.
|
||||
@ -457,7 +457,7 @@ FMT_FUNC void fmt::internal::report_unknown_type(char code, const char *type) {
|
||||
|
||||
FMT_FUNC fmt::internal::UTF8ToUTF16::UTF8ToUTF16(fmt::StringRef s) {
|
||||
int length = MultiByteToWideChar(
|
||||
CP_UTF8, MB_ERR_INVALID_CHARS, s.c_str(), -1, nullptr, 0);
|
||||
CP_UTF8, MB_ERR_INVALID_CHARS, s.c_str(), -1, 0, 0);
|
||||
static const char ERROR_MSG[] = "cannot convert string from UTF-8 to UTF-16";
|
||||
if (length == 0)
|
||||
FMT_THROW(WindowsError(GetLastError(), ERROR_MSG));
|
||||
@ -476,12 +476,12 @@ FMT_FUNC fmt::internal::UTF16ToUTF8::UTF16ToUTF8(fmt::WStringRef s) {
|
||||
}
|
||||
|
||||
FMT_FUNC int fmt::internal::UTF16ToUTF8::convert(fmt::WStringRef s) {
|
||||
int length = WideCharToMultiByte(CP_UTF8, 0, s.c_str(), -1, nullptr, 0, nullptr, nullptr);
|
||||
int length = WideCharToMultiByte(CP_UTF8, 0, s.c_str(), -1, 0, 0, 0, 0);
|
||||
if (length == 0)
|
||||
return GetLastError();
|
||||
buffer_.resize(length);
|
||||
length = WideCharToMultiByte(
|
||||
CP_UTF8, 0, s.c_str(), -1, &buffer_[0], length, nullptr, nullptr);
|
||||
CP_UTF8, 0, s.c_str(), -1, &buffer_[0], length, 0, 0);
|
||||
if (length == 0)
|
||||
return GetLastError();
|
||||
return 0;
|
||||
@ -536,9 +536,9 @@ FMT_FUNC void fmt::internal::format_windows_error(
|
||||
FMT_TRY {
|
||||
String system_message;
|
||||
if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr,
|
||||
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, 0,
|
||||
error_code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
reinterpret_cast<LPWSTR>(system_message.ptr()), 0, nullptr)) {
|
||||
reinterpret_cast<LPWSTR>(system_message.ptr()), 0, 0)) {
|
||||
UTF16ToUTF8 utf8_message;
|
||||
if (utf8_message.convert(system_message.c_str()) == ERROR_SUCCESS) {
|
||||
out << message << ": " << utf8_message;
|
||||
@ -648,7 +648,7 @@ void fmt::BasicWriter<Char>::write_str(
|
||||
|
||||
template <typename Char>
|
||||
inline Arg fmt::BasicFormatter<Char>::parse_arg_index(const Char *&s) {
|
||||
const char *error = nullptr;
|
||||
const char *error = 0;
|
||||
Arg arg = *s < '0' || *s > '9' ?
|
||||
next_arg(error) : get_arg(parse_nonnegative_int(s), error);
|
||||
if (error) {
|
||||
@ -713,7 +713,7 @@ void fmt::internal::PrintfFormatter<Char>::parse_flags(
|
||||
template <typename Char>
|
||||
Arg fmt::internal::PrintfFormatter<Char>::get_arg(
|
||||
const Char *s, unsigned arg_index) {
|
||||
const char *error = nullptr;
|
||||
const char *error = 0;
|
||||
Arg arg = arg_index == UINT_MAX ?
|
||||
next_arg(error) : FormatterBase::get_arg(arg_index - 1, error);
|
||||
if (error)
|
||||
|
||||
11
format.h
11
format.h
@ -133,15 +133,6 @@
|
||||
TypeName& operator=(const TypeName&)
|
||||
#endif
|
||||
|
||||
#if FMT_USE_NULLPTR || FMT_HAS_FEATURE(cxx_nullptr)\
|
||||
|| (FMT_GCC_VERSION >= 406 && __cplusplus >= 201103L)\
|
||||
|| (_MSC_VER >= 1600)
|
||||
// Use nullptr
|
||||
#elif !defined(nullptr)
|
||||
// Some standard library implementations define nullptr themselves such as libc++
|
||||
# define nullptr 0
|
||||
#endif
|
||||
|
||||
namespace fmt {
|
||||
|
||||
// Fix the warning about long long on older versions of GCC
|
||||
@ -280,7 +271,7 @@ class Buffer {
|
||||
std::size_t size_;
|
||||
std::size_t capacity_;
|
||||
|
||||
Buffer(T *ptr = nullptr, std::size_t capacity = 0)
|
||||
Buffer(T *ptr = 0, std::size_t capacity = 0)
|
||||
: ptr_(ptr), size_(0), capacity_(capacity) {}
|
||||
|
||||
virtual void grow(std::size_t size) = 0;
|
||||
|
||||
2
posix.cc
2
posix.cc
@ -92,7 +92,7 @@ void fmt::BufferedFile::close() {
|
||||
if (!file_)
|
||||
return;
|
||||
int result = FMT_SYSTEM(fclose(file_));
|
||||
file_ = nullptr;
|
||||
file_ = 0;
|
||||
if (result != 0)
|
||||
throw SystemError(errno, "cannot close file");
|
||||
}
|
||||
|
||||
8
posix.h
8
posix.h
@ -113,7 +113,7 @@ class BufferedFile {
|
||||
|
||||
public:
|
||||
// Constructs a BufferedFile object which doesn't represent any file.
|
||||
BufferedFile() FMT_NOEXCEPT : file_(nullptr) {}
|
||||
BufferedFile() FMT_NOEXCEPT : file_(0) {}
|
||||
|
||||
// Destroys the object closing the file it represents if any.
|
||||
~BufferedFile() FMT_NOEXCEPT;
|
||||
@ -167,13 +167,13 @@ public:
|
||||
|
||||
public:
|
||||
BufferedFile(BufferedFile &&other) FMT_NOEXCEPT : file_(other.file_) {
|
||||
other.file_ = nullptr;
|
||||
other.file_ = 0;
|
||||
}
|
||||
|
||||
BufferedFile& operator=(BufferedFile &&other) {
|
||||
close();
|
||||
file_ = other.file_;
|
||||
other.file_ = nullptr;
|
||||
other.file_ = 0;
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
@ -182,7 +182,7 @@ public:
|
||||
BufferedFile(fmt::StringRef filename, fmt::StringRef mode);
|
||||
|
||||
// Gets whether a file is opened
|
||||
bool is_open() const FMT_NOEXCEPT { return file_ != nullptr; }
|
||||
bool is_open() const FMT_NOEXCEPT { return file_ != 0; }
|
||||
|
||||
// Closes the file.
|
||||
void close();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user