From 782aae9d3f7f40ccd4c308a09a27a5812b9dbd68 Mon Sep 17 00:00:00 2001 From: Richard Kimberly Heck Date: Sat, 29 Feb 2020 00:00:47 -0500 Subject: [PATCH] Fix warnings in support/. --- src/support/ForkedCalls.cpp | 2 +- src/support/convert.cpp | 14 +++++++------- src/support/docstream.cpp | 2 +- src/support/filetools.cpp | 2 +- src/support/gzstream.cpp | 10 +++++----- src/support/lassert.cpp | 5 +++-- src/support/lyxtime.cpp | 2 +- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/support/ForkedCalls.cpp b/src/support/ForkedCalls.cpp index f81c1d20a9..1318bd3ec2 100644 --- a/src/support/ForkedCalls.cpp +++ b/src/support/ForkedCalls.cpp @@ -374,7 +374,7 @@ int ForkedCall::generateChild() argv.push_back(&*it); prev = *it; } - argv.push_back(0); + argv.push_back(nullptr); // Debug output. if (lyxerr.debugging(Debug::FILES)) { diff --git a/src/support/convert.cpp b/src/support/convert.cpp index 9455643a66..74b1282201 100644 --- a/src/support/convert.cpp +++ b/src/support/convert.cpp @@ -179,49 +179,49 @@ docstring convert(double d) template<> int convert(string const s) { - return strtol(s.c_str(), 0, 10); + return strtol(s.c_str(), nullptr, 10); } template<> int convert(docstring const s) { - return strtol(to_ascii(s).c_str(), 0, 10); + return strtol(to_ascii(s).c_str(), nullptr, 10); } template<> unsigned int convert(string const s) { - return strtoul(s.c_str(), 0, 10); + return strtoul(s.c_str(), nullptr, 10); } template<> unsigned long convert(string const s) { - return strtoul(s.c_str(), 0, 10); + return strtoul(s.c_str(), nullptr, 10); } template<> double convert(string const s) { - return strtod(s.c_str(), 0); + return strtod(s.c_str(), nullptr); } template<> int convert(char const * cptr) { - return strtol(cptr, 0, 10); + return strtol(cptr, nullptr, 10); } template<> double convert(char const * cptr) { - return strtod(cptr, 0); + return strtod(cptr, nullptr); } diff --git a/src/support/docstream.cpp b/src/support/docstream.cpp index f8964cae60..eef5b0361e 100644 --- a/src/support/docstream.cpp +++ b/src/support/docstream.cpp @@ -120,7 +120,7 @@ protected: // As a workaround, we append a nul char in order to force // a switch to ASCII, and then remove it from output after // the conversion. - intern_type * from_new = 0; + intern_type * from_new = nullptr; intern_type const * from_old = from; size_t extra = 0; if (*(from_end - 1) >= 0x80 && encoding_ == "ISO-2022-JP") { diff --git a/src/support/filetools.cpp b/src/support/filetools.cpp index a34ee225f9..d17d04cc5e 100644 --- a/src/support/filetools.cpp +++ b/src/support/filetools.cpp @@ -110,7 +110,7 @@ bool isBinaryFile(FileName const & filename) magic_t magic_cookie = magic_open(MAGIC_MIME_ENCODING); if (magic_cookie) { bool detected = true; - if (magic_load(magic_cookie, NULL) != 0) { + if (magic_load(magic_cookie, nullptr) != 0) { LYXERR(Debug::FILES, "isBinaryFile: " "Could not load magic database - " << magic_error(magic_cookie)); diff --git a/src/support/gzstream.cpp b/src/support/gzstream.cpp index dfad9956bd..232e86bb3d 100644 --- a/src/support/gzstream.cpp +++ b/src/support/gzstream.cpp @@ -51,12 +51,12 @@ namespace GZSTREAM_NAMESPACE { gzstreambuf* gzstreambuf::open( const char* name, int open_mode) { if ( is_open()) - return (gzstreambuf*)0; + return (gzstreambuf*)(nullptr); mode = open_mode; // no append nor read/write mode if ((mode & ios::ate) || (mode & ios::app) || ((mode & ios::in) && (mode & ios::out))) - return (gzstreambuf*)0; + return (gzstreambuf*)(nullptr); char fmode[10]; char* fmodeptr = fmode; if ( mode & ios::in) @@ -66,8 +66,8 @@ gzstreambuf* gzstreambuf::open( const char* name, int open_mode) { *fmodeptr++ = 'b'; *fmodeptr = '\0'; file = gzopen( name, fmode); - if (file == 0) - return (gzstreambuf*)0; + if (file == nullptr) + return (gzstreambuf*)(nullptr); opened = 1; return this; } @@ -79,7 +79,7 @@ gzstreambuf * gzstreambuf::close() { if ( gzclose( file) == Z_OK) return this; } - return (gzstreambuf*)0; + return (gzstreambuf*)(nullptr); } int gzstreambuf::underflow() { // used for input buffer only diff --git a/src/support/lassert.cpp b/src/support/lassert.cpp index c690dbcee0..2634749480 100644 --- a/src/support/lassert.cpp +++ b/src/support/lassert.cpp @@ -111,7 +111,7 @@ docstring printCallStack() docstring bt; for (size_t i = 1; i < size && messages != NULL; i++) { const std::string orig(messages[i]); - char* mangled = 0; + char* mangled = nullptr; for (char *p = messages[i]; *p; ++p) { if (*p == '(') { *p = 0; @@ -122,7 +122,8 @@ docstring printCallStack() } } int status = 0; - const char* demangled = abi::__cxa_demangle(mangled, 0, 0, &status); + const char* demangled = + abi::__cxa_demangle(mangled, nullptr, nullptr, &status); const QByteArray line = QString("(%1) %2: %3\n").arg(i, 3).arg(messages[i]) .arg(demangled ? demangled : orig.c_str()).toLocal8Bit(); free((void*)demangled); diff --git a/src/support/lyxtime.cpp b/src/support/lyxtime.cpp index f3318eb3f0..c155ed428d 100644 --- a/src/support/lyxtime.cpp +++ b/src/support/lyxtime.cpp @@ -27,7 +27,7 @@ namespace support { time_t current_time() { - return time(0); + return time(nullptr); } -- 2.39.5