summaryrefslogtreecommitdiffstats
path: root/src/io
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-06-15 10:46:15 +0000
committerMarc Jeanmougin <marcjeanmougin@free.fr>2018-06-18 12:27:01 +0000
commitf4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43 (patch)
tree7c6044fd3a17a2665841959dac9b3b2110b27924 /src/io
parentRun clang-tidy’s modernize-use-override pass. (diff)
downloadinkscape-f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43.tar.gz
inkscape-f4349fb3e45bd44cef0e2b69af4c9b4cf35dcf43.zip
Run clang-tidy’s modernize-use-nullptr pass.
This replaces all NULL or 0 with nullptr when assigned to or returned as a pointer.
Diffstat (limited to 'src/io')
-rw-r--r--src/io/gzipstream.cpp20
-rw-r--r--src/io/http.cpp2
-rw-r--r--src/io/http.h2
-rw-r--r--src/io/inkscapestream.h4
-rw-r--r--src/io/resource.cpp16
-rw-r--r--src/io/resource.h6
-rw-r--r--src/io/sys.cpp58
-rw-r--r--src/io/uristream.cpp20
-rw-r--r--src/io/xsltstream.cpp8
9 files changed, 68 insertions, 68 deletions
diff --git a/src/io/gzipstream.cpp b/src/io/gzipstream.cpp
index 330191ecd..dfb605f14 100644
--- a/src/io/gzipstream.cpp
+++ b/src/io/gzipstream.cpp
@@ -51,8 +51,8 @@ GzipInputStream::GzipInputStream(InputStream &sourceStream)
loaded(false),
totalIn(0),
totalOut(0),
- outputBuf(NULL),
- srcBuf(NULL),
+ outputBuf(nullptr),
+ srcBuf(nullptr),
crc(0),
srcCrc(0),
srcSiz(0),
@@ -72,11 +72,11 @@ GzipInputStream::~GzipInputStream()
close();
if ( srcBuf ) {
delete[] srcBuf;
- srcBuf = NULL;
+ srcBuf = nullptr;
}
if ( outputBuf ) {
delete[] outputBuf;
- outputBuf = NULL;
+ outputBuf = nullptr;
}
}
@@ -109,11 +109,11 @@ void GzipInputStream::close()
if ( srcBuf ) {
delete[] srcBuf;
- srcBuf = NULL;
+ srcBuf = nullptr;
}
if ( outputBuf ) {
delete[] outputBuf;
- outputBuf = NULL;
+ outputBuf = nullptr;
}
closed = true;
}
@@ -179,7 +179,7 @@ bool GzipInputStream::load()
outputBuf = new (std::nothrow) unsigned char [OUT_SIZE];
if ( !outputBuf ) {
delete[] srcBuf;
- srcBuf = NULL;
+ srcBuf = nullptr;
return false;
}
outputBufLen = 0; // Not filled in yet
@@ -251,9 +251,9 @@ bool GzipInputStream::load()
unsigned long dataLen = srcLen - (headerLen + 8);
//printf("%x %x\n", data[0], data[dataLen-1]);
- d_stream.zalloc = (alloc_func)0;
- d_stream.zfree = (free_func)0;
- d_stream.opaque = (voidpf)0;
+ d_stream.zalloc = (alloc_func)nullptr;
+ d_stream.zfree = (free_func)nullptr;
+ d_stream.opaque = (voidpf)nullptr;
d_stream.next_in = data;
d_stream.avail_in = dataLen;
d_stream.next_out = outputBuf;
diff --git a/src/io/http.cpp b/src/io/http.cpp
index 883f6f56c..c081ca7bc 100644
--- a/src/io/http.cpp
+++ b/src/io/http.cpp
@@ -110,7 +110,7 @@ Glib::ustring get_file(Glib::ustring uri, unsigned int timeout, callback func) {
GStatBuf st;
if(g_stat(filename.c_str(), &st) != -1) {
time_t changed = st.st_mtime;
- time_t now = time(0);
+ time_t now = time(nullptr);
// The cache hasn't timed out, so return the filename.
if(now - changed < timeout) {
if(func) {
diff --git a/src/io/http.h b/src/io/http.h
index 8327ca79d..70676e156 100644
--- a/src/io/http.h
+++ b/src/io/http.h
@@ -27,7 +27,7 @@ namespace Inkscape {
namespace IO {
namespace HTTP {
- Glib::ustring get_file(Glib::ustring uri, unsigned int timeout=0, std::function<void(Glib::ustring)> func=NULL);
+ Glib::ustring get_file(Glib::ustring uri, unsigned int timeout=0, std::function<void(Glib::ustring)> func=nullptr);
}
}
diff --git a/src/io/inkscapestream.h b/src/io/inkscapestream.h
index 3537b8872..536a121ce 100644
--- a/src/io/inkscapestream.h
+++ b/src/io/inkscapestream.h
@@ -379,7 +379,7 @@ protected:
Reader *source;
BasicReader()
- { source = NULL; }
+ { source = nullptr; }
private:
@@ -563,7 +563,7 @@ protected:
Writer *destination;
BasicWriter()
- { destination = NULL; }
+ { destination = nullptr; }
private:
diff --git a/src/io/resource.cpp b/src/io/resource.cpp
index 0b242cc31..f8cf9fce4 100644
--- a/src/io/resource.cpp
+++ b/src/io/resource.cpp
@@ -44,10 +44,10 @@ namespace Resource {
gchar *_get_path(Domain domain, Type type, char const *filename)
{
- gchar *path=NULL;
+ gchar *path=nullptr;
switch (domain) {
case SYSTEM: {
- gchar const* temp = 0;
+ gchar const* temp = nullptr;
switch (type) {
case APPICONS: temp = INKSCAPE_APPICONDIR; break;
case EXTENSIONS: temp = INKSCAPE_EXTENSIONDIR; break;
@@ -71,7 +71,7 @@ gchar *_get_path(Domain domain, Type type, char const *filename)
path = g_strdup(temp);
} break;
case CREATE: {
- gchar const* temp = 0;
+ gchar const* temp = nullptr;
switch (type) {
case GRADIENTS: temp = CREATE_GRADIENTSDIR; break;
case PALETTES: temp = CREATE_PALETTESDIR; break;
@@ -84,7 +84,7 @@ gchar *_get_path(Domain domain, Type type, char const *filename)
path = g_build_filename(g_get_user_cache_dir(), "inkscape", NULL);
} break;
case USER: {
- char const *name=NULL;
+ char const *name=nullptr;
switch (type) {
case EXTENSIONS: name = "extensions"; break;
case FILTERS: name = "filters"; break;
@@ -145,7 +145,7 @@ Glib::ustring get_filename(Type type, char const *filename, char const *locale)
{
Glib::ustring result;
- if(locale != NULL) {
+ if(locale != nullptr) {
char *user_locale = _get_path(USER, type, filename);
char *sys_locale = _get_path(SYSTEM, type, filename);
@@ -288,7 +288,7 @@ void get_filenames_from_path(std::vector<Glib::ustring> &files, Glib::ustring pa
*/
char *profile_path(const char *filename)
{
- static const gchar *prefdir = NULL;
+ static const gchar *prefdir = nullptr;
if (!prefdir) {
@@ -356,7 +356,7 @@ char *profile_path(const char *filename)
int problem = errno;
g_warning("Unable to create profile directory (%s) (%d)", g_strerror(problem), problem);
} else {
- gchar const *userDirs[] = {"keys", "templates", "icons", "extensions", "palettes", NULL};
+ gchar const *userDirs[] = {"keys", "templates", "icons", "extensions", "palettes", nullptr};
for (gchar const** name = userDirs; *name; ++name) {
gchar *dir = g_build_filename(prefdir, *name, NULL);
g_mkdir_with_parents(dir, mode);
@@ -379,7 +379,7 @@ char *log_path(const char *filename)
char *homedir_path(const char *filename)
{
- static const gchar *homedir = NULL;
+ static const gchar *homedir = nullptr;
homedir = g_get_home_dir();
// I suspect this is for handling inkscape app packages
diff --git a/src/io/resource.h b/src/io/resource.h
index 6ec08a28c..dae43ec8f 100644
--- a/src/io/resource.h
+++ b/src/io/resource.h
@@ -58,13 +58,13 @@ enum Domain {
};
Util::ptr_shared get_path(Domain domain, Type type,
- char const *filename=NULL);
+ char const *filename=nullptr);
Glib::ustring get_path_ustring(Domain domain, Type type,
- char const *filename=NULL);
+ char const *filename=nullptr);
Glib::ustring get_filename(Type type, char const *filename,
- char const *locale=NULL);
+ char const *locale=nullptr);
Glib::ustring get_filename(Glib::ustring path, Glib::ustring filename);
std::vector<Glib::ustring> get_filenames(Type type,
diff --git a/src/io/sys.cpp b/src/io/sys.cpp
index 2ff17cdc9..00f91137e 100644
--- a/src/io/sys.cpp
+++ b/src/io/sys.cpp
@@ -66,8 +66,8 @@ void Inkscape::IO::dump_fopen_call( char const *utf8name, char const *id )
FILE *Inkscape::IO::fopen_utf8name( char const *utf8name, char const *mode )
{
- FILE* fp = NULL;
- gchar *filename = g_filename_from_utf8( utf8name, -1, NULL, NULL, NULL );
+ FILE* fp = nullptr;
+ gchar *filename = g_filename_from_utf8( utf8name, -1, nullptr, nullptr, nullptr );
if ( filename )
{
// ensure we open the file in binary mode (not needed in POSIX but doesn't hurt either)
@@ -87,7 +87,7 @@ FILE *Inkscape::IO::fopen_utf8name( char const *utf8name, char const *mode )
}
fp = g_fopen(filename, how.c_str());
g_free(filename);
- filename = 0;
+ filename = nullptr;
}
return fp;
}
@@ -96,12 +96,12 @@ FILE *Inkscape::IO::fopen_utf8name( char const *utf8name, char const *mode )
int Inkscape::IO::mkdir_utf8name( char const *utf8name )
{
int retval = -1;
- gchar *filename = g_filename_from_utf8( utf8name, -1, NULL, NULL, NULL );
+ gchar *filename = g_filename_from_utf8( utf8name, -1, nullptr, nullptr, nullptr );
if ( filename )
{
retval = g_mkdir(filename, S_IRWXU | S_IRGRP | S_IXGRP); // The mode argument is ignored on Windows.
g_free(filename);
- filename = 0;
+ filename = nullptr;
}
return retval;
}
@@ -111,8 +111,8 @@ bool Inkscape::IO::file_test( char const *utf8name, GFileTest test )
bool exists = false;
if ( utf8name ) {
- gchar *filename = NULL;
- if (utf8name && !g_utf8_validate(utf8name, -1, NULL)) {
+ gchar *filename = nullptr;
+ if (utf8name && !g_utf8_validate(utf8name, -1, nullptr)) {
/* FIXME: Trying to guess whether or not a filename is already in utf8 is unreliable.
If any callers pass non-utf8 data (e.g. using g_get_home_dir), then change caller to
use simple g_file_test. Then add g_return_val_if_fail(g_utf_validate(...), false)
@@ -121,12 +121,12 @@ bool Inkscape::IO::file_test( char const *utf8name, GFileTest test )
// Looks like g_get_home_dir isn't safe.
//g_warning("invalid UTF-8 detected internally. HUNT IT DOWN AND KILL IT!!!");
} else {
- filename = g_filename_from_utf8 ( utf8name, -1, NULL, NULL, NULL );
+ filename = g_filename_from_utf8 ( utf8name, -1, nullptr, nullptr, nullptr );
}
if ( filename ) {
exists = g_file_test (filename, test);
g_free(filename);
- filename = NULL;
+ filename = nullptr;
} else {
g_warning( "Unable to convert filename in IO:file_test" );
}
@@ -140,8 +140,8 @@ bool Inkscape::IO::file_is_writable( char const *utf8name)
bool success = true;
if ( utf8name) {
- gchar *filename = NULL;
- if (utf8name && !g_utf8_validate(utf8name, -1, NULL)) {
+ gchar *filename = nullptr;
+ if (utf8name && !g_utf8_validate(utf8name, -1, nullptr)) {
/* FIXME: Trying to guess whether or not a filename is already in utf8 is unreliable.
If any callers pass non-utf8 data (e.g. using g_get_home_dir), then change caller to
use simple g_file_test. Then add g_return_val_if_fail(g_utf_validate(...), false)
@@ -150,7 +150,7 @@ bool Inkscape::IO::file_is_writable( char const *utf8name)
// Looks like g_get_home_dir isn't safe.
//g_warning("invalid UTF-8 detected internally. HUNT IT DOWN AND KILL IT!!!");
} else {
- filename = g_filename_from_utf8 ( utf8name, -1, NULL, NULL, NULL );
+ filename = g_filename_from_utf8 ( utf8name, -1, nullptr, nullptr, nullptr );
}
if ( filename ) {
GStatBuf st;
@@ -160,7 +160,7 @@ bool Inkscape::IO::file_is_writable( char const *utf8name)
}
}
g_free(filename);
- filename = NULL;
+ filename = nullptr;
} else {
g_warning( "Unable to convert filename in IO:file_test" );
}
@@ -175,8 +175,8 @@ bool Inkscape::IO::file_directory_exists( char const *utf8name ){
bool exists = true;
if ( utf8name) {
- gchar *filename = NULL;
- if (utf8name && !g_utf8_validate(utf8name, -1, NULL)) {
+ gchar *filename = nullptr;
+ if (utf8name && !g_utf8_validate(utf8name, -1, nullptr)) {
/* FIXME: Trying to guess whether or not a filename is already in utf8 is unreliable.
If any callers pass non-utf8 data (e.g. using g_get_home_dir), then change caller to
use simple g_file_test. Then add g_return_val_if_fail(g_utf_validate(...), false)
@@ -185,15 +185,15 @@ bool Inkscape::IO::file_directory_exists( char const *utf8name ){
// Looks like g_get_home_dir isn't safe.
//g_warning("invalid UTF-8 detected internally. HUNT IT DOWN AND KILL IT!!!");
} else {
- filename = g_filename_from_utf8 ( utf8name, -1, NULL, NULL, NULL );
+ filename = g_filename_from_utf8 ( utf8name, -1, nullptr, nullptr, nullptr );
}
if ( filename ) {
gchar *dirname = g_path_get_dirname(filename);
exists = Inkscape::IO::file_test( dirname, G_FILE_TEST_EXISTS);
g_free(filename);
g_free(dirname);
- filename = NULL;
- dirname = NULL;
+ filename = nullptr;
+ dirname = nullptr;
} else {
g_warning( "Unable to convert filename in IO:file_test" );
}
@@ -207,13 +207,13 @@ bool Inkscape::IO::file_directory_exists( char const *utf8name ){
GDir *
Inkscape::IO::dir_open(gchar const *const utf8name, guint const flags, GError **const error)
{
- gchar *const opsys_name = g_filename_from_utf8(utf8name, -1, NULL, NULL, error);
+ gchar *const opsys_name = g_filename_from_utf8(utf8name, -1, nullptr, nullptr, error);
if (opsys_name) {
GDir *ret = g_dir_open(opsys_name, flags, error);
g_free(opsys_name);
return ret;
} else {
- return NULL;
+ return nullptr;
}
}
@@ -228,9 +228,9 @@ Inkscape::IO::dir_read_utf8name(GDir *dir)
for (;;) {
gchar const *const opsys_name = g_dir_read_name(dir);
if (!opsys_name) {
- return NULL;
+ return nullptr;
}
- gchar *utf8_name = g_filename_to_utf8(opsys_name, -1, NULL, NULL, NULL);
+ gchar *utf8_name = g_filename_to_utf8(opsys_name, -1, nullptr, nullptr, nullptr);
if (utf8_name) {
return utf8_name;
}
@@ -244,24 +244,24 @@ gchar* Inkscape::IO::locale_to_utf8_fallback( const gchar *opsysstring,
gsize *bytes_written,
GError **error )
{
- gchar *result = NULL;
+ gchar *result = nullptr;
if ( opsysstring ) {
gchar *newFileName = g_locale_to_utf8( opsysstring, len, bytes_read, bytes_written, error );
if ( newFileName ) {
- if ( !g_utf8_validate(newFileName, -1, NULL) ) {
+ if ( !g_utf8_validate(newFileName, -1, nullptr) ) {
g_warning( "input filename did not yield UTF-8" );
g_free( newFileName );
} else {
result = newFileName;
}
- newFileName = 0;
- } else if ( g_utf8_validate(opsysstring, -1, NULL) ) {
+ newFileName = nullptr;
+ } else if ( g_utf8_validate(opsysstring, -1, nullptr) ) {
// This *might* be a case that we want
// g_warning( "input failed filename->utf8, fell back to original" );
// TODO handle cases when len >= 0
result = g_strdup( opsysstring );
} else {
- gchar const *charset = 0;
+ gchar const *charset = nullptr;
g_get_charset(&charset);
g_warning( "input filename conversion failed for file with locale charset '%s'", charset );
}
@@ -292,9 +292,9 @@ Inkscape::IO::spawn_async_with_pipes( const std::string& working_directory,
gchar* Inkscape::IO::sanitizeString( gchar const * str )
{
- gchar *result = NULL;
+ gchar *result = nullptr;
if ( str ) {
- if ( g_utf8_validate(str, -1, NULL) ) {
+ if ( g_utf8_validate(str, -1, nullptr) ) {
result = g_strdup(str);
} else {
guchar scratch[8];
diff --git a/src/io/uristream.cpp b/src/io/uristream.cpp
index 5d2eb59ee..6dfb38e1f 100644
--- a/src/io/uristream.cpp
+++ b/src/io/uristream.cpp
@@ -39,18 +39,18 @@ namespace IO
static FILE *fopen_utf8name( char const *utf8name, int mode )
{
- FILE *fp = NULL;
+ FILE *fp = nullptr;
if (!utf8name)
{
- return NULL;
+ return nullptr;
}
if (mode!=FILE_READ && mode!=FILE_WRITE)
{
- return NULL;
+ return nullptr;
}
#ifndef WIN32
- gchar *filename = g_filename_from_utf8( utf8name, -1, NULL, NULL, NULL );
+ gchar *filename = g_filename_from_utf8( utf8name, -1, nullptr, nullptr, nullptr );
if ( filename ) {
if (mode == FILE_READ)
fp = std::fopen(filename, "rb");
@@ -99,7 +99,7 @@ UriInputStream::UriInputStream(Inkscape::URI &source)
else if (strncmp("data", schemestr, 4)==0)
scheme = SCHEME_DATA;
- gchar *cpath = NULL;
+ gchar *cpath = nullptr;
switch (scheme) {
case SCHEME_FILE:
@@ -132,7 +132,7 @@ UriInputStream::UriInputStream(Inkscape::URI &source)
UriInputStream::UriInputStream(FILE *source, Inkscape::URI &uri)
: uri(uri),
inf(source),
- data(0),
+ data(nullptr),
dataPos(0),
dataLen(0),
closed(false)
@@ -179,7 +179,7 @@ void UriInputStream::close()
return;
fflush(inf);
fclose(inf);
- inf=NULL;
+ inf=nullptr;
break;
case SCHEME_DATA:
@@ -301,7 +301,7 @@ UriOutputStream::UriOutputStream(FILE* fp, Inkscape::URI &destination)
UriOutputStream::UriOutputStream(Inkscape::URI &destination)
: closed(false),
ownsFile(true),
- outf(NULL),
+ outf(nullptr),
uri(destination),
scheme(SCHEME_FILE)
{
@@ -312,7 +312,7 @@ UriOutputStream::UriOutputStream(Inkscape::URI &destination)
else if (strncmp("data", schemestr, 4)==0)
scheme = SCHEME_DATA;
//printf("out schemestr:'%s' scheme:'%d'\n", schemestr, scheme);
- gchar *cpath = NULL;
+ gchar *cpath = nullptr;
switch (scheme) {
@@ -362,7 +362,7 @@ void UriOutputStream::close()
fflush(outf);
if ( ownsFile )
fclose(outf);
- outf=NULL;
+ outf=nullptr;
break;
case SCHEME_DATA:
diff --git a/src/io/xsltstream.cpp b/src/io/xsltstream.cpp
index 531647769..2e3c954da 100644
--- a/src/io/xsltstream.cpp
+++ b/src/io/xsltstream.cpp
@@ -31,7 +31,7 @@ namespace IO
*/
XsltStyleSheet::XsltStyleSheet(InputStream &xsltSource)
- : stylesheet(NULL)
+ : stylesheet(nullptr)
{
if (!read(xsltSource)) {
throw StreamException("read failed");
@@ -42,7 +42,7 @@ XsltStyleSheet::XsltStyleSheet(InputStream &xsltSource)
*
*/
XsltStyleSheet::XsltStyleSheet()
- : stylesheet(NULL)
+ : stylesheet(nullptr)
{
}
@@ -95,7 +95,7 @@ XsltInputStream::XsltInputStream(InputStream &xmlSource, XsltStyleSheet &sheet)
//Do the processing
const char *params[1];
- params[0] = NULL;
+ params[0] = nullptr;
xmlDocPtr srcDoc = xmlParseMemory(strBuf.c_str(), strBuf.size());
xmlDocPtr resDoc = xsltApplyStylesheet(stylesheet.stylesheet, srcDoc, params);
xmlDocDumpFormatMemory(resDoc, &outbuf, &outsize, 1);
@@ -199,7 +199,7 @@ void XsltOutputStream::flush()
xmlChar *resbuf;
int resSize;
const char *params[1];
- params[0] = NULL;
+ params[0] = nullptr;
xmlDocPtr srcDoc = xmlParseMemory(outbuf.raw().c_str(), outbuf.size());
xmlDocPtr resDoc = xsltApplyStylesheet(stylesheet.stylesheet, srcDoc, params);
xmlDocDumpFormatMemory(resDoc, &resbuf, &resSize, 1);