[pan] start working on replacing 0 with nullptr
- From: Dominique Dumont <ddumont src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan] start working on replacing 0 with nullptr
- Date: Mon, 3 Oct 2022 16:48:33 +0000 (UTC)
commit 5452260d545683d8053846af2987d4d67e1dacbe
Author: Thomas Tanner <thosrtanner58 yahoo com>
Date: Tue Sep 27 20:55:14 2022 +0100
start working on replacing 0 with nullptr
configure.ac | 2 +-
pan/general/e-util.h | 2 +-
pan/general/file-util.cc | 4 ++--
pan/general/file-util.h | 4 ++--
pan/general/line-reader.cc | 4 ++--
pan/general/quark.h | 16 ++++++++--------
pan/general/string-view.cc | 20 ++++++++++----------
pan/general/string-view.h | 6 +++---
pan/general/utf8-utils.h | 10 +++++-----
uulib/crc32.h | 3 ++-
10 files changed, 36 insertions(+), 35 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f2d55d5..694a8f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -320,7 +320,7 @@ esac
AM_CONDITIONAL([HAVE_WIN32],[test "$win32" = "yes"])
dnl Sanity checking
-CXXFLAGS="$CXXFLAGS -Wreorder"
+CXXFLAGS="$CXXFLAGS -Wreorder -Wzero-as-null-pointer-constant"
dnl Build the output files
AC_SUBST(panlocaledir)
diff --git a/pan/general/e-util.h b/pan/general/e-util.h
index 3893f8a..bf376a1 100644
--- a/pan/general/e-util.h
+++ b/pan/general/e-util.h
@@ -49,7 +49,7 @@ class EvolutionDateMaker
struct tm last_seven_days[7]; // [0=yesterday ... 6=one week ago]
public:
- EvolutionDateMaker (time_t n=time(0));
+ EvolutionDateMaker (time_t n=time(nullptr));
~EvolutionDateMaker ();
char* get_date_string (time_t date) const;
};
diff --git a/pan/general/file-util.cc b/pan/general/file-util.cc
index 79cb66b..e69f616 100644
--- a/pan/general/file-util.cc
+++ b/pan/general/file-util.cc
@@ -303,9 +303,9 @@ file :: get_text_file_contents (const StringView & filename,
const char * fallback_charset_2)
{
// read in the file...
- char * body (0);
+ char * body (nullptr);
gsize body_len (0);
- GError * err (0);
+ GError * err (nullptr);
const std::string fname (filename.str, filename.len);
g_file_get_contents (fname.c_str(), &body, &body_len, &err);
if (err) {
diff --git a/pan/general/file-util.h b/pan/general/file-util.h
index 59314ec..d004dc9 100644
--- a/pan/general/file-util.h
+++ b/pan/general/file-util.h
@@ -101,8 +101,8 @@ namespace pan
*/
bool get_text_file_contents (const StringView & filename,
std::string & setme,
- const char * fallback_charset_1=0,
- const char * fallback_charset_2=0);
+ const char * fallback_charset_1=nullptr,
+ const char * fallback_charset_2=nullptr);
};
}
diff --git a/pan/general/line-reader.cc b/pan/general/line-reader.cc
index 6b80fc4..8ce01ec 100644
--- a/pan/general/line-reader.cc
+++ b/pan/general/line-reader.cc
@@ -32,7 +32,7 @@ bool
FileLineReader :: getline (StringView& setme)
{
const char * eoln ((const char*) memchr ((const void*)_pos, '\n', _end-_pos));
- if (eoln != 0) // found an end of line... easy case.
+ if (eoln != nullptr) // found an end of line... easy case.
{
setme.assign (_pos, eoln-_pos);
_pos = eoln + 1;
@@ -55,7 +55,7 @@ FileLineReader :: getline (StringView& setme)
_bufend = _buf + _alloc_size;
free (oldbuf);
}
- const int readval (_fp!=0 ? fread ((char*)_end, 1, _bufend-_end, _fp) : 0);
+ const int readval (_fp!=nullptr ? fread ((char*)_end, 1, _bufend-_end, _fp) : 0);
_end += readval;
if (readval > 0) // new content to try
return getline (setme);
diff --git a/pan/general/quark.h b/pan/general/quark.h
index f4a8b58..ad8edaa 100644
--- a/pan/general/quark.h
+++ b/pan/general/quark.h
@@ -66,7 +66,7 @@ namespace pan
uint32_t refcount;
uint32_t len;
char * str;
- Impl (): refcount(0), len(0), str(0) {}
+ Impl (): refcount(0), len(0), str(nullptr) {}
Impl (const StringView& v): refcount(0), len(v.len), str(const_cast<char*>(v.str)) {}
StringView to_view () const { return StringView(str,len); }
//wtf? bool operator() (const Impl& a, const Impl& b) const { return StringView(str,len) ==
StringView(b.str,b.len); }
@@ -166,12 +166,12 @@ namespace pan
}
void unref () {
- if (impl!=0) {
+ if (impl!=nullptr) {
assert (impl->refcount);
if (!--impl->refcount) {
const Impl tmp (*impl);
_lookup.erase (tmp);
- impl = 0;
+ impl = nullptr;
delete [] (char*)tmp.str;
}
}
@@ -181,25 +181,25 @@ namespace pan
Impl * impl;
public:
- Quark (): impl(0) {}
+ Quark (): impl(nullptr) {}
Quark (const std::string & s): impl (init (StringView (s))) { }
Quark (const char * s): impl (init (StringView (s))) { }
Quark (const StringView & p): impl (init (p)) { }
Quark (const Quark& q) {
- if (q.impl != 0) ++q.impl->refcount;
+ if (q.impl != nullptr) ++q.impl->refcount;
impl = q.impl;
}
Quark& operator= (const Quark& q) {
- if (q.impl != 0) ++q.impl->refcount;
+ if (q.impl != nullptr) ++q.impl->refcount;
unref ();
impl = q.impl;
return *this;
}
~Quark () { clear(); }
- void clear () { unref(); impl=0; }
- bool empty() const { return impl == 0; }
+ void clear () { unref(); impl=nullptr; }
+ bool empty() const { return impl == nullptr; }
bool operator== (const char * that) const {
const char * pch = c_str ();
if (!pch && !that) return true;
diff --git a/pan/general/string-view.cc b/pan/general/string-view.cc
index 07627a5..a7a5e12 100644
--- a/pan/general/string-view.cc
+++ b/pan/general/string-view.cc
@@ -51,7 +51,7 @@ StringView :: strrchr (const char * haystack,
size_t haystack_len,
char needle)
{
- const char * pch (0);
+ const char * pch (nullptr);
pan_return_val_if_fail (haystack!=NULL || haystack_len==0, NULL);
@@ -67,7 +67,7 @@ StringView :: strrchr (const char * haystack,
return (char*) pch;
}
-
+
int
StringView :: strncpy (char * target,
size_t target_size,
@@ -94,10 +94,10 @@ StringView :: strstr (const char * haystack,
return NULL;
assert (needle != NULL);
-
+
if (needle_len == 0)
return (char*) haystack;
-
+
if (haystack_len < needle_len)
return NULL;
@@ -109,7 +109,7 @@ StringView :: strstr (const char * haystack,
++s;
}
- return 0;
+ return nullptr;
}
char*
@@ -118,14 +118,14 @@ StringView :: strpbrk (const char * haystack,
const char * needles)
{
if (!haystack || !needles)
- return 0;
+ return nullptr;
for ( ; haystack_len && *haystack; ++haystack, --haystack_len )
for (const char *p=needles; *p; ++p)
if (*haystack == *p)
return (char *) haystack;
- return 0;
+ return nullptr;
}
@@ -183,7 +183,7 @@ StringView :: pop_token (StringView& token, char delimiter)
} else {
token.str = str;
token.len = len;
- str = 0;
+ str = nullptr;
len = 0;
}
return got_token;
@@ -201,7 +201,7 @@ StringView :: pop_last_token (StringView& token, char delimiter)
} else {
token.str = str;
token.len = len;
- str = 0;
+ str = nullptr;
len = 0;
}
@@ -236,7 +236,7 @@ StringView :: eat_chars (size_t n)
{
n = std::min (n, len);
len -= n;
- str = len ? str+n : 0;
+ str = len ? str+n : nullptr;
}
void
diff --git a/pan/general/string-view.h b/pan/general/string-view.h
index bff967d..3b20c8a 100644
--- a/pan/general/string-view.h
+++ b/pan/general/string-view.h
@@ -80,7 +80,7 @@ namespace pan
public:
- StringView (): str(0), len(0) {}
+ StringView (): str(nullptr), len(0) {}
StringView (const std::string& s) { assign(s); }
StringView (const char * s) { assign(s); }
StringView (const char * s, size_t l) { assign(s,l); }
@@ -129,7 +129,7 @@ namespace pan
return strcmp (str, len, s, l); }
char* strchr (char needle, size_t p=0) const {
- return p<len ? strchr (str+p, len-p, needle) : 0; }
+ return p<len ? strchr (str+p, len-p, needle) : nullptr; }
char* strrchr (char needle) const {
return strrchr (str, len, needle); }
@@ -152,7 +152,7 @@ namespace pan
StringView& operator= (const char * s) { str=s; len=s?strlen(s):0; return *this; }
void assign (const char * s, size_t l) { str=s; len=l; }
- void clear () { str=0; len=0; }
+ void clear () { str=nullptr; len=0; }
void trim ();
void ltrim ();
diff --git a/pan/general/utf8-utils.h b/pan/general/utf8-utils.h
index bb22ebb..e531f24 100644
--- a/pan/general/utf8-utils.h
+++ b/pan/general/utf8-utils.h
@@ -27,15 +27,15 @@
namespace pan
{
std::string header_to_utf8 (const StringView & in,
- const char * fallback_charset_1=0,
- const char * fallback_charset_2=0);
+ const char * fallback_charset_1=nullptr,
+ const char * fallback_charset_2=nullptr);
std::string mime_part_to_utf8 (GMimePart * part,
- const char * fallback_charset=0);
+ const char * fallback_charset=nullptr);
std::string content_to_utf8 (const StringView & in,
- const char * fallback_charset_1=0,
- const char * fallback_charset_2=0);
+ const char * fallback_charset_1=nullptr,
+ const char * fallback_charset_2=nullptr);
std::string clean_utf8 (const StringView & in);
}
diff --git a/uulib/crc32.h b/uulib/crc32.h
index 17dc529..ea6e0fe 100644
--- a/uulib/crc32.h
+++ b/uulib/crc32.h
@@ -14,7 +14,8 @@ extern "C" {
#endif
typedef unsigned long crc32_t;
-#define Z_NULL 0
+#undef Z_NULL
+#define Z_NULL nullptr
#ifdef __cplusplus
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]