maint: prefer NULL to nullptr

NULL is best for C as discussed - for coreutils - at:
  https://bugs.gnu.org/66221#53

* bootstrap.conf: Remove dependency on nullptr.
* s/nullptr/NULL/.

This effectively reverts 93ce19f0d5a1.
This commit is contained in:
Bernhard Voelker 2025-11-01 16:55:22 +01:00
parent 99b3365ec3
commit c56b96a54f
25 changed files with 356 additions and 367 deletions

View File

@ -134,7 +134,6 @@ gnulib_modules="
modf
mountlist
nstrftime
nullptr
open
openat-safer
parse-datetime

10
cfg.mk
View File

@ -65,10 +65,6 @@ 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])))$$
@ -315,12 +311,6 @@ 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

View File

@ -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 = nullptr;
execp->wd_for_exec->name = NULL;
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 = nullptr;
char *buf = NULL;
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 = nullptr;
prefix = NULL;
pfxlen = 0;
}
else
@ -145,7 +145,7 @@ impl_pred_exec (const char *pathname,
*/
assert (execp->wd_for_exec == initial_wd);
target = pathname;
prefix = nullptr;
prefix = NULL;
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 (nullptr != execp->wd_for_exec);
assert (NULL != execp->wd_for_exec);
if (!prep_child_for_exec (execp->close_stdin, execp->wd_for_exec))
{
_exit (1);

View File

@ -29,4 +29,4 @@
struct options options;
struct state state;
struct saved_cwd *initial_wd = nullptr;
struct saved_cwd *initial_wd = NULL;

View File

@ -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 = nullptr;
static struct mount_entry *mount_list = NULL;
/* 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 = nullptr;
mount_list = NULL;
}
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 = nullptr;
static char *current_fstype = NULL;
static dev_t current_dev;
if (current_fstype != nullptr)
if (current_fstype != NULL)
{
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 = nullptr;
best = NULL;
entries = get_file_system_list (true);
if (nullptr == entries)
if (NULL == 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=nullptr, entry=entries; entry; entry=entry->me_next)
for (type=NULL, 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 != nullptr);
*fstype_known = (type != NULL);
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 = nullptr;
dev_t *result = NULL;
/* 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 = nullptr;
result = NULL;
}
}
free_file_system_list (entries);

View File

@ -463,7 +463,7 @@ find (char *arg)
inside_dir (AT_FDCWD);
arglist[0] = arg;
arglist[1] = nullptr;
arglist[1] = NULL;
switch (options.symlink_handling)
{
@ -486,8 +486,8 @@ find (char *arg)
if (options.xdev)
ftsoptions |= FTS_XDEV;
p = fts_open (arglist, ftsoptions, nullptr);
if (nullptr == p)
p = fts_open (arglist, ftsoptions, NULL);
if (NULL == p)
{
error (0, errno, _("cannot search %s"),
safely_quote_err_filename (0, arg));
@ -497,7 +497,7 @@ find (char *arg)
{
int level = INT_MIN;
while ( (errno=0, ent=fts_read (p)) != nullptr )
while ( (errno=0, ent=fts_read (p)) != NULL )
{
if (state.execdirs_outstanding && ((int)ent->fts_level != level))
{
@ -518,7 +518,7 @@ find (char *arg)
state.type = state.have_type ? ent->fts_statp->st_mode : 0;
consider_visiting (p, ent);
}
/* fts_read returned nullptr; distinguish between "finished" and "error". */
/* fts_read returned NULL; distinguish between "finished" and "error". */
if (errno)
{
error (0, errno,
@ -540,7 +540,7 @@ find (char *arg)
state.exit_status = EXIT_FAILURE;
return false;
}
p = nullptr;
p = NULL;
}
return true;
}
@ -552,8 +552,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 = nullptr;
char const* files0_filename_quoted = nullptr;
FILE *stream = NULL;
char const* files0_filename_quoted = NULL;
struct argv_iterator *ai;
if (options.files0_from)
@ -585,7 +585,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 == nullptr)
if (stream == NULL)
{
error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
files0_filename_quoted);
@ -669,7 +669,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 == nullptr)
if (options.files0_from == NULL)
error (0, ENOENT, "%s", safely_quote_err_filename (0, file_name));
else
{
@ -734,7 +734,7 @@ main (int argc, char **argv)
}
state.shared_files = sharefile_init ("w");
if (nullptr == state.shared_files)
if (NULL == state.shared_files)
{
error (EXIT_FAILURE, errno,
_("Failed to initialize shared-file hash table"));

View File

@ -208,29 +208,29 @@ static struct parser_table const parse_entry_newerXY =
static struct parser_table const parse_table[] =
{
/* Regular options: no PRED function. */
{ ARG_OPTION, "d", parse_d, nullptr }, /* Mac OS X, FreeBSD, NetBSD, OpenBSD */
{ ARG_OPTION, "d", parse_d, NULL }, /* Mac OS X, FreeBSD, NetBSD, OpenBSD */
/* but deprecated in favour of -depth */
{ ARG_OPTION, "depth", parse_depth, nullptr }, /* POSIX */
{ ARG_OPTION, "files0-from", parse_files0_from, nullptr }, /* GNU */
{ ARG_OPTION, "ignore_readdir_race", parse_ignore_race, nullptr }, /* GNU */
{ ARG_OPTION, "maxdepth", parse_maxdepth, nullptr }, /* GNU */
{ ARG_OPTION, "mindepth", parse_mindepth, nullptr }, /* GNU */
{ ARG_OPTION, "mount", parse_mount, nullptr }, /* POSIX */
{ ARG_OPTION, "noleaf", parse_noleaf, nullptr }, /* GNU */
{ ARG_OPTION, "noignore_readdir_race", parse_noignore_race, nullptr }, /* GNU */
{ ARG_OPTION, "xdev", parse_xdev, nullptr }, /* POSIX */
{ ARG_OPTION, "depth", parse_depth, NULL }, /* POSIX */
{ ARG_OPTION, "files0-from", parse_files0_from, NULL }, /* GNU */
{ ARG_OPTION, "ignore_readdir_race", parse_ignore_race, NULL }, /* GNU */
{ ARG_OPTION, "maxdepth", parse_maxdepth, NULL }, /* GNU */
{ ARG_OPTION, "mindepth", parse_mindepth, NULL }, /* GNU */
{ ARG_OPTION, "mount", parse_mount, NULL }, /* POSIX */
{ ARG_OPTION, "noleaf", parse_noleaf, NULL }, /* GNU */
{ ARG_OPTION, "noignore_readdir_race", parse_noignore_race, NULL }, /* GNU */
{ ARG_OPTION, "xdev", parse_xdev, NULL }, /* POSIX */
/* GNU mandated, general options. */
{ ARG_OPTION, "help", parse_help, nullptr }, /* GNU */
{ ARG_OPTION, "-help", parse_help, nullptr }, /* GNU */
{ ARG_OPTION, "version", parse_version, nullptr }, /* GNU */
{ ARG_OPTION, "-version", parse_version, nullptr }, /* GNU */
{ ARG_OPTION, "help", parse_help, NULL }, /* GNU */
{ ARG_OPTION, "-help", parse_help, NULL }, /* GNU */
{ ARG_OPTION, "version", parse_version, NULL }, /* GNU */
{ ARG_OPTION, "-version", parse_version, NULL }, /* GNU */
/* Positional options (whose position is important). */
{ ARG_POSITIONAL_OPTION, "daystart", parse_daystart, nullptr }, /* GNU */
{ ARG_POSITIONAL_OPTION, "follow", parse_follow, nullptr }, /* GNU, Unix */
{ ARG_POSITIONAL_OPTION, "nowarn", parse_nowarn, nullptr }, /* GNU */
{ ARG_POSITIONAL_OPTION, "regextype", parse_regextype, nullptr }, /* GNU */
{ ARG_POSITIONAL_OPTION, "warn", parse_warn, nullptr }, /* GNU */
{ ARG_POSITIONAL_OPTION, "daystart", parse_daystart, NULL }, /* GNU */
{ ARG_POSITIONAL_OPTION, "follow", parse_follow, NULL }, /* GNU, Unix */
{ ARG_POSITIONAL_OPTION, "nowarn", parse_nowarn, NULL }, /* GNU */
{ ARG_POSITIONAL_OPTION, "regextype", parse_regextype, NULL }, /* GNU */
{ ARG_POSITIONAL_OPTION, "warn", parse_warn, NULL }, /* GNU */
/* Punctuation. */
{ ARG_PUNCTUATION, "!", parse_negate, pred_negate }, /* POSIX */
@ -312,14 +312,14 @@ static struct parser_table const parse_table[] =
#endif
/* Internal pseudo-option, therefore 3 minus: ---noop. */
{ ARG_NOOP, "--noop", nullptr, pred_true }, /* GNU, internal use only */
{ ARG_NOOP, "--noop", NULL, pred_true }, /* GNU, internal use only */
{0, nullptr, nullptr, nullptr}
{0, NULL, NULL, NULL}
};
static const char *first_nonoption_arg = nullptr;
static const struct parser_table *noop = nullptr;
static const char *first_nonoption_arg = NULL;
static const struct parser_table *noop = NULL;
static int
fallback_getfilecon (int fd, const char *name, char **p, int prev_rv)
@ -450,9 +450,9 @@ static const struct parser_table*
get_noop (void)
{
int i;
if (nullptr == noop)
if (NULL == noop)
{
for (i = 0; parse_table[i].parser_name != nullptr; i++)
for (i = 0; parse_table[i].parser_name != NULL; i++)
{
if (ARG_NOOP ==parse_table[i].type)
{
@ -535,7 +535,7 @@ parse_begin_user_args (char **args, int argno,
(void) argno;
(void) last;
(void) predicates;
first_nonoption_arg = nullptr;
first_nonoption_arg = NULL;
}
void
@ -582,7 +582,7 @@ found_parser (const char *original_arg, const struct parser_table *entry)
if (entry->type != ARG_POSITIONAL_OPTION)
{
if (entry->type == ARG_NOOP)
return nullptr; /* internal use only, trap -noop here. */
return NULL; /* internal use only, trap -noop here. */
/* Something other than -follow/-daystart.
* If this is an option, check if it followed
@ -590,7 +590,7 @@ found_parser (const char *original_arg, const struct parser_table *entry)
*/
if (entry->type == ARG_OPTION)
{
if ((first_nonoption_arg != nullptr)
if ((first_nonoption_arg != NULL)
&& should_issue_warnings ())
{
/* option which follows a non-option */
@ -611,7 +611,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 == nullptr)
if (first_nonoption_arg == NULL)
{
first_nonoption_arg = original_arg;
}
@ -624,7 +624,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 nullptr if SEARCH_NAME is not a valid predicate name. */
Return NULL if SEARCH_NAME is not a valid predicate name. */
const struct parser_table*
find_parser (const char *search_name)
@ -642,7 +642,7 @@ find_parser (const char *search_name)
if (*search_name == '-')
search_name++;
for (i = 0; parse_table[i].parser_name != nullptr; i++)
for (i = 0; parse_table[i].parser_name != NULL; i++)
{
if (strcmp (parse_table[i].parser_name, search_name) == 0)
{
@ -663,7 +663,7 @@ find_parser (const char *search_name)
return found_parser (original_arg, &parse_table[i]);
}
}
return nullptr;
return NULL;
}
static float
@ -708,9 +708,9 @@ estimate_timestamp_success_rate (time_t when)
static bool
collect_arg_nonconst (char **argv, int *arg_ptr, char **collected_arg)
{
if ((argv == nullptr) || (argv[*arg_ptr] == nullptr))
if ((argv == NULL) || (argv[*arg_ptr] == NULL))
{
*collected_arg = nullptr;
*collected_arg = NULL;
return false;
}
else
@ -748,7 +748,7 @@ collect_arg_stat_info (char **argv, int *arg_ptr, struct stat *p,
}
else
{
*argument = nullptr;
*argument = NULL;
return false;
}
}
@ -1145,14 +1145,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 != nullptr)
if (cur_gr != NULL)
{
gid = cur_gr->gr_gid;
}
else
{
uintmax_t num;
if ((xstrtoumax (groupname, nullptr, 10, &num, "") != LONGINT_OK)
if ((xstrtoumax (groupname, NULL, 10, &num, "") != LONGINT_OK)
|| (GID_T_MAX < num))
{
error (EXIT_FAILURE, 0,
@ -1336,7 +1336,7 @@ parse_ls (const struct parser_table* entry, char **argv, int *arg_ptr)
{
(void) &argv;
(void) &arg_ptr;
return insert_fls (entry, nullptr);
return insert_fls (entry, NULL);
}
static bool
@ -1460,7 +1460,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, nullptr);
our_pred = get_new_pred_chk_op (entry, NULL);
our_pred->pred_func = pred_negate;
our_pred->p_type = UNI_OP;
our_pred->p_prec = NEGATE_PREC;
@ -1495,7 +1495,7 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr)
(void) argv;
(void) arg_ptr;
if ((argv == nullptr) || (argv[*arg_ptr] == nullptr))
if ((argv == NULL) || (argv[*arg_ptr] == NULL))
{
return false;
}
@ -1524,8 +1524,8 @@ parse_newerXY (const struct parser_table* entry, char **argv, int *arg_ptr)
/* -newertY (for any Y) is invalid. */
if (x == 't'
|| (nullptr == strchr (validchars, x))
|| (nullptr == strchr ( validchars, y)))
|| (NULL == strchr (validchars, x))
|| (NULL == strchr ( validchars, y)))
{
return false;
}
@ -1536,7 +1536,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] == nullptr)
if (argv[1+*arg_ptr] == NULL)
{
error (EXIT_FAILURE, 0, _("The %s test needs an argument"),
quotearg_n_style (0, options.err_quoting_style, argv[*arg_ptr]));
@ -1600,7 +1600,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 != nullptr);
assert (our_pred->pred_func != NULL);
assert (our_pred->pred_func == pred_newerXY);
assert (our_pred->need_stat);
return true;
@ -1624,7 +1624,7 @@ parse_nogroup (const struct parser_table* entry, char **argv, int *arg_ptr)
(void) &argv;
(void) &arg_ptr;
our_pred = insert_primary (entry, nullptr);
our_pred = insert_primary (entry, NULL);
our_pred->est_success_rate = 1e-4;
return true;
}
@ -1669,7 +1669,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, nullptr);
our_pred = get_new_pred_chk_op (entry, NULL);
our_pred->pred_func = pred_openparen;
our_pred->p_type = OPEN_PAREN;
our_pred->p_prec = NO_PREC;
@ -1829,14 +1829,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 (nullptr == change
if (NULL == 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, nullptr);
perm_val[1] = mode_adjust (0, true, 0, change, nullptr);
perm_val[0] = mode_adjust (0, false, 0, change, NULL);
perm_val[1] = mode_adjust (0, true, 0, change, NULL);
free (change);
if (('/' == perm_expr[0]) && (0 == perm_val[0]) && (0 == perm_val[1]))
@ -1897,7 +1897,7 @@ parse_print0 (const struct parser_table* entry, char **argv, int *arg_ptr)
(void) entry;
(void) argv;
(void) arg_ptr;
return insert_fprint (entry, nullptr);
return insert_fprint (entry, NULL);
}
static bool
@ -2015,11 +2015,11 @@ insert_regex (char **argv,
our_pred->args.regex = re;
re->allocated = 100;
re->buffer = xmalloc (re->allocated);
re->fastmap = nullptr;
re->fastmap = NULL;
re_set_syntax (regex_options);
re->syntax = regex_options;
re->translate = nullptr;
re->translate = NULL;
error_message = re_compile_pattern (rx, strlen (rx), re);
if (error_message)
@ -2049,7 +2049,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 == nullptr) || (argv[*arg_ptr] == nullptr))
if ((argv == NULL) || (argv[*arg_ptr] == NULL))
return false;
arg = argv[*arg_ptr];
@ -2386,14 +2386,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 != nullptr)
if (cur_pwd != NULL)
{
uid = cur_pwd->pw_uid;
}
else
{
uintmax_t num;
if ((xstrtoumax (username, nullptr, 10, &num, "") != LONGINT_OK)
if ((xstrtoumax (username, NULL, 10, &num, "") != LONGINT_OK)
|| (UID_T_MAX < num))
{
error (EXIT_FAILURE, 0,
@ -2459,7 +2459,7 @@ parse_context (const struct parser_table* entry, char **argv, int *arg_ptr)
{
struct predicate *our_pred;
if ((argv == nullptr) || (argv[*arg_ptr] == nullptr))
if ((argv == NULL) || (argv[*arg_ptr] == NULL))
return false;
if (is_selinux_enabled () <= 0)
@ -2468,7 +2468,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, nullptr);
our_pred = insert_primary (entry, NULL);
our_pred->est_success_rate = 0.01f;
our_pred->need_stat = false;
our_pred->args.scontext = argv[*arg_ptr];
@ -2721,7 +2721,7 @@ check_path_safety (const char *action)
const char *path_separators = ":";
size_t pos, len;
if (nullptr == path)
if (NULL == path)
{
/* $PATH is not set. Assume the OS default is safe.
* That may not be true on Windows, but I'm not aware
@ -2782,7 +2782,7 @@ insert_exec_ok (const char *action,
struct predicate *our_pred;
struct exec_val *execp; /* Pointer for efficiency. */
if ((argv == nullptr) || (argv[*arg_ptr] == nullptr))
if ((argv == NULL) || (argv[*arg_ptr] == NULL))
return false;
our_pred = insert_primary_withpred (entry, func, "(some -exec* arguments)");
@ -2791,7 +2791,7 @@ insert_exec_ok (const char *action,
assert(predicate_uses_exec (our_pred));
execp = &our_pred->args.exec_vec;
execp->wd_for_exec = nullptr;
execp->wd_for_exec = NULL;
if ((func != pred_okdir) && (func != pred_ok))
{
@ -2813,13 +2813,13 @@ insert_exec_ok (const char *action,
if ((func == pred_execdir) || (func == pred_okdir))
{
execp->wd_for_exec = nullptr;
execp->wd_for_exec = NULL;
options.ignore_readdir_race = false;
check_path_safety (action);
}
else
{
assert (nullptr != initial_wd);
assert (NULL != initial_wd);
execp->wd_for_exec = initial_wd;
}
@ -2829,8 +2829,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=nullptr;
(argv[end] != nullptr)
for (end = start, prev_was_braces_only=false, brace_count=0, brace_arg=NULL;
(argv[end] != NULL)
&& ((argv[end][0] != ';') || (argv[end][1] != '\0'));
end++)
{
@ -2877,7 +2877,7 @@ insert_exec_ok (const char *action,
}
/* Fail if no command given or no semicolon found. */
if ((end == start) || (argv[end] == nullptr))
if ((end == start) || (argv[end] == NULL))
{
*arg_ptr = end;
free (our_pred);
@ -2940,8 +2940,8 @@ insert_exec_ok (const char *action,
/* "+" terminator, so we can just append our arguments after the
* command and initial arguments.
*/
execp->replace_vec = nullptr;
execp->ctl.replace_pat = nullptr;
execp->replace_vec = NULL;
execp->ctl.replace_pat = NULL;
execp->ctl.rplen = 0;
execp->ctl.lines_per_exec = 0; /* no limit */
execp->ctl.args_per_exec = 0; /* no limit */
@ -2957,7 +2957,7 @@ insert_exec_ok (const char *action,
{
bc_push_arg (&execp->ctl, &execp->state,
argv[i], strlen (argv[i])+1,
nullptr, 0,
NULL, 0,
1);
}
}
@ -2985,7 +2985,7 @@ insert_exec_ok (const char *action,
}
}
if (argv[end] == nullptr)
if (argv[end] == NULL)
*arg_ptr = end;
else
*arg_ptr = end + 1;
@ -3030,7 +3030,7 @@ get_relative_timestamp (const char *str,
}
/* Convert the ASCII number into floating-point. */
if (xstrtod (str, nullptr, &offset, strtod))
if (xstrtod (str, NULL, &offset, strtod))
{
if (isnan (offset))
{
@ -3216,7 +3216,7 @@ get_num (const char *str,
{
char *pend;
if (str == nullptr)
if (str == NULL)
return false;
/* Figure out the comparison type if the caller accepts one. */
@ -3277,17 +3277,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 nullptr;
return NULL;
}
}
return nullptr;
return NULL;
}
static void
open_output_file (const char *path, struct format_val *p)
{
p->segment = nullptr;
p->quote_opts = clone_quoting_options (nullptr);
p->segment = NULL;
p->quote_opts = clone_quoting_options (NULL);
if (!strcmp (path, "/dev/stderr"))
{
@ -3304,7 +3304,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 == nullptr)
if (p->stream == NULL)
{
fatal_nontarget_file_error (errno, path);
}

View File

@ -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 == nullptr
if (pred_ptr->pred_left == NULL
|| 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 != nullptr)
if (pred_ptr->pred_left != NULL)
{
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 == nullptr)
if (d == NULL)
{
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) == nullptr;
return getgrgid (stat_buf->st_gid) == NULL;
}
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) == nullptr;
return getpwuid (stat_buf->st_uid) == NULL;
}
@ -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 == nullptr
if (pred_ptr->pred_left == NULL
|| !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 != nullptr &&
if (stat_buf != NULL &&
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 *) nullptr) == len)
(struct re_registers *) NULL) == len)
return (true);
return (false);
}
@ -1170,8 +1170,8 @@ blank_rtrim (const char *str, char *buf)
{
int i;
if (str == nullptr)
return (nullptr);
if (str == NULL)
return (NULL);
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 != nullptr)
while (cur != NULL)
{
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 == nullptr)
&& node->pred_left == NULL)
{
/* 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 != nullptr; p=p->pred_next)
for (p=predicates; p != NULL; p=p->pred_next)
{
/* All predicates must do something. */
assert (p->pred_func != nullptr);
assert (p->pred_func != NULL);
/* All predicates must have a parser table entry. */
assert (p->parser_entry != nullptr);
assert (p->parser_entry != NULL);
/* 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 nullptr for the predicate function, that means that
* If the parser has NULL 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)

View File

@ -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 = nullptr;
(*segment)->next = NULL;
(*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 = nullptr;
*segmentp = NULL;
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 = nullptr;
static char *buf = NULL;
static size_t buf_size;
char *timefmt = nullptr;
char *timefmt = NULL;
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 == nullptr)
if (buf == NULL)
{
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 == nullptr) /* No leading directories. */
if (s == NULL) /* 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 = nullptr;
char *linkname = NULL;
if (S_ISLNK (stat_buf->st_mode))
{
linkname = areadlinkat (state.cwd_dir_fd, state.rel_pathname);
if (linkname == nullptr)
if (linkname == NULL)
{
nonfatal_target_file_error (errno, pathname);
state.exit_status = EXIT_FAILURE;

View File

@ -106,7 +106,7 @@ sharefile_init (const char *mode)
p->mode = strdup (mode);
if (p->mode)
{
p->table = hash_initialize (DefaultHashTableSize, nullptr,
p->table = hash_initialize (DefaultHashTableSize, NULL,
entry_hashfunc,
entry_comparator,
entry_free);
@ -125,7 +125,7 @@ sharefile_init (const char *mode)
free (p);
}
}
return nullptr;
return NULL;
}
void
@ -145,19 +145,19 @@ sharefile_fopen (sharefile_handle h, const char *filename)
new_entry = malloc (sizeof (struct SharefileEntry));
if (!new_entry)
return nullptr;
return NULL;
new_entry->name = strdup (filename);
if (nullptr == new_entry->name)
if (NULL == new_entry->name)
{
free (new_entry);
return nullptr;
return NULL;
}
if (nullptr == (new_entry->fp = fopen (filename, p->mode)))
if (NULL == (new_entry->fp = fopen (filename, p->mode)))
{
entry_free (new_entry);
return nullptr;
return NULL;
}
else
{
@ -169,7 +169,7 @@ sharefile_fopen (sharefile_handle h, const char *filename)
if (fstat (fd, &st) < 0)
{
entry_free (new_entry);
return nullptr;
return NULL;
}
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 nullptr;
return NULL;
}
}
}

View File

@ -32,13 +32,13 @@
/* All predicates for each path to process. */
static struct predicate *predicates = nullptr;
static struct predicate *predicates = NULL;
/* The root of the evaluation tree. */
static struct predicate *eval_tree = nullptr;
static struct predicate *eval_tree = NULL;
/* The last predicate allocated. */
static struct predicate *last_pred = nullptr;
static struct predicate *last_pred = NULL;
/* 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 = nullptr;
struct predicate *next = NULL;
struct predicate *this_pred = (*input);
if (*input == nullptr)
if (*input == NULL)
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 == nullptr)
if (prev_pred == NULL)
{
/* 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 ( (nullptr == (*input)->pred_next) || (*input)->pred_next->artificial )
if ( (NULL == (*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 == nullptr)
if ((*input == NULL)
|| ((*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 nullptr, all done. Otherwise, if
out the next operator. If NULL, 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 == nullptr)
if (*input == NULL)
return (next);
if ((int) (*input)->p_prec > (int) prev_prec)
{
next = scan_rest (input, next, prev_prec);
if (next == nullptr)
if (next == NULL)
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 == nullptr) || ((*input)->p_type == CLOSE_PAREN))
return (nullptr);
if ((*input == NULL) || ((*input)->p_type == CLOSE_PAREN))
return (NULL);
tree = head;
while ((*input != nullptr) && ((int) (*input)->p_prec > (int) prev_prec))
while ((*input != NULL) && ((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 = nullptr;
p->head = p->tail = NULL;
}
static void
@ -352,7 +352,7 @@ predlist_insert (struct predlist *list,
*pprev = curr->pred_left;
curr->pred_left = (*insertpos);
(*insertpos) = curr;
if (nullptr == list->tail)
if (NULL == 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 (nullptr == list->head)
if (NULL == 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 = nullptr;
q->pred_left = NULL;
/* 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 (nullptr == q->pred_left)
if (NULL == 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 (nullptr == new_list.tail)
if (NULL == 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 = nullptr;
struct predicate **pl = nullptr, **pr = nullptr;
const char *reason = NULL;
struct predicate **pl = NULL, **pr = NULL;
if (BI_OP != p->p_type)
reason = "Not a binary operation";
if (!reason)
{
if (nullptr == p->pred_left || nullptr == p->pred_right)
if (NULL == p->pred_left || NULL == p->pred_right)
reason = "Doesn't have two arms";
}
if (!reason)
{
if (nullptr == p->pred_left->pred_right)
if (NULL == 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={nullptr,nullptr}, name_list={nullptr,nullptr};
struct predlist regex_list={NULL,NULL}, name_list={NULL,NULL};
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 == nullptr || *eval_treep == nullptr)
if (eval_treep == NULL || *eval_treep == NULL)
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 != nullptr)
while (curr->pred_left != NULL)
{
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) != nullptr)
while ((curr = *prevp) != NULL)
{
/* 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 (nullptr != p);
assert (NULL != 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 (nullptr == p->pred_right);
assert (nullptr == p->pred_left);
assert (NULL == p->pred_right);
assert (NULL == p->pred_left);
return p->est_success_rate;
case PRIMARY_TYPE:
assert (nullptr == p->pred_right);
assert (nullptr == p->pred_left);
assert (NULL == p->pred_right);
assert (NULL == 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 (nullptr == p->pred_left);
assert (NULL == 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 = nullptr;
predicates = NULL;
/* 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 != nullptr);
assert (entry_close != nullptr);
assert (entry_print != nullptr);
assert (entry_open != NULL);
assert (entry_close != NULL);
assert (entry_print != NULL);
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 == nullptr)
if (parse_entry == NULL)
{
/* 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 = nullptr;
last_pred->arg_text = NULL;
}
pred_sanity_check(last_pred);
pred_sanity_check(predicates); /* XXX: expensive */
}
parse_end_user_args (argv, argc, last_pred, predicates);
if (predicates->pred_next == nullptr)
if (predicates->pred_next == NULL)
{
/* 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, nullptr);
eval_tree = get_expr (&cur_pred, NO_PREC, NULL);
calculate_derived_rates (eval_tree);
/* Check if we have any left-over predicates (this fixes
* Debian bug #185202).
*/
if (cur_pred != nullptr)
if (cur_pred != NULL)
{
/* cur_pred->p_name is often nullptr here */
/* cur_pred->p_name is often NULL 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 = nullptr;
p->arg_text = NULL;
}
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 == nullptr)
if (predicates == NULL)
{
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 = nullptr;
static const struct parser_table *entry_and = NULL;
/* Locate the entry in the parser table for the "and" operator */
if (nullptr == entry_and)
if (NULL == entry_and)
entry_and = find_parser ("and");
/* Check that it's actually there. If not, that is a bug.*/
assert (entry_and != nullptr);
assert (entry_and != NULL);
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 = nullptr;
new_pred->args.str = nullptr;
new_pred->arg_text = NULL;
new_pred->args.str = NULL;
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 == nullptr)
if (node == NULL)
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 (nullptr == node->pred_left && nullptr == node->pred_right)
if (NULL == node->pred_left && NULL == node->pred_right)
{
fprintf (fp, "no children.\n");
}

View File

@ -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) nullptr
args(.str) NULL
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 = nullptr;
new_pred->args.str = NULL;
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) nullptr
args(.str) NULL
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 != nullptr);
assert (entry->pred_func != NULL);
return insert_primary_withpred (entry, entry->pred_func, arg);
}
struct predicate *
insert_primary_noarg (const struct parser_table *entry)
{
return insert_primary (entry, nullptr);
return insert_primary (entry, NULL);
}
@ -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 = nullptr;
execp->wd_for_exec = NULL;
}
}
@ -392,7 +392,7 @@ do_exec (struct exec_val *execp)
static void
do_complete_pending_execdirs (struct predicate *p)
{
if (nullptr == p)
if (NULL == p)
return;
assert (state.execdirs_outstanding);
@ -443,7 +443,7 @@ complete_pending_execdirs (void)
void
complete_pending_execs (struct predicate *p)
{
if (nullptr == p)
if (NULL == 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 = nullptr;
initial_wd = NULL;
}
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 = nullptr;
p->args.printf_vec.stream = NULL;
}
}
@ -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 != nullptr)
while (pred != NULL)
{
if (pred->no_default_print)
return (false);
@ -812,7 +812,7 @@ static void
process_debug_options (char *arg)
{
const char *p;
char *token_context = nullptr;
char *token_context = NULL;
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 (nullptr, delimiters, &token_context);
p = strtok_r (NULL, 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 = nullptr;
p->files0_from = NULL;
p->ok_prompt_stdin = false;
}

View File

@ -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, nullptr, 0, 0);
bc_push_arg (ctl, state, special_terminating_arg, 0, NULL, 0, 0);
}
@ -145,7 +145,7 @@ bc_do_insert (struct buildcmd_control *ctl,
bc_push_arg (ctl, state,
insertbuf, p - insertbuf,
nullptr, 0,
NULL, 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] = nullptr;
working_args[dst_pos] = NULL;
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] == nullptr);
assert (state->cmd_argv[state->cmd_argc-1] == NULL);
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 != nullptr);
assert (arg != NULL);
if (!terminate)
{
@ -384,7 +384,7 @@ bc_push_arg (struct buildcmd_control *ctl,
}
if (terminate)
state->cmd_argv[state->cmd_argc++] = nullptr;
state->cmd_argv[state->cmd_argc++] = NULL;
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 = nullptr;
ctl->replace_pat = NULL;
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 = nullptr;
state->cmd_argv = NULL;
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, nullptr) == LONGINT_OK)
if (xstrtoul (val, &tmp, 10, &limit, NULL) == LONGINT_OK)
{
if (quantity > limit)
return 1;

View File

@ -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; /* nullptr */
char **cmd_argv; /* NULL */
/* Number of elements allocated for `cmd_argv'. */
size_t cmd_argv_alloc;

View File

@ -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 (nullptr == existing);
assert (NULL == 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 (nullptr == result)
if (NULL == 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 (nullptr == p)
if (NULL == p)
{
free (existing);
xalloc_die ();

View File

@ -75,7 +75,7 @@ get_proc_max_fd (void)
{
errno = 0;
dent = readdir (dir);
if (nullptr == dent)
if (NULL == 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 = nullptr;
cb_data.buf = NULL;
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 = nullptr;
non_cloexec_fds = NULL;
num_cloexec_fds = 0;
}

View File

@ -49,5 +49,5 @@ display_findutils_version (const char *official_name)
_("Eric B. Decker"),
_("James Youngman"),
_("Kevin Dalley"),
(const char*) nullptr);
(const char*) NULL);
}

View File

@ -68,7 +68,7 @@ print_quoted (FILE *fp,
if (buf != smallbuf)
{
free (buf);
buf = nullptr;
buf = NULL;
}
}
else

View File

@ -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."
""
,nullptr
,NULL
};
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 (nullptr == next)
if (NULL == next)
return "";
else
return next;
@ -556,7 +556,7 @@ describe_all (const char *contextname,
}
next = get_next (i+1, context);
if (nullptr == next)
if (NULL == next)
next = "";
begin_subsection (name, next, previous, up);
parent = get_regex_type_synonym (i, context);

View File

@ -108,7 +108,7 @@ get_regex_type_name (unsigned int ix)
if (ix < N_REGEX_MAP_ENTRIES)
return regex_map[ix].name;
else
return nullptr;
return NULL;
}
int

View File

@ -35,14 +35,14 @@ enum {
/* Returns the regex type name corresponding to index IX.
* Indexes start at 0. Returns nullptr if IX is too large.
* Indexes start at 0. Returns NULL 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 nullptr.
* has a value which would cause get_regex_type_name to return NULL.
*/
int get_regex_type_flags(unsigned int ix);

View File

@ -124,10 +124,10 @@ prefix_length (char *s1, char *s2)
static struct option const longopts[] =
{
{"help", no_argument, nullptr, 'h'},
{"version", no_argument, nullptr, 'v'},
{"null", no_argument, nullptr, '0'},
{nullptr, no_argument, nullptr, 0}
{"help", no_argument, NULL, 'h'},
{"version", no_argument, NULL, 'v'},
{"null", no_argument, NULL, '0'},
{NULL, no_argument, NULL, 0}
};
static void _GL_ATTRIBUTE_NORETURN

View File

@ -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 = nullptr;
static struct quoting_options * quote_opts = NULL;
static bool stdout_is_a_tty;
static bool print_quoted_filename;
static bool results_were_filtered;
static const char *selected_secure_db = nullptr;
static const char *selected_secure_db = NULL;
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 (nullptr == strpbrk (s, metacharacters))
if (NULL == 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 = nullptr;
char * p = NULL;
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 != nullptr);
assert (p != NULL);
needed = offs + nread + 1u;
if (needed > (*siz))
{
char *pnew = realloc (*buf, needed);
if (nullptr == pnew)
if (NULL == pnew)
{
return -1; /* FAIL */
}
@ -318,9 +318,9 @@ struct visitor
};
static struct visitor *inspectors = nullptr;
static struct visitor *lastinspector = nullptr;
static struct visitor *past_pat_inspector = nullptr;
static struct visitor *inspectors = NULL;
static struct visitor *lastinspector = NULL;
static struct visitor *past_pat_inspector = NULL;
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, nullptr);
return visit (inspectors, (VISIT_CONTINUE|VISIT_ACCEPTED), procdata, NULL);
}
/* 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, nullptr);
result = visit (past_pat_inspector, VISIT_CONTINUE, procdata, NULL);
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, nullptr);
result = visit (past_pat_inspector, VISIT_CONTINUE, procdata, NULL);
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 = nullptr;
static processfunc mainprocessor = NULL;
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 = nullptr;
p->next = NULL;
if (nullptr == lastinspector)
if (NULL == lastinspector)
{
lastinspector = inspectors = p;
}
@ -675,7 +675,7 @@ visit_substring_match_nocasefold_wide (struct process_data *procdata, void *cont
{
const char *pattern = context;
if (nullptr != mbsstr (procdata->munged_filename, pattern))
if (NULL != 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 (nullptr != strstr (procdata->munged_filename, pattern))
if (NULL != 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 (nullptr != mbscasestr (procdata->munged_filename, pattern))
if (NULL != 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 (nullptr != strcasestr (procdata->munged_filename, pattern))
if (NULL != 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 *) nullptr);
(struct re_registers *) NULL);
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 = nullptr;
lastinspector = nullptr;
past_pat_inspector = nullptr;
inspectors = NULL;
lastinspector = NULL;
past_pat_inspector = NULL;
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, nullptr);
add_visitor (visit_locate02_format, NULL);
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, nullptr);
add_visitor (visit_locate02_format, NULL);
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, nullptr);
add_visitor (visit_old_format, NULL);
}
}
if (basename_only)
add_visitor (visit_basename, nullptr);
add_visitor (visit_basename, NULL);
/* 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 = nullptr;
const char *error_message = NULL;
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 = nullptr;
p->regex.fastmap = NULL;
p->regex.syntax = regex_options;
p->regex.translate = nullptr;
p->regex.translate = NULL;
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, nullptr);
add_visitor (visit_existing_follow, NULL);
else /* -P */
add_visitor (visit_existing_nofollow, nullptr);
add_visitor (visit_existing_nofollow, NULL);
break;
case ACCEPT_NON_EXISTING:
results_were_filtered = true;
if (follow_symlinks) /* -L, default */
add_visitor (visit_non_existing_follow, nullptr);
add_visitor (visit_non_existing_follow, NULL);
else /* -P */
add_visitor (visit_non_existing_nofollow, nullptr);
add_visitor (visit_non_existing_nofollow, NULL);
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, nullptr);
add_visitor (visit_justprint_quoted, NULL);
else
add_visitor (visit_justprint_unquoted, nullptr);
add_visitor (visit_justprint_unquoted, NULL);
}
@ -1339,7 +1339,7 @@ search_one_database (int argc,
"is not obvious.\n"));
}
}
if (filesize || (database_mtime != nullptr))
if (filesize || (database_mtime != NULL))
print_stats (argc, filesize, database_mtime);
}
@ -1385,29 +1385,29 @@ enum
static struct option const longopts[] =
{
{"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}
{"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}
};
@ -1529,7 +1529,7 @@ cleanup_quote_opts (void)
static int
dolocate (int argc, char **argv, int secure_db_fd)
{
char *path_element = nullptr;
char *path_element = NULL;
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 (nullptr);
quote_opts = clone_quoting_options (NULL);
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 != nullptr);
assert (optarg != NULL);
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,
nullptr);
NULL);
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 (nullptr == fp)
if (NULL == 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) : nullptr,
have_mtime ? (&database_mtime) : NULL,
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 = nullptr;
path_element = NULL;
}
if (!user_selected_locate_path)
@ -1912,7 +1912,7 @@ open_secure_db (void)
{
LOCATE_DB,
"/var/lib/slocate/slocate.db",
nullptr
NULL
};
for (i=0; secure_db_list[i]; ++i)
{

View File

@ -36,7 +36,7 @@
enum { FLAGFILE_MAX = 128 };
static char flagfile_name[FLAGFILE_MAX];
static const char* tmpdir = nullptr;
static const char* tmpdir = NULL;
static void
@ -47,7 +47,7 @@ remove_temporary_files(void)
unlink(flagfile_name);
rmdir(tmpdir);
}
tmpdir = nullptr;
tmpdir = NULL;
}
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*)nullptr))
if (0 != sigaction(signum, &sa, (struct sigaction*)NULL))
{
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*)nullptr))
if (0 != sigaction(signum, &sa, (struct sigaction*)NULL))
{
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++] = nullptr;
argv[i++] = NULL;
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(nullptr, nullptr, signum);
status = run_xargs(NULL, NULL, 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(nullptr, nullptr, signum);
status = run_xargs(NULL, NULL, 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 (nullptr == tmpdir)
if (NULL == tmpdir)
{
error(2, errno, "failed to create temporary directory");
}

View File

@ -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 nullptr.
IEEE Std 1003.1, 2004 Edition allows this to be NULL.
In findutils releases up to and including 4.2.8, this was "_".
*/
static char *eof_str = nullptr;
static char *eof_str = NULL;
/* 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 = nullptr;
static pid_t *pids = NULL;
/* 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 = nullptr;
static char* slot_var_name = NULL;
enum LongOptionIdentifier
{
@ -173,25 +173,25 @@ enum LongOptionIdentifier
static struct option const longopts[] =
{
{"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}
{"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}
};
/* 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 = nullptr; /* Silence compiler warning. */
p = NULL; /* Silence compiler warning. */
error (EXIT_FAILURE, 0,
_("Invalid escape sequence %s in input delimiter specification."),
s);
}
errno = 0;
endp = nullptr;
endp = NULL;
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 nullptr;
return NULL;
}
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 nullptr;
return NULL;
}
return result;
}
@ -538,7 +538,7 @@ main (int argc, char **argv)
if (optarg && (strlen (optarg) > 0))
eof_str = optarg;
else
eof_str = nullptr;
eof_str = NULL;
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 != nullptr)
if (bc_ctl.replace_pat != NULL)
{
warn_mutually_exclusive ("-L", "--replace");
bc_ctl.replace_pat = nullptr;
bc_ctl.replace_pat = NULL;
}
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 != nullptr)
if (bc_ctl.replace_pat != NULL)
{
warn_mutually_exclusive ("--max-lines/-l", "--replace");
bc_ctl.replace_pat = nullptr;
bc_ctl.replace_pat = NULL;
}
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 != nullptr)
if (bc_ctl.replace_pat != NULL)
{
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 = nullptr;
bc_ctl.replace_pat = NULL;
}
}
break;
@ -740,13 +740,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 *)nullptr))
if (0 != sigaction (SIGUSR1, &sigact, (struct sigaction *)NULL))
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 *)nullptr))
if (0 != sigaction (SIGUSR2, &sigact, (struct sigaction *)NULL))
error (0, errno, _("Cannot set SIGUSR2 signal handler"));
# endif /* SIGUSR2 */
#endif /* SIGUSR1 */
@ -760,7 +760,7 @@ main (int argc, char **argv)
{
keep_stdin = 1; /* see prep_child_for_exec () */
input_stream = fopen_cloexec_for_read_only (input_file);
if (nullptr == input_stream)
if (NULL == input_stream)
{
error (EXIT_FAILURE, errno,
_("Cannot open input file %s"),
@ -830,7 +830,7 @@ main (int argc, char **argv)
for (; optind < argc; optind++)
bc_push_arg (&bc_ctl, &bc_state,
argv[optind], strlen (argv[optind]) + 1,
nullptr, 0,
NULL, 0,
initial_args);
initial_args = false;
bc_ctl.initial_argc = bc_state.cmd_argc;
@ -869,7 +869,7 @@ main (int argc, char **argv)
bc_push_arg (&bc_ctl, &bc_state,
argv[optind], arglen[optind] + 1,
nullptr, 0,
NULL, 0,
initial_args);
len--;
initial_args = false;
@ -877,7 +877,7 @@ main (int argc, char **argv)
for (i = optind + 1; i < argc; i++)
bc_do_insert (&bc_ctl, &bc_state,
argv[i], arglen[i],
nullptr, 0,
NULL, 0,
linebuf, len,
initial_args);
bc_do_exec (&bc_ctl, &bc_state);
@ -952,7 +952,7 @@ read_line (void)
if (!bc_ctl.replace_pat)
bc_push_arg (&bc_ctl, &bc_state,
linebuf, len,
nullptr, 0,
NULL, 0,
initial_args);
return len;
}
@ -992,7 +992,7 @@ read_line (void)
if (!bc_ctl.replace_pat)
bc_push_arg (&bc_ctl, &bc_state,
linebuf, len,
nullptr, 0,
NULL, 0,
initial_args);
return len;
}
@ -1012,7 +1012,7 @@ read_line (void)
}
bc_push_arg (&bc_ctl, &bc_state,
linebuf, len,
nullptr, 0,
NULL, 0,
initial_args);
p = linebuf;
state = SPACE;
@ -1118,7 +1118,7 @@ read_string (void)
if (!bc_ctl.replace_pat)
bc_push_arg (&bc_ctl, &bc_state,
linebuf, len,
nullptr, 0,
NULL, 0,
initial_args);
return len;
}
@ -1130,7 +1130,7 @@ read_string (void)
if (!bc_ctl.replace_pat)
bc_push_arg (&bc_ctl, &bc_state,
linebuf, len,
nullptr, 0,
NULL, 0,
initial_args);
return len;
}