Codechange: Use null pointer literal instead of the NULL macro

This commit is contained in:
Henry Wilson
2019-04-10 22:07:06 +01:00
committed by Michael Lutz
parent 3b4f224c0b
commit 7c8e7c6b6e
463 changed files with 5674 additions and 5674 deletions

View File

@@ -54,7 +54,7 @@
*
* Copies the source string to the destination buffer with respect of the
* terminating null-character and the last pointer to the last element in
* the destination buffer. If the last pointer is set to NULL no boundary
* the destination buffer. If the last pointer is set to nullptr no boundary
* check is performed.
*
* @note usage: strecpy(dst, src, lastof(dst));
@@ -85,7 +85,7 @@ char *strecpy(char *dst, const char *src, const char *last)
*
* Appends the source string to the destination string with respect of the
* terminating null-character and and the last pointer to the last element
* in the destination buffer. If the last pointer is set to NULL no
* in the destination buffer. If the last pointer is set to nullptr no
* boundary check is performed.
*
* @note usage: strecat(dst, src, lastof(dst));
@@ -163,13 +163,13 @@ public:
File(const char *filename)
{
this->fp = fopen(filename, "r");
if (this->fp == NULL) {
if (this->fp == nullptr) {
fprintf(stdout, "Could not open %s for reading\n", filename);
exit(1);
}
this->dirname = strdup(filename);
char *last = strrchr(this->dirname, '/');
if (last != NULL) {
if (last != nullptr) {
*last = '\0';
} else {
*this->dirname = '\0';
@@ -247,7 +247,7 @@ public:
* Create the lexer and fill the keywords table.
* @param file the file to read from.
*/
Lexer(const File *file) : file(file), current_char('\0'), string(NULL), token(TOKEN_UNKNOWN)
Lexer(const File *file) : file(file), current_char('\0'), string(nullptr), token(TOKEN_UNKNOWN)
{
this->keywords["define"] = TOKEN_DEFINE;
this->keywords["defined"] = TOKEN_DEFINED;
@@ -293,7 +293,7 @@ public:
/**
* Read the currenty processed string.
* @return the string, can be NULL.
* @return the string, can be nullptr.
*/
const char *GetString() const
{
@@ -308,7 +308,7 @@ public:
{
for (;;) {
free(this->string);
this->string = NULL;
this->string = nullptr;
this->token = TOKEN_UNKNOWN;
switch (this->current_char) {
@@ -503,7 +503,7 @@ private:
* @param dirname the directory to look in.
* @param filename the file to look for.
* @param local whether to look locally (in dirname) for the file.
* @return the absolute path, or NULL if the file doesn't exist.
* @return the absolute path, or nullptr if the file doesn't exist.
*/
const char *GeneratePath(const char *dirname, const char *filename, bool local)
{
@@ -517,7 +517,7 @@ const char *GeneratePath(const char *dirname, const char *filename, bool local)
while (*p == '.') {
if (*(++p) == '.') {
char *s = strrchr(path, '/');
if (s != NULL) *s = '\0';
if (s != nullptr) *s = '\0';
p += 2;
}
}
@@ -535,7 +535,7 @@ const char *GeneratePath(const char *dirname, const char *filename, bool local)
while (*p == '.') {
if (*(++p) == '.') {
char *s = strrchr(path, '/');
if (s != NULL) *s = '\0';
if (s != nullptr) *s = '\0';
p += 2;
}
}
@@ -545,7 +545,7 @@ const char *GeneratePath(const char *dirname, const char *filename, bool local)
if (access(path, R_OK) == 0) return strdup(path);
}
return NULL;
return nullptr;
}
/**
@@ -730,7 +730,7 @@ void ScanFile(const char *filename, const char *ext, bool header, bool verbose)
break;
}
const char *h = GeneratePath(file.GetDirname(), lexer.GetString(), lexer.GetToken() == TOKEN_LOCAL);
if (h != NULL) {
if (h != nullptr) {
StringMap::iterator it = _headers.find(h);
if (it == _headers.end()) {
it = (_headers.insert(StringMapItem(strdup(h), new StringSet()))).first;
@@ -745,7 +745,7 @@ void ScanFile(const char *filename, const char *ext, bool header, bool verbose)
char path[PATH_MAX];
strecpy(path, filename, lastof(path));
*(strrchr(path, '.')) = '\0';
strecat(path, ext != NULL ? ext : ".o", lastof(path));
strecat(path, ext != nullptr ? ext : ".o", lastof(path));
curfile = _files.find(path);
if (curfile == _files.end()) {
curfile = (_files.insert(StringMapItem(strdup(path), new StringSet()))).first;
@@ -909,9 +909,9 @@ void ScanFile(const char *filename, const char *ext, bool header, bool verbose)
int main(int argc, char *argv[])
{
bool ignorenext = true;
char *filename = NULL;
char *ext = NULL;
char *delimiter = NULL;
char *filename = nullptr;
char *ext = nullptr;
char *delimiter = nullptr;
bool append = false;
bool verbose = false;
@@ -936,25 +936,25 @@ int main(int argc, char *argv[])
/* Define */
if (strncmp(argv[i], "-D", 2) == 0) {
char *p = strchr(argv[i], '=');
if (p != NULL) *p = '\0';
if (p != nullptr) *p = '\0';
_defines.insert(strdup(&argv[i][2]));
continue;
}
/* Output file */
if (strncmp(argv[i], "-f", 2) == 0) {
if (filename != NULL) continue;
if (filename != nullptr) continue;
filename = strdup(&argv[i][2]);
continue;
}
/* Object file extension */
if (strncmp(argv[i], "-o", 2) == 0) {
if (ext != NULL) continue;
if (ext != nullptr) continue;
ext = strdup(&argv[i][2]);
continue;
}
/* Starting string delimiter */
if (strncmp(argv[i], "-s", 2) == 0) {
if (delimiter != NULL) continue;
if (delimiter != nullptr) continue;
delimiter = strdup(&argv[i][2]);
continue;
}
@@ -966,22 +966,22 @@ int main(int argc, char *argv[])
}
/* Default output file is Makefile */
if (filename == NULL) filename = strdup("Makefile");
if (filename == nullptr) filename = strdup("Makefile");
/* Default delimiter string */
if (delimiter == NULL) delimiter = strdup("# DO NOT DELETE");
if (delimiter == nullptr) delimiter = strdup("# DO NOT DELETE");
char backup[PATH_MAX];
strecpy(backup, filename, lastof(backup));
strecat(backup, ".bak", lastof(backup));
char *content = NULL;
char *content = nullptr;
long size = 0;
/* Read in the current file; so we can overwrite everything from the
* end of non-depend data marker down till the end. */
FILE *src = fopen(filename, "rb");
if (src != NULL) {
if (src != nullptr) {
fseek(src, 0, SEEK_END);
if ((size = ftell(src)) < 0) {
fprintf(stderr, "Could not read %s\n", filename);
@@ -1009,7 +1009,7 @@ int main(int argc, char *argv[])
/* Then append it to the real file. */
src = fopen(backup, "r");
while (fgets(content, size, src) != NULL) {
while (fgets(content, size, src) != nullptr) {
fputs(content, dst);
if (!strncmp(content, delimiter, strlen(delimiter))) found_delimiter = true;
if (!append && found_delimiter) break;