* bootstrap.conf (gnulib_modules): Add nullptr.
In code, prefer nullptr to NULL where either will do.
* cfg.mk (sc_prohibit_NULL): Direct to use nullptr instead.
(begword, endword): Add regex helper macros.
---
bootstrap.conf | 1 +
cfg.mk | 10 +++
find/exec.c | 10 +--
find/finddata.c | 2 +-
find/fstype.c | 20 +++---
find/ftsfind.c | 22 +++---
find/parser.c | 130 ++++++++++++++++++------------------
find/pred.c | 32 ++++-----
find/print.c | 16 ++---
find/sharefile.c | 18 ++---
find/tree.c | 106 ++++++++++++++---------------
find/util.c | 32 ++++-----
lib/buildcmd.c | 20 +++---
lib/buildcmd.h | 4 +-
lib/extendbuf.c | 6 +-
lib/fdleak.c | 6 +-
lib/findutils-version.c | 2 +-
lib/printquoted.c | 2 +-
lib/regexprops.c | 6 +-
lib/regextype.c | 2 +-
lib/regextype.h | 4 +-
locate/frcode.c | 8 +--
locate/locate.c | 136 +++++++++++++++++++-------------------
tests/xargs/test-sigusr.c | 16 ++---
xargs/xargs.c | 90 ++++++++++++-------------
25 files changed, 356 insertions(+), 345 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 9cdeb0d0..35fb36f7 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -134,6 +134,7 @@ gnulib_modules="
modf
mountlist
nstrftime
+ nullptr
open
openat-safer
parse-datetime
diff --git a/cfg.mk b/cfg.mk
index 4f963639..3be63886 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -65,6 +65,10 @@ local-checks-to-skip += sc_two_space_separator_in_usage
# 9e 1855268 67844 0.11
export XZ_OPT = -7e
+# Partial substitutes for GNU extensions \< and \> in regexps.
+begword = (^|[^_[:alnum:]])
+endword = ($$|[^_[:alnum:]])
+
# Some test inputs/outputs have trailing blanks.
exclude_file_name_regexp--sc_trailing_blank = \
^COPYING|(po/.*\.po)|(find/testsuite/find.gnu/printf\.xo)|(xargs/testsuite/(inputs/.*\.xi|xargs\.(gnu|posix|sysv)/.*\.(x[oe])))$$
@@ -311,6 +315,12 @@ sc_standard_outputs:
fail=1; } || :; \
exit $$fail
+sc_prohibit_NULL:
+ @prohibit='$(begword)NULL$(endword)' \
+ in_vc_files='\.[ch]$$' \
+ halt='use nullptr instead' \
+ $(_sc_search_regexp)
+
# Now that we have better tests, make this the default.
export VERBOSE = yes
diff --git a/find/exec.c b/find/exec.c
index f281fcc0..a9e3ff77 100644
--- a/find/exec.c
+++ b/find/exec.c
@@ -49,7 +49,7 @@ static bool
initialize_wd_for_exec (struct exec_val *execp, int cwd_fd, const char *dir)
{
execp->wd_for_exec = xmalloc (sizeof (*execp->wd_for_exec));
- execp->wd_for_exec->name = NULL;
+ execp->wd_for_exec->name = nullptr;
execp->wd_for_exec->desc = openat (cwd_fd, dir, O_RDONLY);
if (execp->wd_for_exec->desc < 0)
return false;
@@ -101,7 +101,7 @@ impl_pred_exec (const char *pathname,
struct predicate *pred_ptr)
{
struct exec_val *execp = &pred_ptr->args.exec_vec;
- char *buf = NULL;
+ char *buf = nullptr;
const char *target;
bool result;
const bool local = is_exec_in_local_dir (pred_ptr->pred_func);
@@ -127,7 +127,7 @@ impl_pred_exec (const char *pathname,
if ('/' == target[0])
{
/* find / -execdir ls -d {} \; */
- prefix = NULL;
+ prefix = nullptr;
pfxlen = 0;
}
else
@@ -145,7 +145,7 @@ impl_pred_exec (const char *pathname,
*/
assert (execp->wd_for_exec == initial_wd);
target = pathname;
- prefix = NULL;
+ prefix = nullptr;
pfxlen = 0u;
}
@@ -316,7 +316,7 @@ launch (struct buildcmd_control *ctl, void *usercontext,
int argc, char **argv)
if (child_pid == 0)
{
/* We are the child. */
- assert (NULL != execp->wd_for_exec);
+ assert (nullptr != execp->wd_for_exec);
if (!prep_child_for_exec (execp->close_stdin, execp->wd_for_exec))
{
_exit (1);
diff --git a/find/finddata.c b/find/finddata.c
index 6e19835a..317d8347 100644
--- a/find/finddata.c
+++ b/find/finddata.c
@@ -29,4 +29,4 @@
struct options options;
struct state state;
-struct saved_cwd *initial_wd = NULL;
+struct saved_cwd *initial_wd = nullptr;
diff --git a/find/fstype.c b/find/fstype.c
index bd157f65..dfb53d32 100644
--- a/find/fstype.c
+++ b/find/fstype.c
@@ -110,7 +110,7 @@ static struct mount_entry *
get_file_system_list (bool need_fs_type)
{
/* Local cache for the mount list. */
- static struct mount_entry *mount_list = NULL;
+ static struct mount_entry *mount_list = nullptr;
/* Remember if the list contains the ME_TYPE members. */
static bool has_fstype = false;
@@ -118,7 +118,7 @@ get_file_system_list (bool need_fs_type)
if (mount_list && ! has_fstype && need_fs_type)
{
free_file_system_list (mount_list);
- mount_list = NULL;
+ mount_list = nullptr;
}
if (! mount_list)
{
@@ -139,10 +139,10 @@ filesystem_type (const struct stat *statp, const char
*path)
/* Nonzero if the current file system's type is known. */
static bool fstype_known = false;
- static char *current_fstype = NULL;
+ static char *current_fstype = nullptr;
static dev_t current_dev;
- if (current_fstype != NULL)
+ if (current_fstype != nullptr)
{
if (fstype_known && statp->st_dev == current_dev)
return current_fstype; /* Cached value. */
@@ -225,9 +225,9 @@ file_system_type_uncached (const struct stat *statp, const
char *path,
}
#endif
- best = NULL;
+ best = nullptr;
entries = get_file_system_list (true);
- if (NULL == entries)
+ if (nullptr == entries)
{
/* We cannot determine for sure which file we were trying to
* use because gnulib has abstracted all that stuff away.
@@ -235,7 +235,7 @@ file_system_type_uncached (const struct stat *statp, const
char *path,
*/
error (EXIT_FAILURE, 0, _("Cannot read mounted file system list"));
}
- for (type=NULL, entry=entries; entry; entry=entry->me_next)
+ for (type=nullptr, entry=entries; entry; entry=entry->me_next)
{
#ifdef MNTTYPE_IGNORE
if (!strcmp (entry->me_type, MNTTYPE_IGNORE))
@@ -261,7 +261,7 @@ file_system_type_uncached (const struct stat *statp, const
char *path,
}
/* Don't cache unknown values. */
- *fstype_known = (type != NULL);
+ *fstype_known = (type != nullptr);
return type ? type : xstrdup (_("unknown"));
}
@@ -273,7 +273,7 @@ get_mounted_devices (size_t *n)
size_t alloc_size = 0u;
size_t used = 0u;
struct mount_entry *entries, *entry;
- dev_t *result = NULL;
+ dev_t *result = nullptr;
/* Ignore read_file_system_list () not returning a valid list
* because on some system this is always called at startup,
@@ -298,7 +298,7 @@ get_mounted_devices (size_t *n)
else
{
free (result);
- result = NULL;
+ result = nullptr;
}
}
free_file_system_list (entries);
diff --git a/find/ftsfind.c b/find/ftsfind.c
index 90e16008..4614369a 100644
--- a/find/ftsfind.c
+++ b/find/ftsfind.c
@@ -463,7 +463,7 @@ find (char *arg)
inside_dir (AT_FDCWD);
arglist[0] = arg;
- arglist[1] = NULL;
+ arglist[1] = nullptr;
switch (options.symlink_handling)
{
@@ -483,8 +483,8 @@ find (char *arg)
if (options.stay_on_filesystem)
ftsoptions |= FTS_XDEV;
- p = fts_open (arglist, ftsoptions, NULL);
- if (NULL == p)
+ p = fts_open (arglist, ftsoptions, nullptr);
+ if (nullptr == p)
{
error (0, errno, _("cannot search %s"),
safely_quote_err_filename (0, arg));
@@ -494,7 +494,7 @@ find (char *arg)
{
int level = INT_MIN;
- while ( (errno=0, ent=fts_read (p)) != NULL )
+ while ( (errno=0, ent=fts_read (p)) != nullptr )
{
if (state.execdirs_outstanding && ((int)ent->fts_level != level))
{
@@ -515,7 +515,7 @@ find (char *arg)
state.type = state.have_type ? ent->fts_statp->st_mode : 0;
consider_visiting (p, ent);
}
- /* fts_read returned NULL; distinguish between "finished" and "error". */
+ /* fts_read returned nullptr; distinguish between "finished" and
"error". */
if (errno)
{
error (0, errno,
@@ -537,7 +537,7 @@ find (char *arg)
state.exit_status = EXIT_FAILURE;
return false;
}
- p = NULL;
+ p = nullptr;
}
return true;
}
@@ -549,8 +549,8 @@ process_all_startpoints (int argc, char *argv[])
/* Did the user pass starting points on the command line? */
bool argv_starting_points = 0 < argc && !looks_like_expression (argv[0],
true);
- FILE *stream = NULL;
- char const* files0_filename_quoted = NULL;
+ FILE *stream = nullptr;
+ char const* files0_filename_quoted = nullptr;
struct argv_iterator *ai;
if (options.files0_from)
@@ -582,7 +582,7 @@ process_all_startpoints (int argc, char *argv[])
{
files0_filename_quoted = safely_quote_err_filename (0,
options.files0_from);
stream = fopen (options.files0_from, "r");
- if (stream == NULL)
+ if (stream == nullptr)
{
error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
files0_filename_quoted);
@@ -666,7 +666,7 @@ process_all_startpoints (int argc, char *argv[])
{
/* Diagnose a zero-length file name. When it's one
among many, knowing the record number may help. */
- if (options.files0_from == NULL)
+ if (options.files0_from == nullptr)
error (0, ENOENT, "%s", safely_quote_err_filename (0, file_name));
else
{
@@ -731,7 +731,7 @@ main (int argc, char **argv)
}
state.shared_files = sharefile_init ("w");
- if (NULL == state.shared_files)
+ if (nullptr == state.shared_files)
{
error (EXIT_FAILURE, errno,
_("Failed to initialize shared-file hash table"));
diff --git a/find/parser.c b/find/parser.c
index bd18df60..f4b38d4c 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -195,16 +195,16 @@ static bool parse_noop (const struct parser_table* entry,
#define PARSE_OPTION(what,suffix) \
- { (ARG_OPTION), (what), PASTE(parse_,suffix), NULL }
+ { (ARG_OPTION), (what), PASTE(parse_,suffix), nullptr }
#define PARSE_POSOPT(what,suffix) \
- { (ARG_POSITIONAL_OPTION), (what), PASTE(parse_,suffix), NULL }
+ { (ARG_POSITIONAL_OPTION), (what), PASTE(parse_,suffix), nullptr }
#define PARSE_TEST(what,suffix) \
{ (ARG_TEST), (what), PASTE(parse_,suffix), PASTE(pred_,suffix) }
#define PARSE_TEST_NP(what,suffix) \
- { (ARG_TEST), (what), PASTE(parse_,suffix), NULL }
+ { (ARG_TEST), (what), PASTE(parse_,suffix), nullptr }
#define PARSE_ACTION(what,suffix) \
{ (ARG_ACTION), (what), PASTE(parse_,suffix), PASTE(pred_,suffix) }
@@ -294,7 +294,7 @@ static struct parser_table const parse_table[] =
PARSE_TEST ("perm", perm), /* POSIX */
PARSE_ACTION ("print", print), /* POSIX */
PARSE_ACTION ("print0", print0), /* GNU */
- {ARG_ACTION, "printf", parse_printf, NULL}, /* GNU */
+ {ARG_ACTION, "printf", parse_printf, nullptr}, /* GNU */
PARSE_ACTION ("prune", prune), /* POSIX */
PARSE_ACTION ("quit", quit), /* GNU */
{ARG_TEST, "readable", parse_accesscheck, pred_readable},
/* GNU, 4.3.0+ */
@@ -323,19 +323,19 @@ static struct parser_table const parse_table[] =
{ARG_TEST, "false", parse_false, pred_false}, /* GNU */
{ARG_TEST, "true", parse_true, pred_true }, /* GNU */
/* Internal pseudo-option, therefore 3 minus: ---noop. */
- {ARG_NOOP, "--noop", NULL, pred_true }, /* GNU,
internal use only */
+ {ARG_NOOP, "--noop", nullptr, pred_true }, /* GNU,
internal use only */
/* Various other cases that don't fit neatly into our macro scheme. */
- {ARG_TEST, "help", parse_help, NULL}, /* GNU */
- {ARG_TEST, "-help", parse_help, NULL}, /* GNU */
- {ARG_TEST, "version", parse_version, NULL}, /* GNU */
- {ARG_TEST, "-version", parse_version, NULL}, /* GNU */
- {0, NULL, NULL, NULL}
+ {ARG_TEST, "help", parse_help, nullptr}, /* GNU */
+ {ARG_TEST, "-help", parse_help, nullptr}, /* GNU */
+ {ARG_TEST, "version", parse_version, nullptr}, /* GNU */
+ {ARG_TEST, "-version", parse_version, nullptr}, /* GNU */
+ {0, nullptr, nullptr, nullptr}
};
-static const char *first_nonoption_arg = NULL;
-static const struct parser_table *noop = NULL;
+static const char *first_nonoption_arg = nullptr;
+static const struct parser_table *noop = nullptr;
static int
fallback_getfilecon (int fd, const char *name, char **p, int prev_rv)
@@ -466,9 +466,9 @@ static const struct parser_table*
get_noop (void)
{
int i;
- if (NULL == noop)
+ if (nullptr == noop)
{
- for (i = 0; parse_table[i].parser_name != NULL; i++)
+ for (i = 0; parse_table[i].parser_name != nullptr; i++)
{
if (ARG_NOOP ==parse_table[i].type)
{
@@ -551,7 +551,7 @@ parse_begin_user_args (char **args, int argno,
(void) argno;
(void) last;
(void) predicates;
- first_nonoption_arg = NULL;
+ first_nonoption_arg = nullptr;
}
void
@@ -598,7 +598,7 @@ found_parser (const char *original_arg, const struct
parser_table *entry)
if (entry->type != ARG_POSITIONAL_OPTION)
{
if (entry->type == ARG_NOOP)
- return NULL; /* internal use only, trap -noop here. */
+ return nullptr; /* internal use only, trap -noop here. */
/* Something other than -follow/-daystart.
* If this is an option, check if it followed
@@ -606,7 +606,7 @@ found_parser (const char *original_arg, const struct
parser_table *entry)
*/
if (entry->type == ARG_OPTION)
{
- if ((first_nonoption_arg != NULL)
+ if ((first_nonoption_arg != nullptr)
&& should_issue_warnings ())
{
/* option which follows a non-option */
@@ -627,7 +627,7 @@ found_parser (const char *original_arg, const struct
parser_table *entry)
* so remember we've seen it in order to
* use it in a possible future warning message.
*/
- if (first_nonoption_arg == NULL)
+ if (first_nonoption_arg == nullptr)
{
first_nonoption_arg = original_arg;
}
@@ -640,7 +640,7 @@ found_parser (const char *original_arg, const struct
parser_table *entry)
/* Return a pointer to the parser function to invoke for predicate
SEARCH_NAME.
- Return NULL if SEARCH_NAME is not a valid predicate name. */
+ Return nullptr if SEARCH_NAME is not a valid predicate name. */
const struct parser_table*
find_parser (const char *search_name)
@@ -658,7 +658,7 @@ find_parser (const char *search_name)
if (*search_name == '-')
search_name++;
- for (i = 0; parse_table[i].parser_name != NULL; i++)
+ for (i = 0; parse_table[i].parser_name != nullptr; i++)
{
if (strcmp (parse_table[i].parser_name, search_name) == 0)
{
@@ -679,7 +679,7 @@ find_parser (const char *search_name)
return found_parser (original_arg, &parse_table[i]);
}
}
- return NULL;
+ return nullptr;
}
static float
@@ -724,9 +724,9 @@ estimate_timestamp_success_rate (time_t when)
static bool
collect_arg_nonconst (char **argv, int *arg_ptr, char **collected_arg)
{
- if ((argv == NULL) || (argv[*arg_ptr] == NULL))
+ if ((argv == nullptr) || (argv[*arg_ptr] == nullptr))
{
- *collected_arg = NULL;
+ *collected_arg = nullptr;
return false;
}
else
@@ -764,7 +764,7 @@ collect_arg_stat_info (char **argv, int *arg_ptr, struct
stat *p,
}
else
{
- *argument = NULL;
+ *argument = nullptr;
return false;
}
}
@@ -1161,14 +1161,14 @@ parse_group (const struct parser_table* entry, char
**argv, int *arg_ptr)
gid_t gid;
struct group *cur_gr = getgrnam (groupname);
endgrent ();
- if (cur_gr != NULL)
+ if (cur_gr != nullptr)
{
gid = cur_gr->gr_gid;
}
else
{
uintmax_t num;
- if ((xstrtoumax (groupname, NULL, 10, &num, "") != LONGINT_OK)
+ if ((xstrtoumax (groupname, nullptr, 10, &num, "") != LONGINT_OK)
|| (GID_T_MAX < num))
{
error (EXIT_FAILURE, 0,
@@ -1352,7 +1352,7 @@ parse_ls (const struct parser_table* entry, char **argv,
int *arg_ptr)
{
(void) &argv;
(void) &arg_ptr;
- return insert_fls (entry, NULL);
+ return insert_fls (entry, nullptr);
}
static bool
@@ -1476,7 +1476,7 @@ parse_negate (const struct parser_table* entry, char
**argv, int *arg_ptr)
(void) &argv;
(void) &arg_ptr;
- our_pred = get_new_pred_chk_op (entry, NULL);
+ our_pred = get_new_pred_chk_op (entry, nullptr);
our_pred->pred_func = pred_negate;
our_pred->p_type = UNI_OP;
our_pred->p_prec = NEGATE_PREC;
@@ -1511,7 +1511,7 @@ parse_newerXY (const struct parser_table* entry, char
**argv, int *arg_ptr)
(void) argv;
(void) arg_ptr;
- if ((argv == NULL) || (argv[*arg_ptr] == NULL))
+ if ((argv == nullptr) || (argv[*arg_ptr] == nullptr))
{
return false;
}
@@ -1540,8 +1540,8 @@ parse_newerXY (const struct parser_table* entry, char
**argv, int *arg_ptr)
/* -newertY (for any Y) is invalid. */
if (x == 't'
- || (NULL == strchr (validchars, x))
- || (NULL == strchr ( validchars, y)))
+ || (nullptr == strchr (validchars, x))
+ || (nullptr == strchr ( validchars, y)))
{
return false;
}
@@ -1552,7 +1552,7 @@ parse_newerXY (const struct parser_table* entry, char
**argv, int *arg_ptr)
/* Because this item is ARG_SPECIAL_PARSE, we have to advance arg_ptr
* past the test name (for most other tests, this is already done)
*/
- if (argv[1+*arg_ptr] == NULL)
+ if (argv[1+*arg_ptr] == nullptr)
{
error (EXIT_FAILURE, 0, _("The %s test needs an argument"),
quotearg_n_style (0, options.err_quoting_style,
argv[*arg_ptr]));
@@ -1616,7 +1616,7 @@ parse_newerXY (const struct parser_table* entry, char
**argv, int *arg_ptr)
our_pred->est_success_rate = estimate_timestamp_success_rate
(our_pred->args.reftime.ts.tv_sec);
(*arg_ptr)++;
- assert (our_pred->pred_func != NULL);
+ assert (our_pred->pred_func != nullptr);
assert (our_pred->pred_func == pred_newerXY);
assert (our_pred->need_stat);
return true;
@@ -1640,7 +1640,7 @@ parse_nogroup (const struct parser_table* entry, char
**argv, int *arg_ptr)
(void) &argv;
(void) &arg_ptr;
- our_pred = insert_primary (entry, NULL);
+ our_pred = insert_primary (entry, nullptr);
our_pred->est_success_rate = 1e-4;
return true;
}
@@ -1685,7 +1685,7 @@ parse_openparen (const struct parser_table* entry, char
**argv, int *arg_ptr)
(void) argv;
(void) arg_ptr;
- our_pred = get_new_pred_chk_op (entry, NULL);
+ our_pred = get_new_pred_chk_op (entry, nullptr);
our_pred->pred_func = pred_openparen;
our_pred->p_type = OPEN_PAREN;
our_pred->p_prec = NO_PREC;
@@ -1845,14 +1845,14 @@ parse_perm (const struct parser_table* entry, char
**argv, int *arg_ptr)
The latter were formerly accepted as a GNU extension, but that
extension was incompatible with how GNU 'chmod' treats these modes now,
and it would be confusing if 'find' continued to support it. */
- if (NULL == change
+ if (nullptr == change
|| (perm_expr[0] == '+' && '0' <= perm_expr[1] && perm_expr[1] < '8'))
{
error (EXIT_FAILURE, 0, _("invalid mode %s"),
quotearg_n_style (0, options.err_quoting_style, perm_expr));
}
- perm_val[0] = mode_adjust (0, false, 0, change, NULL);
- perm_val[1] = mode_adjust (0, true, 0, change, NULL);
+ perm_val[0] = mode_adjust (0, false, 0, change, nullptr);
+ perm_val[1] = mode_adjust (0, true, 0, change, nullptr);
free (change);
if (('/' == perm_expr[0]) && (0 == perm_val[0]) && (0 == perm_val[1]))
@@ -1913,7 +1913,7 @@ parse_print0 (const struct parser_table* entry, char
**argv, int *arg_ptr)
(void) entry;
(void) argv;
(void) arg_ptr;
- return insert_fprint (entry, NULL);
+ return insert_fprint (entry, nullptr);
}
static bool
@@ -2031,11 +2031,11 @@ insert_regex (char **argv,
our_pred->args.regex = re;
re->allocated = 100;
re->buffer = xmalloc (re->allocated);
- re->fastmap = NULL;
+ re->fastmap = nullptr;
re_set_syntax (regex_options);
re->syntax = regex_options;
- re->translate = NULL;
+ re->translate = nullptr;
error_message = re_compile_pattern (rx, strlen (rx), re);
if (error_message)
@@ -2065,7 +2065,7 @@ parse_size (const struct parser_table* entry, char
**argv, int *arg_ptr)
/* XXX: cannot (yet) convert to use collect_arg() as this
* function modifies the args in-place.
*/
- if ((argv == NULL) || (argv[*arg_ptr] == NULL))
+ if ((argv == nullptr) || (argv[*arg_ptr] == nullptr))
return false;
arg = argv[*arg_ptr];
@@ -2402,14 +2402,14 @@ parse_user (const struct parser_table* entry, char
**argv, int *arg_ptr)
uid_t uid;
struct passwd *cur_pwd = getpwnam (username);
endpwent ();
- if (cur_pwd != NULL)
+ if (cur_pwd != nullptr)
{
uid = cur_pwd->pw_uid;
}
else
{
uintmax_t num;
- if ((xstrtoumax (username, NULL, 10, &num, "") != LONGINT_OK)
+ if ((xstrtoumax (username, nullptr, 10, &num, "") != LONGINT_OK)
|| (UID_T_MAX < num))
{
error (EXIT_FAILURE, 0,
@@ -2475,7 +2475,7 @@ parse_context (const struct parser_table* entry, char
**argv, int *arg_ptr)
{
struct predicate *our_pred;
- if ((argv == NULL) || (argv[*arg_ptr] == NULL))
+ if ((argv == nullptr) || (argv[*arg_ptr] == nullptr))
return false;
if (is_selinux_enabled () <= 0)
@@ -2484,7 +2484,7 @@ parse_context (const struct parser_table* entry, char
**argv, int *arg_ptr)
_("invalid predicate -context: SELinux is not enabled."));
return false;
}
- our_pred = insert_primary (entry, NULL);
+ our_pred = insert_primary (entry, nullptr);
our_pred->est_success_rate = 0.01f;
our_pred->need_stat = false;
our_pred->args.scontext = argv[*arg_ptr];
@@ -2730,7 +2730,7 @@ check_path_safety (const char *action)
const char *path_separators = ":";
size_t pos, len;
- if (NULL == path)
+ if (nullptr == path)
{
/* $PATH is not set. Assume the OS default is safe.
* That may not be true on Windows, but I'm not aware
@@ -2791,7 +2791,7 @@ insert_exec_ok (const char *action,
struct predicate *our_pred;
struct exec_val *execp; /* Pointer for efficiency. */
- if ((argv == NULL) || (argv[*arg_ptr] == NULL))
+ if ((argv == nullptr) || (argv[*arg_ptr] == nullptr))
return false;
our_pred = insert_primary_withpred (entry, func, "(some -exec* arguments)");
@@ -2800,7 +2800,7 @@ insert_exec_ok (const char *action,
assert(predicate_uses_exec (our_pred));
execp = &our_pred->args.exec_vec;
- execp->wd_for_exec = NULL;
+ execp->wd_for_exec = nullptr;
if ((func != pred_okdir) && (func != pred_ok))
{
@@ -2822,13 +2822,13 @@ insert_exec_ok (const char *action,
if ((func == pred_execdir) || (func == pred_okdir))
{
- execp->wd_for_exec = NULL;
+ execp->wd_for_exec = nullptr;
options.ignore_readdir_race = false;
check_path_safety (action);
}
else
{
- assert (NULL != initial_wd);
+ assert (nullptr != initial_wd);
execp->wd_for_exec = initial_wd;
}
@@ -2838,8 +2838,8 @@ insert_exec_ok (const char *action,
* Also figure out if the command is terminated by ";" or by "+".
*/
start = *arg_ptr;
- for (end = start, prev_was_braces_only=false, brace_count=0, brace_arg=NULL;
- (argv[end] != NULL)
+ for (end = start, prev_was_braces_only=false, brace_count=0,
brace_arg=nullptr;
+ (argv[end] != nullptr)
&& ((argv[end][0] != ';') || (argv[end][1] != '\0'));
end++)
{
@@ -2886,7 +2886,7 @@ insert_exec_ok (const char *action,
}
/* Fail if no command given or no semicolon found. */
- if ((end == start) || (argv[end] == NULL))
+ if ((end == start) || (argv[end] == nullptr))
{
*arg_ptr = end;
free (our_pred);
@@ -2949,8 +2949,8 @@ insert_exec_ok (const char *action,
/* "+" terminator, so we can just append our arguments after the
* command and initial arguments.
*/
- execp->replace_vec = NULL;
- execp->ctl.replace_pat = NULL;
+ execp->replace_vec = nullptr;
+ execp->ctl.replace_pat = nullptr;
execp->ctl.rplen = 0;
execp->ctl.lines_per_exec = 0; /* no limit */
execp->ctl.args_per_exec = 0; /* no limit */
@@ -2966,7 +2966,7 @@ insert_exec_ok (const char *action,
{
bc_push_arg (&execp->ctl, &execp->state,
argv[i], strlen (argv[i])+1,
- NULL, 0,
+ nullptr, 0,
1);
}
}
@@ -2994,7 +2994,7 @@ insert_exec_ok (const char *action,
}
}
- if (argv[end] == NULL)
+ if (argv[end] == nullptr)
*arg_ptr = end;
else
*arg_ptr = end + 1;
@@ -3039,7 +3039,7 @@ get_relative_timestamp (const char *str,
}
/* Convert the ASCII number into floating-point. */
- if (xstrtod (str, NULL, &offset, strtod))
+ if (xstrtod (str, nullptr, &offset, strtod))
{
if (isnan (offset))
{
@@ -3225,7 +3225,7 @@ get_num (const char *str,
{
char *pend;
- if (str == NULL)
+ if (str == nullptr)
return false;
/* Figure out the comparison type if the caller accepts one. */
@@ -3286,17 +3286,17 @@ insert_num (char **argv, int *arg_ptr, const struct
parser_table *entry)
predicate,
quotearg_n_style (0, options.err_quoting_style, numstr));
/*NOTREACHED*/
- return NULL;
+ return nullptr;
}
}
- return NULL;
+ return nullptr;
}
static void
open_output_file (const char *path, struct format_val *p)
{
- p->segment = NULL;
- p->quote_opts = clone_quoting_options (NULL);
+ p->segment = nullptr;
+ p->quote_opts = clone_quoting_options (nullptr);
if (!strcmp (path, "/dev/stderr"))
{
@@ -3313,7 +3313,7 @@ open_output_file (const char *path, struct format_val *p)
p->stream = sharefile_fopen (state.shared_files, path);
p->filename = path;
- if (p->stream == NULL)
+ if (p->stream == nullptr)
{
fatal_nontarget_file_error (errno, path);
}
diff --git a/find/pred.c b/find/pred.c
index 1a41ade7..bc7bd985 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -148,7 +148,7 @@ pred_amin (const char *pathname, struct stat *stat_buf,
struct predicate *pred_p
bool
pred_and (const char *pathname, struct stat *stat_buf, struct predicate
*pred_ptr)
{
- if (pred_ptr->pred_left == NULL
+ if (pred_ptr->pred_left == nullptr
|| apply_predicate (pathname, stat_buf, pred_ptr->pred_left))
{
return apply_predicate (pathname, stat_buf, pred_ptr->pred_right);
@@ -201,7 +201,7 @@ pred_cnewer (const char *pathname, struct stat *stat_buf,
struct predicate *pred
bool
pred_comma (const char *pathname, struct stat *stat_buf, struct predicate
*pred_ptr)
{
- if (pred_ptr->pred_left != NULL)
+ if (pred_ptr->pred_left != nullptr)
{
apply_predicate (pathname, stat_buf,pred_ptr->pred_left);
}
@@ -323,7 +323,7 @@ pred_empty (const char *pathname, struct stat *stat_buf,
struct predicate *pred_
return false;
}
d = fdopendir (fd);
- if (d == NULL)
+ if (d == nullptr)
{
error (0, errno, "%s", safely_quote_err_filename (0, pathname));
state.exit_status = EXIT_FAILURE;
@@ -653,7 +653,7 @@ pred_nogroup (const char *pathname, struct stat *stat_buf,
struct predicate *pre
{
(void) pathname;
(void) pred_ptr;
- return getgrgid (stat_buf->st_gid) == NULL;
+ return getgrgid (stat_buf->st_gid) == nullptr;
}
bool
@@ -661,7 +661,7 @@ pred_nouser (const char *pathname, struct stat *stat_buf,
struct predicate *pred
{
(void) pathname;
(void) pred_ptr;
- return getpwuid (stat_buf->st_uid) == NULL;
+ return getpwuid (stat_buf->st_uid) == nullptr;
}
@@ -723,7 +723,7 @@ pred_openparen (const char *pathname, struct stat
*stat_buf, struct predicate *p
bool
pred_or (const char *pathname, struct stat *stat_buf, struct predicate
*pred_ptr)
{
- if (pred_ptr->pred_left == NULL
+ if (pred_ptr->pred_left == nullptr
|| !apply_predicate (pathname, stat_buf, pred_ptr->pred_left))
{
return apply_predicate (pathname, stat_buf, pred_ptr->pred_right);
@@ -841,7 +841,7 @@ pred_prune (const char *pathname, struct stat *stat_buf,
struct predicate *pred_
if (options.do_dir_first == true) { /* no effect with -depth */
assert (state.have_stat);
- if (stat_buf != NULL &&
+ if (stat_buf != nullptr &&
S_ISDIR(stat_buf->st_mode))
state.stop_at_current_level = true;
}
@@ -877,7 +877,7 @@ pred_regex (const char *pathname, struct stat *stat_buf,
struct predicate *pred_
int len = strlen (pathname);
(void) stat_buf;
if (re_match (pred_ptr->args.regex, pathname, len, 0,
- (struct re_registers *) NULL) == len)
+ (struct re_registers *) nullptr) == len)
return (true);
return (false);
}
@@ -1170,8 +1170,8 @@ blank_rtrim (const char *str, char *buf)
{
int i;
- if (str == NULL)
- return (NULL);
+ if (str == nullptr)
+ return (nullptr);
strcpy (buf, str);
i = strlen (buf) - 1;
while ((i >= 0) && ((buf[i] == ' ') || buf[i] == '\t'))
@@ -1188,7 +1188,7 @@ print_list (FILE *fp, struct predicate *node)
char name[256];
cur = node;
- while (cur != NULL)
+ while (cur != nullptr)
{
fprintf (fp, "[%s] ", blank_rtrim (cur->p_name, name));
cur = cur->pred_next;
@@ -1205,7 +1205,7 @@ print_parenthesised (FILE *fp, struct predicate *node)
if (node)
{
if ((pred_is (node, pred_or) || pred_is (node, pred_and))
- && node->pred_left == NULL)
+ && node->pred_left == nullptr)
{
/* We print "<nothing> or X" as just "X"
* We print "<nothing> and X" as just "X"
@@ -1286,17 +1286,17 @@ pred_sanity_check (const struct predicate *predicates)
{
const struct predicate *p;
- for (p=predicates; p != NULL; p=p->pred_next)
+ for (p=predicates; p != nullptr; p=p->pred_next)
{
/* All predicates must do something. */
- assert (p->pred_func != NULL);
+ assert (p->pred_func != nullptr);
/* All predicates must have a parser table entry. */
- assert (p->parser_entry != NULL);
+ assert (p->parser_entry != nullptr);
/* If the parser table tells us that just one predicate function is
* possible, verify that that is still the one that is in effect.
- * If the parser has NULL for the predicate function, that means that
+ * If the parser has nullptr for the predicate function, that means that
* the parse_xxx function fills it in, so we can't check it.
*/
if (p->parser_entry->pred_func)
diff --git a/find/print.c b/find/print.c
index 30360a0a..5d89865b 100644
--- a/find/print.c
+++ b/find/print.c
@@ -82,7 +82,7 @@ make_segment (struct segment **segment,
(*segment)->segkind = kind;
(*segment)->format_char[0] = format_char;
(*segment)->format_char[1] = aux_format_char;
- (*segment)->next = NULL;
+ (*segment)->next = nullptr;
(*segment)->text_len = len;
fmt = (*segment)->text = xmalloc (len + sizeof "d");
@@ -312,7 +312,7 @@ insert_fprintf (struct format_val *vec,
our_pred->p_cost = NeedsNothing;
segmentp = &our_pred->args.printf_vec.segment;
- *segmentp = NULL;
+ *segmentp = nullptr;
for (fmt_editpos = segstart; *fmt_editpos; fmt_editpos++)
{
@@ -473,9 +473,9 @@ scan_for_digit_differences (const char *p, const char *q,
static char*
do_time_format (const char *fmt, const struct tm *p, const char *ns, size_t
ns_size)
{
- static char *buf = NULL;
+ static char *buf = nullptr;
static size_t buf_size;
- char *timefmt = NULL;
+ char *timefmt = nullptr;
struct tm altered_time;
@@ -502,7 +502,7 @@ do_time_format (const char *fmt, const struct tm *p, const
char *ns, size_t ns_s
* on Solaris, since it unconditionally writes the terminating null
* character.
*/
- if (buf == NULL)
+ if (buf == nullptr)
{
buf_size = 1u;
buf = xmalloc (buf_size);
@@ -968,7 +968,7 @@ do_fprintf (struct format_val *dest,
*(s+1) = '\0';
s = strrchr (pname, '/');
- if (s == NULL) /* No leading directories. */
+ if (s == nullptr) /* No leading directories. */
{
/* If there is no slash in the pathname, we still
* print the string because it contains characters
@@ -1019,12 +1019,12 @@ do_fprintf (struct format_val *dest,
/* sanitised */
#ifdef S_ISLNK
{
- char *linkname = NULL;
+ char *linkname = nullptr;
if (S_ISLNK (stat_buf->st_mode))
{
linkname = areadlinkat (state.cwd_dir_fd, state.rel_pathname);
- if (linkname == NULL)
+ if (linkname == nullptr)
{
nonfatal_target_file_error (errno, pathname);
state.exit_status = EXIT_FAILURE;
diff --git a/find/sharefile.c b/find/sharefile.c
index 9098f7a5..87d2d635 100644
--- a/find/sharefile.c
+++ b/find/sharefile.c
@@ -106,7 +106,7 @@ sharefile_init (const char *mode)
p->mode = strdup (mode);
if (p->mode)
{
- p->table = hash_initialize (DefaultHashTableSize, NULL,
+ p->table = hash_initialize (DefaultHashTableSize, nullptr,
entry_hashfunc,
entry_comparator,
entry_free);
@@ -125,7 +125,7 @@ sharefile_init (const char *mode)
free (p);
}
}
- return NULL;
+ return nullptr;
}
void
@@ -145,19 +145,19 @@ sharefile_fopen (sharefile_handle h, const char *filename)
new_entry = malloc (sizeof (struct SharefileEntry));
if (!new_entry)
- return NULL;
+ return nullptr;
new_entry->name = strdup (filename);
- if (NULL == new_entry->name)
+ if (nullptr == new_entry->name)
{
free (new_entry);
- return NULL;
+ return nullptr;
}
- if (NULL == (new_entry->fp = fopen (filename, p->mode)))
+ if (nullptr == (new_entry->fp = fopen (filename, p->mode)))
{
entry_free (new_entry);
- return NULL;
+ return nullptr;
}
else
{
@@ -169,7 +169,7 @@ sharefile_fopen (sharefile_handle h, const char *filename)
if (fstat (fd, &st) < 0)
{
entry_free (new_entry);
- return NULL;
+ return nullptr;
}
else
{
@@ -195,7 +195,7 @@ sharefile_fopen (sharefile_handle h, const char *filename)
const int save_errno = errno;
entry_free (new_entry);
errno = save_errno;
- return NULL;
+ return nullptr;
}
}
}
diff --git a/find/tree.c b/find/tree.c
index 0ac2e525..fc07507e 100644
--- a/find/tree.c
+++ b/find/tree.c
@@ -32,13 +32,13 @@
/* All predicates for each path to process. */
-static struct predicate *predicates = NULL;
+static struct predicate *predicates = nullptr;
/* The root of the evaluation tree. */
-static struct predicate *eval_tree = NULL;
+static struct predicate *eval_tree = nullptr;
/* The last predicate allocated. */
-static struct predicate *last_pred = NULL;
+static struct predicate *last_pred = nullptr;
/* The starting points. */
static char **start_points;
@@ -106,10 +106,10 @@ get_expr (struct predicate **input,
short int prev_prec,
const struct predicate* prev_pred)
{
- struct predicate *next = NULL;
+ struct predicate *next = nullptr;
struct predicate *this_pred = (*input);
- if (*input == NULL)
+ if (*input == nullptr)
error (EXIT_FAILURE, 0, _("invalid expression"));
switch ((*input)->p_type)
@@ -126,7 +126,7 @@ get_expr (struct predicate **input,
break;
case CLOSE_PAREN:
- if (prev_pred == NULL)
+ if (prev_pred == nullptr)
{
/* Happens with e.g. "find -files0-from - ')' -print" */
error (EXIT_FAILURE, 0,
@@ -171,7 +171,7 @@ get_expr (struct predicate **input,
break;
case OPEN_PAREN:
- if ( (NULL == (*input)->pred_next) || (*input)->pred_next->artificial )
+ if ( (nullptr == (*input)->pred_next) || (*input)->pred_next->artificial
)
{
/* user typed something like "find . (", and so the ) we are
* looking at is from the artificial "( ) -print" that we
@@ -196,7 +196,7 @@ get_expr (struct predicate **input,
_("invalid expression; empty parentheses are not allowed."));
}
next = get_expr (input, NO_PREC, prev_pred);
- if ((*input == NULL)
+ if ((*input == nullptr)
|| ((*input)->p_type != CLOSE_PAREN))
error (EXIT_FAILURE, 0,
_("invalid expression; I was expecting to find a ')' somewhere "
@@ -211,16 +211,16 @@ get_expr (struct predicate **input,
}
/* We now have the first expression and are positioned to check
- out the next operator. If NULL, all done. Otherwise, if
+ out the next operator. If nullptr, all done. Otherwise, if
PREV_PREC < the current node precedence, we must continue;
the expression we just nabbed is more tightly bound to the
following expression than to the previous one. */
- if (*input == NULL)
+ if (*input == nullptr)
return (next);
if ((int) (*input)->p_prec > (int) prev_prec)
{
next = scan_rest (input, next, prev_prec);
- if (next == NULL)
+ if (next == nullptr)
error (EXIT_FAILURE, 0, _("invalid expression"));
}
return (next);
@@ -246,10 +246,10 @@ scan_rest (struct predicate **input,
{
struct predicate *tree; /* The new tree we are building. */
- if ((*input == NULL) || ((*input)->p_type == CLOSE_PAREN))
- return (NULL);
+ if ((*input == nullptr) || ((*input)->p_type == CLOSE_PAREN))
+ return (nullptr);
tree = head;
- while ((*input != NULL) && ((int) (*input)->p_prec > (int) prev_prec))
+ while ((*input != nullptr) && ((int) (*input)->p_prec > (int) prev_prec))
{
switch ((*input)->p_type)
{
@@ -339,7 +339,7 @@ struct predlist
static void
predlist_init (struct predlist *p)
{
- p->head = p->tail = NULL;
+ p->head = p->tail = nullptr;
}
static void
@@ -352,7 +352,7 @@ predlist_insert (struct predlist *list,
*pprev = curr->pred_left;
curr->pred_left = (*insertpos);
(*insertpos) = curr;
- if (NULL == list->tail)
+ if (nullptr == list->tail)
list->tail = list->head;
}
@@ -382,7 +382,7 @@ predlist_merge_sort (struct predlist *list,
struct predlist new_list;
struct predicate *p, *q;
- if (NULL == list->head)
+ if (nullptr == list->head)
return; /* nothing to do */
if (options.debug_options & DebugTreeOpt)
@@ -398,7 +398,7 @@ predlist_merge_sort (struct predlist *list,
/* remove head of source list */
q = list->head;
list->head = list->head->pred_left;
- q->pred_left = NULL;
+ q->pred_left = nullptr;
/* insert it into the new list */
for (p=new_list.head; p; p=p->pred_left)
@@ -420,7 +420,7 @@ predlist_merge_sort (struct predlist *list,
{
/* insert into existing list */
q->pred_left = p->pred_left;
- if (NULL == q->pred_left)
+ if (nullptr == q->pred_left)
new_list.tail = q;
p->pred_left = q;
}
@@ -428,7 +428,7 @@ predlist_merge_sort (struct predlist *list,
{
q->pred_left = new_list.head; /* prepend */
new_list.head = q;
- if (NULL == new_list.tail)
+ if (nullptr == new_list.tail)
new_list.tail = q; /* first item in new list */
}
}
@@ -528,21 +528,21 @@ static bool
consider_arm_swap (struct predicate *p)
{
int left_cost, right_cost;
- const char *reason = NULL;
- struct predicate **pl = NULL, **pr = NULL;
+ const char *reason = nullptr;
+ struct predicate **pl = nullptr, **pr = nullptr;
if (BI_OP != p->p_type)
reason = "Not a binary operation";
if (!reason)
{
- if (NULL == p->pred_left || NULL == p->pred_right)
+ if (nullptr == p->pred_left || nullptr == p->pred_right)
reason = "Doesn't have two arms";
}
if (!reason)
{
- if (NULL == p->pred_left->pred_right)
+ if (nullptr == p->pred_left->pred_right)
{
reason = "Left arm has no child on RHS";
}
@@ -693,7 +693,7 @@ do_arm_swaps (struct predicate *p)
static bool
opt_expr (struct predicate **eval_treep)
{
- struct predlist regex_list={NULL,NULL}, name_list={NULL,NULL};
+ struct predlist regex_list={nullptr,nullptr}, name_list={nullptr,nullptr};
struct predlist cbo_list[NumEvaluationCosts];
int i;
struct predicate *curr;
@@ -705,7 +705,7 @@ opt_expr (struct predicate **eval_treep)
enum predicate_precedence prev_prec, /* precedence of last BI_OP in branch */
biop_prec; /* topmost BI_OP precedence in branch */
- if (eval_treep == NULL || *eval_treep == NULL)
+ if (eval_treep == nullptr || *eval_treep == nullptr)
return (false);
for (i=0; i<NumEvaluationCosts; i++)
@@ -717,7 +717,7 @@ opt_expr (struct predicate **eval_treep)
prevp = eval_treep;
prev_prec = AND_PREC;
curr = *prevp;
- while (curr->pred_left != NULL)
+ while (curr->pred_left != nullptr)
{
prevp = &curr->pred_left;
prev_prec = curr->p_prec; /* must be a BI_OP */
@@ -740,7 +740,7 @@ opt_expr (struct predicate **eval_treep)
biop_prec = NO_PREC; /* not COMMA_PREC */
if ((*prevp) && (*prevp)->p_type == BI_OP)
biop_prec = (*prevp)->p_prec;
- while ((curr = *prevp) != NULL)
+ while ((curr = *prevp) != nullptr)
{
/* If there is a BI_OP of different precedence from the first
in the pred_left chain, create a new parent of the
@@ -1155,7 +1155,7 @@ getrate (const struct predicate *p)
float
calculate_derived_rates (struct predicate *p)
{
- assert (NULL != p);
+ assert (nullptr != p);
if (p->pred_right)
calculate_derived_rates (p->pred_right);
@@ -1168,19 +1168,19 @@ calculate_derived_rates (struct predicate *p)
switch (p->p_type)
{
case NO_TYPE:
- assert (NULL == p->pred_right);
- assert (NULL == p->pred_left);
+ assert (nullptr == p->pred_right);
+ assert (nullptr == p->pred_left);
return p->est_success_rate;
case PRIMARY_TYPE:
- assert (NULL == p->pred_right);
- assert (NULL == p->pred_left);
+ assert (nullptr == p->pred_right);
+ assert (nullptr == p->pred_left);
return p->est_success_rate;
case UNI_OP:
/* Unary operators must have exactly one operand */
assert (pred_is (p, pred_negate));
- assert (NULL == p->pred_left);
+ assert (nullptr == p->pred_left);
p->est_success_rate = (1.0 - p->pred_right->est_success_rate);
return p->est_success_rate;
@@ -1252,7 +1252,7 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
const struct parser_table *entry_close, *entry_print, *entry_open;
int i, oldi;
- predicates = NULL;
+ predicates = nullptr;
/* Find where in ARGV the predicates begin by skipping the list of
* start points. As a side effect, also figure out which is the
@@ -1269,9 +1269,9 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
entry_open = find_parser ("(");
entry_close = find_parser (")");
entry_print = find_parser ("print");
- assert (entry_open != NULL);
- assert (entry_close != NULL);
- assert (entry_print != NULL);
+ assert (entry_open != nullptr);
+ assert (entry_close != nullptr);
+ assert (entry_print != nullptr);
parse_openparen (entry_open, argv, &argc);
last_pred->p_name = "(";
@@ -1294,7 +1294,7 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
predicate_name = argv[i];
parse_entry = find_parser (predicate_name);
- if (parse_entry == NULL)
+ if (parse_entry == nullptr)
{
/* Command line option not recognized */
error (EXIT_FAILURE, 0, _("unknown predicate `%s'"), predicate_name);
@@ -1339,13 +1339,13 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
if (i != oldi)
last_pred->arg_text = argv[oldi];
else
- last_pred->arg_text = NULL;
+ last_pred->arg_text = nullptr;
}
pred_sanity_check(last_pred);
pred_sanity_check(predicates); /* XXX: expensive */
}
parse_end_user_args (argv, argc, last_pred, predicates);
- if (predicates->pred_next == NULL)
+ if (predicates->pred_next == nullptr)
{
/* No predicates that do something other than set a global variable
were given; remove the unneeded initial `(' and add `-print'. */
@@ -1392,15 +1392,15 @@ build_expression_tree (int argc, char *argv[], int
end_of_leading_options)
/* Done parsing the predicates. Build the evaluation tree. */
cur_pred = predicates;
- eval_tree = get_expr (&cur_pred, NO_PREC, NULL);
+ eval_tree = get_expr (&cur_pred, NO_PREC, nullptr);
calculate_derived_rates (eval_tree);
/* Check if we have any left-over predicates (this fixes
* Debian bug #185202).
*/
- if (cur_pred != NULL)
+ if (cur_pred != nullptr)
{
- /* cur_pred->p_name is often NULL here */
+ /* cur_pred->p_name is often nullptr here */
if (pred_is (cur_pred, pred_closeparen))
{
/* e.g. "find \( -true \) \)" */
@@ -1466,7 +1466,7 @@ get_new_pred_noarg (const struct parser_table *entry)
struct predicate *p = get_new_pred (entry);
if (p)
{
- p->arg_text = NULL;
+ p->arg_text = nullptr;
}
return p;
}
@@ -1492,7 +1492,7 @@ get_new_pred (const struct parser_table *entry)
/* Allocate + initialize a new predicate. */
new_pred = xzalloc (sizeof (struct predicate));
- if (predicates == NULL)
+ if (predicates == nullptr)
{
last_pred = predicates = new_pred;
}
@@ -1522,14 +1522,14 @@ get_new_pred_chk_op (const struct parser_table *entry,
const char *arg)
{
struct predicate *new_pred;
- static const struct parser_table *entry_and = NULL;
+ static const struct parser_table *entry_and = nullptr;
/* Locate the entry in the parser table for the "and" operator */
- if (NULL == entry_and)
+ if (nullptr == entry_and)
entry_and = find_parser ("and");
/* Check that it's actually there. If not, that is a bug.*/
- assert (entry_and != NULL);
+ assert (entry_and != nullptr);
if (last_pred)
switch (last_pred->p_type)
@@ -1549,8 +1549,8 @@ get_new_pred_chk_op (const struct parser_table *entry,
new_pred->need_stat = false;
new_pred->need_type = false;
new_pred->need_inum = false;
- new_pred->arg_text = NULL;
- new_pred->args.str = NULL;
+ new_pred->arg_text = nullptr;
+ new_pred->args.str = nullptr;
new_pred->side_effects = false;
new_pred->no_default_print = false;
break;
@@ -1663,7 +1663,7 @@ print_tree (FILE *fp, struct predicate *node, int indent)
{
int i;
- if (node == NULL)
+ if (node == nullptr)
return;
for (i = 0; i < indent; i++)
fprintf (fp, " ");
@@ -1701,7 +1701,7 @@ print_tree (FILE *fp, struct predicate *node, int indent)
for (i = 0; i < indent; i++)
fprintf (fp, " ");
- if (NULL == node->pred_left && NULL == node->pred_right)
+ if (nullptr == node->pred_left && nullptr == node->pred_right)
{
fprintf (fp, "no children.\n");
}
diff --git a/find/util.c b/find/util.c
index fff55b90..eb628aa7 100644
--- a/find/util.c
+++ b/find/util.c
@@ -75,7 +75,7 @@ static struct debug_option_assoc debugassoc[] =
Fills in the following cells of the new predicate node:
pred_func PRED_FUNC
- args(.str) NULL
+ args(.str) nullptr
p_type PRIMARY_TYPE
p_prec NO_PREC
@@ -94,7 +94,7 @@ insert_primary_withpred (const struct parser_table *entry,
new_pred = get_new_pred_chk_op (entry, arg);
new_pred->pred_func = pred_func;
new_pred->p_name = entry->parser_name;
- new_pred->args.str = NULL;
+ new_pred->args.str = nullptr;
new_pred->p_type = PRIMARY_TYPE;
new_pred->p_prec = NO_PREC;
return new_pred;
@@ -107,7 +107,7 @@ insert_primary_withpred (const struct parser_table *entry,
Fills in the following cells of the new predicate node:
pred_func PRED_FUNC
- args(.str) NULL
+ args(.str) nullptr
p_type PRIMARY_TYPE
p_prec NO_PREC
@@ -118,14 +118,14 @@ insert_primary_withpred (const struct parser_table *entry,
struct predicate *
insert_primary (const struct parser_table *entry, const char *arg)
{
- assert (entry->pred_func != NULL);
+ assert (entry->pred_func != nullptr);
return insert_primary_withpred (entry, entry->pred_func, arg);
}
struct predicate *
insert_primary_noarg (const struct parser_table *entry)
{
- return insert_primary (entry, NULL);
+ return insert_primary (entry, nullptr);
}
@@ -379,7 +379,7 @@ do_exec (struct exec_val *execp)
{
free_cwd (execp->wd_for_exec);
free (execp->wd_for_exec);
- execp->wd_for_exec = NULL;
+ execp->wd_for_exec = nullptr;
}
}
@@ -392,7 +392,7 @@ do_exec (struct exec_val *execp)
static void
do_complete_pending_execdirs (struct predicate *p)
{
- if (NULL == p)
+ if (nullptr == p)
return;
assert (state.execdirs_outstanding);
@@ -443,7 +443,7 @@ complete_pending_execdirs (void)
void
complete_pending_execs (struct predicate *p)
{
- if (NULL == p)
+ if (nullptr == p)
return;
complete_pending_execs (p->pred_left);
@@ -488,7 +488,7 @@ cleanup_initial_cwd (void)
{
free_cwd (initial_wd);
free (initial_wd);
- initial_wd = NULL;
+ initial_wd = nullptr;
}
else
{
@@ -517,7 +517,7 @@ traverse_tree (struct predicate *tree,
/* After sharefile_destroy is called, our output file
* pointers will be dangling (fclose will already have
- * been called on them). NULL these out.
+ * been called on them). Null these out.
*/
static void
undangle_file_pointers (struct predicate *p)
@@ -528,7 +528,7 @@ undangle_file_pointers (struct predicate *p)
|| pred_is (p, pred_fprint0))
{
/* The file was already fclose()d by sharefile_destroy. */
- p->args.printf_vec.stream = NULL;
+ p->args.printf_vec.stream = nullptr;
}
}
@@ -545,7 +545,7 @@ cleanup (void)
complete_pending_execdirs ();
}
- /* Close output files and NULL out references to them. */
+ /* Close output files and null out references to them. */
sharefile_destroy (state.shared_files);
if (eval_tree)
traverse_tree (eval_tree, undangle_file_pointers);
@@ -765,7 +765,7 @@ digest_mode (mode_t *mode,
bool
default_prints (struct predicate *pred)
{
- while (pred != NULL)
+ while (pred != nullptr)
{
if (pred->no_default_print)
return (false);
@@ -812,7 +812,7 @@ static void
process_debug_options (char *arg)
{
const char *p;
- char *token_context = NULL;
+ char *token_context = nullptr;
const char delimiters[] = ",";
bool empty = true;
size_t i;
@@ -835,7 +835,7 @@ process_debug_options (char *arg)
error (0, 0, _("Ignoring unrecognised debug flag %s"),
quotearg_n_style (0, options.err_quoting_style, arg));
}
- p = strtok_r (NULL, delimiters, &token_context);
+ p = strtok_r (nullptr, delimiters, &token_context);
}
if (empty)
{
@@ -1041,7 +1041,7 @@ set_option_defaults (struct options *p)
p->err_quoting_style = locale_quoting_style;
- p->files0_from = NULL;
+ p->files0_from = nullptr;
p->ok_prompt_stdin = false;
}
diff --git a/lib/buildcmd.c b/lib/buildcmd.c
index 6718599e..eb18d619 100644
--- a/lib/buildcmd.c
+++ b/lib/buildcmd.c
@@ -57,7 +57,7 @@ static void
bc_args_complete (struct buildcmd_control *ctl,
struct buildcmd_state *state)
{
- bc_push_arg (ctl, state, special_terminating_arg, 0, NULL, 0, 0);
+ bc_push_arg (ctl, state, special_terminating_arg, 0, nullptr, 0, 0);
}
@@ -145,7 +145,7 @@ bc_do_insert (struct buildcmd_control *ctl,
bc_push_arg (ctl, state,
insertbuf, p - insertbuf,
- NULL, 0,
+ nullptr, 0,
initial_args);
}
@@ -239,7 +239,7 @@ copy_args (struct buildcmd_control *ctl,
working_args[dst_pos++] = state->cmd_argv[src_pos++];
}
assert (dst_pos >= ctl->initial_argc);
- working_args[dst_pos] = NULL;
+ working_args[dst_pos] = nullptr;
return dst_pos;
}
@@ -258,7 +258,7 @@ bc_do_exec (struct buildcmd_control *ctl,
bc_args_complete (ctl, state);
/* Verify that the argument list is terminated. */
assert (state->cmd_argc > 0);
- assert (state->cmd_argv[state->cmd_argc-1] == NULL);
+ assert (state->cmd_argv[state->cmd_argc-1] == nullptr);
working_args = xmalloc ((1+state->cmd_argc) * sizeof (char*));
done = 0;
@@ -290,7 +290,7 @@ bc_do_exec (struct buildcmd_control *ctl,
}
}
while ((done + 1) < (state->cmd_argc - ctl->initial_argc));
- /* (state->cmd_argc - ctl->initial_argc) includes the terminating NULL,
+ /* (state->cmd_argc - ctl->initial_argc) includes the terminating null,
* which is why we add 1 to done in the test above. */
free (working_args);
@@ -337,7 +337,7 @@ bc_push_arg (struct buildcmd_control *ctl,
{
const int terminate = (arg == special_terminating_arg);
- assert (arg != NULL);
+ assert (arg != nullptr);
if (!terminate)
{
@@ -384,7 +384,7 @@ bc_push_arg (struct buildcmd_control *ctl,
}
if (terminate)
- state->cmd_argv[state->cmd_argc++] = NULL;
+ state->cmd_argv[state->cmd_argc++] = nullptr;
else
{
state->cmd_argv[state->cmd_argc++] = state->argbuf +
state->cmd_argv_chars;
@@ -520,7 +520,7 @@ bc_init_controlinfo (struct buildcmd_control *ctl,
ctl->max_arg_count = (ctl->posix_arg_size_max / sizeof (char*)) - 2u;
assert (ctl->max_arg_count > 0);
ctl->rplen = 0u;
- ctl->replace_pat = NULL;
+ ctl->replace_pat = nullptr;
ctl->initial_argc = 0;
ctl->exec_callback = cb_exec_noop;
ctl->lines_per_exec = 0;
@@ -562,7 +562,7 @@ bc_init_state (const struct buildcmd_control *ctl,
{
state->cmd_argc = 0;
state->cmd_argv_chars = 0;
- state->cmd_argv = NULL;
+ state->cmd_argv = nullptr;
state->cmd_argv_alloc = 0;
state->largest_successful_arg_count = 0;
state->smallest_failed_arg_count = 0;
@@ -604,7 +604,7 @@ exceeds (const char *env_var_name, size_t quantity)
char *tmp;
unsigned long limit;
- if (xstrtoul (val, &tmp, 10, &limit, NULL) == LONGINT_OK)
+ if (xstrtoul (val, &tmp, 10, &limit, nullptr) == LONGINT_OK)
{
if (quantity > limit)
return 1;
diff --git a/lib/buildcmd.h b/lib/buildcmd.h
index eefded58..91fd5ec5 100644
--- a/lib/buildcmd.h
+++ b/lib/buildcmd.h
@@ -24,11 +24,11 @@
struct buildcmd_state
{
- /* Number of valid elements in `cmd_argv', including terminating NULL. */
+ /* Number of valid elements in `cmd_argv', including terminating null. */
size_t cmd_argc; /* 0 */
/* The list of args being built. */
- char **cmd_argv; /* NULL */
+ char **cmd_argv; /* nullptr */
/* Number of elements allocated for `cmd_argv'. */
size_t cmd_argv_alloc;
diff --git a/lib/extendbuf.c b/lib/extendbuf.c
index 338d201c..7a01fa85 100644
--- a/lib/extendbuf.c
+++ b/lib/extendbuf.c
@@ -76,7 +76,7 @@ extendbuf (void* existing, size_t wanted, size_t *allocated)
/* Sanity check: If there is no existing allocation size, there
* must be no existing allocated buffer.
*/
- assert (NULL == existing);
+ assert (nullptr == existing);
(*allocated) = newsize;
result = malloc (newsize);
@@ -87,7 +87,7 @@ extendbuf (void* existing, size_t wanted, size_t *allocated)
{
(*allocated) = newsize;
result = realloc (existing, newsize);
- if (NULL == result)
+ if (nullptr == result)
{
saved_errno = errno;
}
@@ -113,7 +113,7 @@ void *
xextendbuf (void* existing, size_t wanted, size_t *allocated)
{
void *p = extendbuf (existing, wanted, allocated);
- if (NULL == p)
+ if (nullptr == p)
{
free (existing);
xalloc_die ();
diff --git a/lib/fdleak.c b/lib/fdleak.c
index 7786760c..d095693d 100644
--- a/lib/fdleak.c
+++ b/lib/fdleak.c
@@ -75,7 +75,7 @@ get_proc_max_fd (void)
{
errno = 0;
dent = readdir (dir);
- if (NULL == dent)
+ if (nullptr == dent)
{
if (errno)
{
@@ -229,7 +229,7 @@ remember_non_cloexec_fds (void)
{
int max_fd = get_max_fd ();
struct remember_fd_context cb_data;
- cb_data.buf = NULL;
+ cb_data.buf = nullptr;
cb_data.used = cb_data.allocated = 0;
if (max_fd < INT_MAX)
@@ -361,7 +361,7 @@ void
forget_non_cloexec_fds (void)
{
free (non_cloexec_fds);
- non_cloexec_fds = NULL;
+ non_cloexec_fds = nullptr;
num_cloexec_fds = 0;
}
diff --git a/lib/findutils-version.c b/lib/findutils-version.c
index daf33363..b45889ee 100644
--- a/lib/findutils-version.c
+++ b/lib/findutils-version.c
@@ -49,5 +49,5 @@ display_findutils_version (const char *official_name)
_("Eric B. Decker"),
_("James Youngman"),
_("Kevin Dalley"),
- (const char*) NULL);
+ (const char*) nullptr);
}
diff --git a/lib/printquoted.c b/lib/printquoted.c
index 0d080839..89024f2b 100644
--- a/lib/printquoted.c
+++ b/lib/printquoted.c
@@ -68,7 +68,7 @@ print_quoted (FILE *fp,
if (buf != smallbuf)
{
free (buf);
- buf = NULL;
+ buf = nullptr;
}
}
else
diff --git a/lib/regexprops.c b/lib/regexprops.c
index a36bd71f..c48e668b 100644
--- a/lib/regexprops.c
+++ b/lib/regexprops.c
@@ -463,7 +463,7 @@ copying (void)
,"A copy of the license is included in the ``GNU Free"
,"Documentation License'' file as part of this distribution."
""
- ,NULL
+ ,nullptr
};
const char **s = copy_para;
while (*s)
@@ -511,7 +511,7 @@ get_next (unsigned int ix, unsigned int context)
if (!ignore (ix, context))
{
next = get_regex_type_name (ix);
- if (NULL == next)
+ if (nullptr == next)
return "";
else
return next;
@@ -556,7 +556,7 @@ describe_all (const char *contextname,
}
next = get_next (i+1, context);
- if (NULL == next)
+ if (nullptr == next)
next = "";
begin_subsection (name, next, previous, up);
parent = get_regex_type_synonym (i, context);
diff --git a/lib/regextype.c b/lib/regextype.c
index e06ebaa5..24edaf3b 100644
--- a/lib/regextype.c
+++ b/lib/regextype.c
@@ -108,7 +108,7 @@ get_regex_type_name (unsigned int ix)
if (ix < N_REGEX_MAP_ENTRIES)
return regex_map[ix].name;
else
- return NULL;
+ return nullptr;
}
int
diff --git a/lib/regextype.h b/lib/regextype.h
index c7294044..f84a6d33 100644
--- a/lib/regextype.h
+++ b/lib/regextype.h
@@ -35,14 +35,14 @@ enum {
/* Returns the regex type name corresponding to index IX.
- * Indexes start at 0. Returns NULL if IX is too large.
+ * Indexes start at 0. Returns nullptr if IX is too large.
*/
const char * get_regex_type_name(unsigned int ix);
/* Returns the option mask name corresponding to regular expression
* type index IX. Indexes start at 0. Behaviour is undefined if IX
- * has a value which would cause get_regex_type_name to return NULL.
+ * has a value which would cause get_regex_type_name to return nullptr.
*/
int get_regex_type_flags(unsigned int ix);
diff --git a/locate/frcode.c b/locate/frcode.c
index b1232fe9..9fb615d1 100644
--- a/locate/frcode.c
+++ b/locate/frcode.c
@@ -124,10 +124,10 @@ prefix_length (char *s1, char *s2)
static struct option const longopts[] =
{
- {"help", no_argument, NULL, 'h'},
- {"version", no_argument, NULL, 'v'},
- {"null", no_argument, NULL, '0'},
- {NULL, no_argument, NULL, 0}
+ {"help", no_argument, nullptr, 'h'},
+ {"version", no_argument, nullptr, 'v'},
+ {"null", no_argument, nullptr, '0'},
+ {nullptr, no_argument, nullptr, 0}
};
static void _GL_ATTRIBUTE_NORETURN
diff --git a/locate/locate.c b/locate/locate.c
index f4540c0a..ed699bea 100644
--- a/locate/locate.c
+++ b/locate/locate.c
@@ -133,12 +133,12 @@ static int follow_symlinks = 1;
/* What to separate the results with. */
static int separator = '\n';
-static struct quoting_options * quote_opts = NULL;
+static struct quoting_options * quote_opts = nullptr;
static bool stdout_is_a_tty;
static bool print_quoted_filename;
static bool results_were_filtered;
-static const char *selected_secure_db = NULL;
+static const char *selected_secure_db = nullptr;
static int dolocate (int argc, char **argv, int secure_db_fd);
@@ -209,7 +209,7 @@ static const char * const metacharacters = "*?[]\\";
static int
contains_metacharacter (const char *s)
{
- if (NULL == strpbrk (s, metacharacters))
+ if (nullptr == strpbrk (s, metacharacters))
return 0;
else
return 1;
@@ -232,7 +232,7 @@ contains_metacharacter (const char *s)
static int
locate_read_str (char **buf, size_t *siz, FILE *fp, int delimiter, int offs)
{
- char * p = NULL;
+ char * p = nullptr;
size_t sz = 0;
int nread;
size_t needed;
@@ -240,13 +240,13 @@ locate_read_str (char **buf, size_t *siz, FILE *fp, int
delimiter, int offs)
nread = getdelim (&p, &sz, delimiter, fp);
if (nread >= 0)
{
- assert (p != NULL);
+ assert (p != nullptr);
needed = offs + nread + 1u;
if (needed > (*siz))
{
char *pnew = realloc (*buf, needed);
- if (NULL == pnew)
+ if (nullptr == pnew)
{
return -1; /* FAIL */
}
@@ -318,9 +318,9 @@ struct visitor
};
-static struct visitor *inspectors = NULL;
-static struct visitor *lastinspector = NULL;
-static struct visitor *past_pat_inspector = NULL;
+static struct visitor *inspectors = nullptr;
+static struct visitor *lastinspector = nullptr;
+static struct visitor *past_pat_inspector = nullptr;
static inline int visit (const struct visitor *p,
int accept_flags,
@@ -340,7 +340,7 @@ static inline int visit (const struct visitor *p,
static int
process_simple (struct process_data *procdata)
{
- return visit (inspectors, (VISIT_CONTINUE|VISIT_ACCEPTED), procdata, NULL);
+ return visit (inspectors, (VISIT_CONTINUE|VISIT_ACCEPTED), procdata,
nullptr);
}
/* Accept if any pattern matches. */
@@ -355,7 +355,7 @@ process_or (struct process_data *procdata)
if (result & (VISIT_ABORT | VISIT_REJECTED))
return result;
- result = visit (past_pat_inspector, VISIT_CONTINUE, procdata, NULL);
+ result = visit (past_pat_inspector, VISIT_CONTINUE, procdata, nullptr);
if (VISIT_CONTINUE == result)
return VISIT_ACCEPTED;
else
@@ -374,7 +374,7 @@ process_and (struct process_data *procdata)
if (result & (VISIT_ABORT | VISIT_REJECTED))
return result;
- result = visit (past_pat_inspector, VISIT_CONTINUE, procdata, NULL);
+ result = visit (past_pat_inspector, VISIT_CONTINUE, procdata, nullptr);
if (VISIT_CONTINUE == result)
return VISIT_ACCEPTED;
else
@@ -383,7 +383,7 @@ process_and (struct process_data *procdata)
typedef int (*processfunc)(struct process_data *procdata);
-static processfunc mainprocessor = NULL;
+static processfunc mainprocessor = nullptr;
static void
add_visitor (visitfunc fn, void *context)
@@ -391,9 +391,9 @@ add_visitor (visitfunc fn, void *context)
struct visitor *p = xmalloc (sizeof (struct visitor));
p->inspector = fn;
p->context = context;
- p->next = NULL;
+ p->next = nullptr;
- if (NULL == lastinspector)
+ if (nullptr == lastinspector)
{
lastinspector = inspectors = p;
}
@@ -675,7 +675,7 @@ visit_substring_match_nocasefold_wide (struct process_data
*procdata, void *cont
{
const char *pattern = context;
- if (NULL != mbsstr (procdata->munged_filename, pattern))
+ if (nullptr != mbsstr (procdata->munged_filename, pattern))
return VISIT_ACCEPTED;
else
return VISIT_REJECTED;
@@ -686,7 +686,7 @@ visit_substring_match_nocasefold_narrow (struct
process_data *procdata, void *co
{
const char *pattern = context;
assert (MB_CUR_MAX == 1);
- if (NULL != strstr (procdata->munged_filename, pattern))
+ if (nullptr != strstr (procdata->munged_filename, pattern))
return VISIT_ACCEPTED;
else
return VISIT_REJECTED;
@@ -697,7 +697,7 @@ visit_substring_match_casefold_wide (struct process_data
*procdata, void *contex
{
const char *pattern = context;
- if (NULL != mbscasestr (procdata->munged_filename, pattern))
+ if (nullptr != mbscasestr (procdata->munged_filename, pattern))
return VISIT_ACCEPTED;
else
return VISIT_REJECTED;
@@ -710,7 +710,7 @@ visit_substring_match_casefold_narrow (struct process_data
*procdata, void *cont
const char *pattern = context;
assert (MB_CUR_MAX == 1);
- if (NULL != strcasestr (procdata->munged_filename, pattern))
+ if (nullptr != strcasestr (procdata->munged_filename, pattern))
return VISIT_ACCEPTED;
else
return VISIT_REJECTED;
@@ -747,7 +747,7 @@ visit_regex (struct process_data *procdata, void *context)
int rv = re_search (&p->regex, procdata->munged_filename,
len, 0, len,
- (struct re_registers *) NULL);
+ (struct re_registers *) nullptr);
if (rv < 0)
{
return VISIT_REJECTED; /* no match (-1), or internal error (-2) */
@@ -1049,9 +1049,9 @@ search_one_database (int argc,
procdata.fp = fp;
/* Set up the inspection regime */
- inspectors = NULL;
- lastinspector = NULL;
- past_pat_inspector = NULL;
+ inspectors = nullptr;
+ lastinspector = nullptr;
+ past_pat_inspector = nullptr;
results_were_filtered = false;
procdata.pathsize = 128; /* Increased as necessary by locate_read_str.
*/
procdata.original_filename = xmalloc (procdata.pathsize);
@@ -1110,7 +1110,7 @@ search_one_database (int argc,
do_check_existence = ACCEPT_EXISTING;
}
}
- add_visitor (visit_locate02_format, NULL);
+ add_visitor (visit_locate02_format, nullptr);
format_name = "slocate";
slocatedb_format = 1;
}
@@ -1124,7 +1124,7 @@ search_one_database (int argc,
procdata.fp);
if (looking_at_gnu_locatedb (procdata.original_filename, nread+nread2))
{
- add_visitor (visit_locate02_format, NULL);
+ add_visitor (visit_locate02_format, nullptr);
format_name = "GNU LOCATE02";
}
else /* Use the old format */
@@ -1155,12 +1155,12 @@ search_one_database (int argc,
}
format_name = "old";
oldformat = 1;
- add_visitor (visit_old_format, NULL);
+ add_visitor (visit_old_format, nullptr);
}
}
if (basename_only)
- add_visitor (visit_basename, NULL);
+ add_visitor (visit_basename, nullptr);
/* Add an inspector for each pattern we're looking for. */
for ( argn = 0; argn < argc; argn++ )
@@ -1170,16 +1170,16 @@ search_one_database (int argc,
if (regex)
{
struct regular_expression *p = xmalloc (sizeof (*p));
- const char *error_message = NULL;
+ const char *error_message = nullptr;
memset (&p->regex, 0, sizeof (p->regex));
re_set_syntax (regex_options);
p->regex.allocated = 100;
p->regex.buffer = xmalloc (p->regex.allocated);
- p->regex.fastmap = NULL;
+ p->regex.fastmap = nullptr;
p->regex.syntax = regex_options;
- p->regex.translate = NULL;
+ p->regex.translate = nullptr;
error_message = re_compile_pattern (pathpart, strlen (pathpart),
&p->regex);
@@ -1240,17 +1240,17 @@ search_one_database (int argc,
case ACCEPT_EXISTING:
results_were_filtered = true;
if (follow_symlinks) /* -L, default */
- add_visitor (visit_existing_follow, NULL);
+ add_visitor (visit_existing_follow, nullptr);
else /* -P */
- add_visitor (visit_existing_nofollow, NULL);
+ add_visitor (visit_existing_nofollow, nullptr);
break;
case ACCEPT_NON_EXISTING:
results_were_filtered = true;
if (follow_symlinks) /* -L, default */
- add_visitor (visit_non_existing_follow, NULL);
+ add_visitor (visit_non_existing_follow, nullptr);
else /* -P */
- add_visitor (visit_non_existing_nofollow, NULL);
+ add_visitor (visit_non_existing_nofollow, nullptr);
break;
case ACCEPT_EITHER: /* Default, neither -E nor -e */
@@ -1268,9 +1268,9 @@ search_one_database (int argc,
if (enable_print)
{
if (print_quoted_filename)
- add_visitor (visit_justprint_quoted, NULL);
+ add_visitor (visit_justprint_quoted, nullptr);
else
- add_visitor (visit_justprint_unquoted, NULL);
+ add_visitor (visit_justprint_unquoted, nullptr);
}
@@ -1339,7 +1339,7 @@ search_one_database (int argc,
"is not obvious.\n"));
}
}
- if (filesize || (database_mtime != NULL))
+ if (filesize || (database_mtime != nullptr))
print_stats (argc, filesize, database_mtime);
}
@@ -1385,29 +1385,29 @@ enum
static struct option const longopts[] =
{
- {"database", required_argument, NULL, 'd'},
- {"existing", no_argument, NULL, 'e'},
- {"non-existing", no_argument, NULL, 'E'},
- {"ignore-case", no_argument, NULL, 'i'},
- {"all", no_argument, NULL, 'A'},
- {"help", no_argument, NULL, 'h'},
- {"version", no_argument, NULL, 'v'},
- {"null", no_argument, NULL, '0'},
- {"count", no_argument, NULL, 'c'},
- {"wholename", no_argument, NULL, 'w'},
- {"wholepath", no_argument, NULL, 'w'}, /* Synonym. */
- {"basename", no_argument, NULL, 'b'},
- {"print", no_argument, NULL, 'p'},
- {"stdio", no_argument, NULL, 's'},
- {"mmap", no_argument, NULL, 'm'},
- {"limit", required_argument, NULL, 'l'},
- {"regex", no_argument, NULL, 'r'},
- {"regextype", required_argument, NULL, REGEXTYPE_OPTION},
- {"statistics", no_argument, NULL, 'S'},
- {"follow", no_argument, NULL, 'L'},
- {"nofollow", no_argument, NULL, 'P'},
- {"max-database-age", required_argument, NULL, MAX_DB_AGE},
- {NULL, no_argument, NULL, 0}
+ {"database", required_argument, nullptr, 'd'},
+ {"existing", no_argument, nullptr, 'e'},
+ {"non-existing", no_argument, nullptr, 'E'},
+ {"ignore-case", no_argument, nullptr, 'i'},
+ {"all", no_argument, nullptr, 'A'},
+ {"help", no_argument, nullptr, 'h'},
+ {"version", no_argument, nullptr, 'v'},
+ {"null", no_argument, nullptr, '0'},
+ {"count", no_argument, nullptr, 'c'},
+ {"wholename", no_argument, nullptr, 'w'},
+ {"wholepath", no_argument, nullptr, 'w'}, /* Synonym. */
+ {"basename", no_argument, nullptr, 'b'},
+ {"print", no_argument, nullptr, 'p'},
+ {"stdio", no_argument, nullptr, 's'},
+ {"mmap", no_argument, nullptr, 'm'},
+ {"limit", required_argument, nullptr, 'l'},
+ {"regex", no_argument, nullptr, 'r'},
+ {"regextype", required_argument, nullptr, REGEXTYPE_OPTION},
+ {"statistics", no_argument, nullptr, 'S'},
+ {"follow", no_argument, nullptr, 'L'},
+ {"nofollow", no_argument, nullptr, 'P'},
+ {"max-database-age", required_argument, nullptr, MAX_DB_AGE},
+ {nullptr, no_argument, nullptr, 0}
};
@@ -1529,7 +1529,7 @@ cleanup_quote_opts (void)
static int
dolocate (int argc, char **argv, int secure_db_fd)
{
- char *path_element = NULL;
+ char *path_element = nullptr;
size_t path_element_pos, path_element_len;
const char *user_selected_locate_path;
const char *db_name;
@@ -1558,7 +1558,7 @@ dolocate (int argc, char **argv, int secure_db_fd)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
- quote_opts = clone_quoting_options (NULL);
+ quote_opts = clone_quoting_options (nullptr);
if (atexit (close_stdout) || atexit (cleanup_quote_opts))
{
error (EXIT_FAILURE, errno, _("The atexit library function failed"));
@@ -1606,7 +1606,7 @@ dolocate (int argc, char **argv, int secure_db_fd)
case 'd':
user_selected_locate_path = optarg;
- assert (optarg != NULL);
+ assert (optarg != nullptr);
break;
case 'e':
@@ -1671,7 +1671,7 @@ dolocate (int argc, char **argv, int secure_db_fd)
{
char *end = optarg;
strtol_error err = xstrtoumax (optarg, &end, 10, &limits.limit,
- NULL);
+ nullptr);
if (LONGINT_OK != err)
xstrtol_fatal (err, opti, optc, longopts, optarg);
use_limit = 1;
@@ -1849,7 +1849,7 @@ dolocate (int argc, char **argv, int secure_db_fd)
}
fp = fdopen (fd, "r");
- if (NULL == fp)
+ if (nullptr == fp)
{
error (0, errno, "%s",
quotearg_n_style (0, locale_quoting_style, db_name));
@@ -1859,7 +1859,7 @@ dolocate (int argc, char **argv, int secure_db_fd)
/* Search this database for all patterns simultaneously */
found = search_one_database (argc - optind, &argv[optind],
db_name, fp, filesize,
- have_mtime ? (&database_mtime) : NULL,
+ have_mtime ? (&database_mtime) : nullptr,
ignore_case, print, basename_only,
use_limit, &limits, stats,
op_and, regex, regex_options);
@@ -1874,7 +1874,7 @@ dolocate (int argc, char **argv, int secure_db_fd)
if (path_element)
{
free (path_element);
- path_element = NULL;
+ path_element = nullptr;
}
if (!user_selected_locate_path)
@@ -1912,7 +1912,7 @@ open_secure_db (void)
{
LOCATE_DB,
"/var/lib/slocate/slocate.db",
- NULL
+ nullptr
};
for (i=0; secure_db_list[i]; ++i)
{
diff --git a/tests/xargs/test-sigusr.c b/tests/xargs/test-sigusr.c
index 648dd9ef..c581880b 100644
--- a/tests/xargs/test-sigusr.c
+++ b/tests/xargs/test-sigusr.c
@@ -36,7 +36,7 @@
enum { FLAGFILE_MAX = 128 };
static char flagfile_name[FLAGFILE_MAX];
-static const char* tmpdir = NULL;
+static const char* tmpdir = nullptr;
static void
@@ -47,7 +47,7 @@ remove_temporary_files(void)
unlink(flagfile_name);
rmdir(tmpdir);
}
- tmpdir = NULL;
+ tmpdir = nullptr;
}
static void
@@ -84,7 +84,7 @@ ignore_signal(int signum)
sa.sa_handler = SIG_IGN;
sa.sa_flags = 0;
sigemptyset(&sa.sa_mask);
- if (0 != sigaction(signum, &sa, (struct sigaction*)NULL))
+ if (0 != sigaction(signum, &sa, (struct sigaction*)nullptr))
{
error(2, errno, "sigaction failed");
}
@@ -102,7 +102,7 @@ catch_signal(int signum)
struct sigaction sa;
sa.sa_handler = handler;
sa.sa_flags = 0;
- if (0 != sigaction(signum, &sa, (struct sigaction*)NULL))
+ if (0 != sigaction(signum, &sa, (struct sigaction*)nullptr))
{
error(2, errno, "sigaction failed");
}
@@ -181,7 +181,7 @@ run_xargs(const char *option, const char *opt_arg, int
send_signal)
argv[i++] = (char*)"touch \"$1\" && sleep 4";
argv[i++] = (char*)"fnord";
argv[i++] = flagfile_name;
- argv[i++] = NULL;
+ argv[i++] = nullptr;
assert(i <= ARGV_MAX);
/* Create a pipe so that we can detect an exec call. */
@@ -283,7 +283,7 @@ verify_signal_ignored(int signum)
fflush(stdout);
ignore_signal(signum);
- status = run_xargs(NULL, NULL, signum);
+ status = run_xargs(nullptr, nullptr, signum);
if (status.fatalsig)
{
fprintf(stderr, "xargs should not have exited fatally on receipt of
signal %d\n", signum);
@@ -304,7 +304,7 @@ verify_signal_is_fatal(int signum)
printf("verifying that signal %d will kill xargs (without -P) if it is not
blocked when xargs starts...", signum);
fflush(stdout);
catch_signal(signum);
- status = run_xargs(NULL, NULL, signum);
+ status = run_xargs(nullptr, nullptr, signum);
if (!status.fatalsig)
{
fprintf(stderr, "xargs should have exited fatally on receipt of signal
%d\n", signum);
@@ -334,7 +334,7 @@ main(int argc, char *argv[])
{
char tmpdir_tmpl[] = "/tmp/test-sigusr.XXXXXX";
tmpdir = mkdtemp(tmpdir_tmpl);
- if (NULL == tmpdir)
+ if (nullptr == tmpdir)
{
error(2, errno, "failed to create temporary directory");
}
diff --git a/xargs/xargs.c b/xargs/xargs.c
index 636ed20c..fef0b597 100644
--- a/xargs/xargs.c
+++ b/xargs/xargs.c
@@ -102,10 +102,10 @@ static int nullwarning_given = 0;
/* If nonzero, when this string is read on stdin, then it is treated as EOF.
- IEEE Std 1003.1, 2004 Edition allows this to be NULL.
+ IEEE Std 1003.1, 2004 Edition allows this to be nullptr.
In findutils releases up to and including 4.2.8, this was "_".
*/
-static char *eof_str = NULL;
+static char *eof_str = nullptr;
/* Number of chars in the initial args. */
/* static int initial_argv_chars = 0; */
@@ -126,7 +126,7 @@ static bool procs_executed = false;
static unsigned long int procs_executing = 0uL;
/* List of child processes currently executing. */
-static pid_t *pids = NULL;
+static pid_t *pids = nullptr;
/* The number of allocated elements in `pids'. */
static size_t pids_alloc = 0u;
@@ -164,7 +164,7 @@ static char input_delimiter = '\0';
* load distribution. We guarantee not to allow two processes to run
* at the same time with the same value of this variable.
*/
-static char* slot_var_name = NULL;
+static char* slot_var_name = nullptr;
enum LongOptionIdentifier
{
@@ -173,25 +173,25 @@ enum LongOptionIdentifier
static struct option const longopts[] =
{
- {"null", no_argument, NULL, '0'},
- {"arg-file", required_argument, NULL, 'a'},
- {"delimiter", required_argument, NULL, 'd'},
- {"eof", optional_argument, NULL, 'e'},
- {"replace", optional_argument, NULL, 'I'},
- {"max-lines", optional_argument, NULL, 'l'},
- {"max-args", required_argument, NULL, 'n'},
- {"open-tty", no_argument, NULL, 'o'},
- {"interactive", no_argument, NULL, 'p'},
- {"no-run-if-empty", no_argument, NULL, 'r'},
- {"max-chars", required_argument, NULL, 's'},
- {"verbose", no_argument, NULL, 't'},
- {"show-limits", no_argument, NULL, 'S'},
- {"exit", no_argument, NULL, 'x'},
- {"max-procs", required_argument, NULL, 'P'},
- {"process-slot-var", required_argument, NULL, PROCESS_SLOT_VAR},
- {"version", no_argument, NULL, 'v'},
- {"help", no_argument, NULL, 'h'},
- {NULL, no_argument, NULL, 0}
+ {"null", no_argument, nullptr, '0'},
+ {"arg-file", required_argument, nullptr, 'a'},
+ {"delimiter", required_argument, nullptr, 'd'},
+ {"eof", optional_argument, nullptr, 'e'},
+ {"replace", optional_argument, nullptr, 'I'},
+ {"max-lines", optional_argument, nullptr, 'l'},
+ {"max-args", required_argument, nullptr, 'n'},
+ {"open-tty", no_argument, nullptr, 'o'},
+ {"interactive", no_argument, nullptr, 'p'},
+ {"no-run-if-empty", no_argument, nullptr, 'r'},
+ {"max-chars", required_argument, nullptr, 's'},
+ {"verbose", no_argument, nullptr, 't'},
+ {"show-limits", no_argument, nullptr, 'S'},
+ {"exit", no_argument, nullptr, 'x'},
+ {"max-procs", required_argument, nullptr, 'P'},
+ {"process-slot-var", required_argument, nullptr, PROCESS_SLOT_VAR},
+ {"version", no_argument, nullptr, 'v'},
+ {"help", no_argument, nullptr, 'h'},
+ {nullptr, no_argument, nullptr, 0}
};
/* xargs exits with status values with specific meanings (this is a POSIX
requirement).
@@ -248,13 +248,13 @@ get_char_oct_or_hex_escape (const char *s)
}
else
{
- p = NULL; /* Silence compiler warning. */
+ p = nullptr; /* Silence compiler warning. */
error (EXIT_FAILURE, 0,
_("Invalid escape sequence %s in input delimiter specification."),
s);
}
errno = 0;
- endp = NULL;
+ endp = nullptr;
val = strtoul (p, &endp, base);
/* This if condition is carefully constructed to do
@@ -368,7 +368,7 @@ static FILE* fopen_cloexec_for_read_only (const char
*file_name)
int fd = open_cloexec (file_name, O_RDONLY);
if (fd < 0)
{
- return NULL;
+ return nullptr;
}
else
{
@@ -378,7 +378,7 @@ static FILE* fopen_cloexec_for_read_only (const char
*file_name)
int saved_errno = errno;
close (fd);
errno = saved_errno;
- return NULL;
+ return nullptr;
}
return result;
}
@@ -538,7 +538,7 @@ main (int argc, char **argv)
if (optarg && (strlen (optarg) > 0))
eof_str = optarg;
else
- eof_str = NULL;
+ eof_str = nullptr;
break;
case 'h':
@@ -571,10 +571,10 @@ main (int argc, char **argv)
warn_mutually_exclusive ("-L", "--max-args");
bc_ctl.args_per_exec = 0;
}
- if (bc_ctl.replace_pat != NULL)
+ if (bc_ctl.replace_pat != nullptr)
{
warn_mutually_exclusive ("-L", "--replace");
- bc_ctl.replace_pat = NULL;
+ bc_ctl.replace_pat = nullptr;
}
break;
@@ -589,10 +589,10 @@ main (int argc, char **argv)
warn_mutually_exclusive ("--max-lines/-l", "--max-args");
bc_ctl.args_per_exec = 0;
}
- if (bc_ctl.replace_pat != NULL)
+ if (bc_ctl.replace_pat != nullptr)
{
warn_mutually_exclusive ("--max-lines/-l", "--replace");
- bc_ctl.replace_pat = NULL;
+ bc_ctl.replace_pat = nullptr;
}
break;
@@ -604,7 +604,7 @@ main (int argc, char **argv)
warn_mutually_exclusive ("--max-args/-n", "--max-lines");
bc_ctl.lines_per_exec = 0;
}
- if (bc_ctl.replace_pat != NULL)
+ if (bc_ctl.replace_pat != nullptr)
{
if (bc_ctl.args_per_exec == 1)
{
@@ -614,7 +614,7 @@ main (int argc, char **argv)
else
{
warn_mutually_exclusive ("--max-args/-n", "--replace");
- bc_ctl.replace_pat = NULL;
+ bc_ctl.replace_pat = nullptr;
}
}
break;
@@ -739,13 +739,13 @@ main (int argc, char **argv)
sigact.sa_handler = increment_proc_max;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = SA_RESTART;
- if (0 != sigaction (SIGUSR1, &sigact, (struct sigaction *)NULL))
+ if (0 != sigaction (SIGUSR1, &sigact, (struct sigaction *)nullptr))
error (0, errno, _("Cannot set SIGUSR1 signal handler"));
sigact.sa_handler = decrement_proc_max;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = SA_RESTART;
- if (0 != sigaction (SIGUSR2, &sigact, (struct sigaction *)NULL))
+ if (0 != sigaction (SIGUSR2, &sigact, (struct sigaction *)nullptr))
error (0, errno, _("Cannot set SIGUSR2 signal handler"));
# endif /* SIGUSR2 */
#endif /* SIGUSR1 */
@@ -759,7 +759,7 @@ main (int argc, char **argv)
{
keep_stdin = 1; /* see prep_child_for_exec () */
input_stream = fopen_cloexec_for_read_only (input_file);
- if (NULL == input_stream)
+ if (nullptr == input_stream)
{
error (EXIT_FAILURE, errno,
_("Cannot open input file %s"),
@@ -829,7 +829,7 @@ main (int argc, char **argv)
for (; optind < argc; optind++)
bc_push_arg (&bc_ctl, &bc_state,
argv[optind], strlen (argv[optind]) + 1,
- NULL, 0,
+ nullptr, 0,
initial_args);
initial_args = false;
bc_ctl.initial_argc = bc_state.cmd_argc;
@@ -868,7 +868,7 @@ main (int argc, char **argv)
bc_push_arg (&bc_ctl, &bc_state,
argv[optind], arglen[optind] + 1,
- NULL, 0,
+ nullptr, 0,
initial_args);
len--;
initial_args = false;
@@ -876,7 +876,7 @@ main (int argc, char **argv)
for (i = optind + 1; i < argc; i++)
bc_do_insert (&bc_ctl, &bc_state,
argv[i], arglen[i],
- NULL, 0,
+ nullptr, 0,
linebuf, len,
initial_args);
bc_do_exec (&bc_ctl, &bc_state);
@@ -950,7 +950,7 @@ read_line (void)
if (!bc_ctl.replace_pat)
bc_push_arg (&bc_ctl, &bc_state,
linebuf, len,
- NULL, 0,
+ nullptr, 0,
initial_args);
return len;
}
@@ -990,7 +990,7 @@ read_line (void)
if (!bc_ctl.replace_pat)
bc_push_arg (&bc_ctl, &bc_state,
linebuf, len,
- NULL, 0,
+ nullptr, 0,
initial_args);
return len;
}
@@ -1010,7 +1010,7 @@ read_line (void)
}
bc_push_arg (&bc_ctl, &bc_state,
linebuf, len,
- NULL, 0,
+ nullptr, 0,
initial_args);
p = linebuf;
state = SPACE;
@@ -1115,7 +1115,7 @@ read_string (void)
if (!bc_ctl.replace_pat)
bc_push_arg (&bc_ctl, &bc_state,
linebuf, len,
- NULL, 0,
+ nullptr, 0,
initial_args);
return len;
}
@@ -1127,7 +1127,7 @@ read_string (void)
if (!bc_ctl.replace_pat)
bc_push_arg (&bc_ctl, &bc_state,
linebuf, len,
- NULL, 0,
+ nullptr, 0,
initial_args);
return len;
}
--
2.51.1