mpsort
nproc
nstrftime
- nullptr
obstack
open
openat-safer
heap->array = xnmalloc (n_reserve, sizeof *(heap->array));
- heap->array[0] = nullptr;
+ heap->array[0] = NULL;
heap->capacity = n_reserve;
heap->count = 0;
heap->compare = compare ? compare : heap_default_compare;
void *top;
if (heap->count == 0)
- return nullptr;
+ return NULL;
top = heap->array[1];
heap->array[1] = heap->array[heap->count--];
main (int argc, char **argv)
{
randint i;
- randint n = strtoumax (argv[1], nullptr, 10);
- randint choices = strtoumax (argv[2], nullptr, 10);
+ randint n = strtoumax (argv[1], NULL, 10);
+ randint choices = strtoumax (argv[2], NULL, 10);
char const *name = argv[3];
struct randint_source *ints = randint_all_new (name, SIZE_MAX);
}
/* Create a new randint_source by creating a randread_source from
- NAME and ESTIMATED_BYTES. Return nullptr (setting errno) if
+ NAME and ESTIMATED_BYTES. Return NULL (setting errno) if
unsuccessful. */
struct randint_source *
randint_all_new (char const *name, size_t bytes_bound)
{
struct randread_source *source = randread_new (name, bytes_bound);
- return (source ? randint_new (source) : nullptr);
+ return (source ? randint_new (source) : NULL);
}
/* Return the random data source of *S. */
static sparse_map *
sparse_new (size_t size_hint)
{
- return hash_initialize (size_hint, nullptr, sparse_hash_, sparse_cmp_, free);
+ return hash_initialize (size_hint, NULL, sparse_hash_, sparse_cmp_, free);
}
/* Swap the values for I and J. If a value is not already present
/* From R, allocate and return a malloc'd array of the first H elements
of a random permutation of N elements. H must not exceed N.
- Return nullptr if H is zero. */
+ Return NULL if H is zero. */
size_t *
randperm_new (struct randint_source *r, size_t h, size_t n)
switch (h)
{
case 0:
- v = nullptr;
+ v = NULL;
break;
case 1:
if (sparse)
{
sv = sparse_new (h * 2);
- if (sv == nullptr)
+ if (sv == NULL)
xalloc_die ();
v = xnmalloc (h, sizeof *v);
}
else
{
- sv = nullptr; /* To placate GCC's -Wuninitialized. */
+ sv = NULL; /* To placate GCC's -Wuninitialized. */
v = xnmalloc (n, sizeof *v);
for (i = 0; i < n; i++)
v[i] = i;
default handler. Unless a non-default handler is used, NAME's
lifetime should be at least that of the returned value.
- Return nullptr (setting errno) on failure. */
+ Return NULL (setting errno) on failure. */
struct randread_source *
randread_new (char const *name, size_t bytes_bound)
{
if (bytes_bound == 0)
- return simple_new (nullptr, nullptr);
+ return simple_new (NULL, NULL);
else
{
- FILE *source = nullptr;
+ FILE *source = NULL;
struct randread_source *s;
if (name)
if (! (source = fopen_safer (name, "rb")))
- return nullptr;
+ return NULL;
s = simple_new (source, name);
int e = errno;
randread_free_body (s);
errno = e;
- return nullptr;
+ return NULL;
}
isaac_seed (&s->buf.isaac.state);
}
#include <stdlib.h>
/* Call lstat to get the device and inode numbers for '/'.
- Upon failure, return nullptr. Otherwise, set the members of
+ Upon failure, return NULL. Otherwise, set the members of
*ROOT_D_I accordingly and return ROOT_D_I. */
struct dev_ino *
get_root_dev_ino (struct dev_ino *root_d_i)
{
struct stat statbuf;
if (lstat ("/", &statbuf))
- return nullptr;
+ return NULL;
root_d_i->st_ino = statbuf.st_ino;
root_d_i->st_dev = statbuf.st_dev;
return root_d_i;
is_smack_enabled (void)
{
#ifdef HAVE_SMACK
- return smack_smackfs_path () != nullptr;
+ return smack_smackfs_path () != NULL;
#else
return false;
#endif
int flags)
{
__xdectoint_t tnum, r;
- strtol_error s_err = __xstrtol (n_str, nullptr, base, &tnum, suffixes);
+ strtol_error s_err = __xstrtol (n_str, NULL, base, &tnum, suffixes);
/* Errno value to report if there is an overflow. */
int overflow_errno;
int (*compar) (const FTSENT **, const FTSENT **))
{
FTS *fts = fts_open (argv, options | FTS_CWDFD, compar);
- if (fts == nullptr)
+ if (fts == NULL)
{
/* This can fail in two ways: out of memory or with errno==EINVAL,
which indicates it was called with invalid bit_flags. */
fdadvise (fileno (stdin), 0, 0, FADVISE_RANDOM);
/* Ignored. */
- fadvise (nullptr, FADVISE_RANDOM);
+ fadvise (NULL, FADVISE_RANDOM);
/* Invalid. */
fdadvise (42, 0, 0, FADVISE_RANDOM);
/* If invoked with a positive argument, run a benchmark;
if with a negative, run a do-nothing benchmark. */
- for (iterations = argc <= 1 ? 0 : strtol (argv[1], nullptr, 10);
+ for (iterations = argc <= 1 ? 0 : strtol (argv[1], NULL, 10);
iterations != 0;
iterations += (iterations < 0 ? 1 : -1))
if (0 <= iterations)
static struct option const longopts[] =
{
- {"multiple", no_argument, nullptr, 'a'},
- {"suffix", required_argument, nullptr, 's'},
- {"zero", no_argument, nullptr, 'z'},
+ {"multiple", no_argument, NULL, 'a'},
+ {"suffix", required_argument, NULL, 's'},
+ {"zero", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
{
bool multiple_names = false;
bool use_nuls = false;
- char const *suffix = nullptr;
+ char const *suffix = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
while (true)
{
- int c = getopt_long (argc, argv, "+as:z", longopts, nullptr);
+ int c = getopt_long (argc, argv, "+as:z", longopts, NULL);
if (c == -1)
break;
}
else
perform_basename (argv[optind],
- optind + 2 == argc ? argv[optind + 1] : nullptr,
+ optind + 2 == argc ? argv[optind + 1] : NULL,
use_nuls);
return EXIT_SUCCESS;
#endif
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
static bool
isuz85 (unsigned char ch)
{
- return c_isalnum (ch) || strchr (".-:+=^!/*?&<>()[]{}@%$#", ch) != nullptr;
+ return c_isalnum (ch) || strchr (".-:+=^!/*?&<>()[]{}@%$#", ch) != NULL;
}
static char const z85_encoding[85] ATTRIBUTE_NONSTRING =
static void
base58_encode_ctx_init (struct base_encode_context *ctx)
{
- ctx->ctx.base58.buf = nullptr;
+ ctx->ctx.base58.buf = NULL;
ctx->ctx.base58.size = 0;
ctx->ctx.base58.capacity = 0;
}
*out, outlen);
free (ctx->ctx.base58.buf);
- ctx->ctx.base58.buf = nullptr;
+ ctx->ctx.base58.buf = NULL;
return true;
}
{
ctx->ctx.base58.size = 0;
ctx->ctx.base58.capacity = 0;
- ctx->ctx.base58.buf = nullptr;
+ ctx->ctx.base58.buf = NULL;
}
static bool
*out, outlen);
free (ctx->ctx.base58.buf);
- ctx->ctx.base58.buf = nullptr;
+ ctx->ctx.base58.buf = NULL;
return ret;
}
#if BASE_TYPE == 42
/* Initialize encoding context if needed (for base58) */
struct base_encode_context encode_ctx;
- bool use_ctx = (base_encode_ctx_init != nullptr);
+ bool use_ctx = (base_encode_ctx_init != NULL);
if (use_ctx)
base_encode_ctx_init (&encode_ctx);
#endif
outbuf = xmalloc (DEC_BLOCKSIZE);
#if BASE_TYPE == 42
- ctx.inbuf = nullptr;
+ ctx.inbuf = NULL;
#endif
base_decode_ctx_init (&ctx);
atexit (close_stdout);
- while ((opt = getopt_long (argc, argv, "diw:", long_options, nullptr)) != -1)
+ while ((opt = getopt_long (argc, argv, "diw:", long_options, NULL)) != -1)
switch (opt)
{
case 'd':
case 'w':
{
intmax_t w;
- strtol_error s_err = xstrtoimax (optarg, nullptr, 10, &w, "");
+ strtol_error s_err = xstrtoimax (optarg, NULL, 10, &w, "");
if (LONGINT_OVERFLOW < s_err || w < 0)
error (EXIT_FAILURE, 0, "%s: %s",
_("invalid wrap size"), quote (optarg));
else
{
input_fh = fopen (infile, "rb");
- if (input_fh == nullptr)
+ if (input_fh == NULL)
error (EXIT_FAILURE, errno, "%s", quotef (infile));
}
while( 1 )
{
int option_index = 0;
- char *end = nullptr;
+ char *end = NULL;
unsigned long outbits;
static struct option long_options[] = {
{ "help", no_argument, 0, 0 },
{ "tag", no_argument, 0, 0 },
- { nullptr, 0, nullptr, 0 }
+ { NULL, 0, NULL, 0 }
};
c = getopt_long( argc, argv, "a:l:", long_options, &option_index );
for( i = optind; i < argc; ++i )
{
- FILE *f = nullptr;
+ FILE *f = NULL;
if( argv[i][0] == '-' && argv[i][1] == '\0' )
f = stdin;
else
unsupported or the input file seems empty. */
for (bool some_copied = false; ; some_copied = true)
- switch (copy_file_range (input_desc, nullptr, STDOUT_FILENO, nullptr,
+ switch (copy_file_range (input_desc, NULL, STDOUT_FILENO, NULL,
copy_max, 0))
{
case 0:
static struct option const long_options[] =
{
- {"number-nonblank", no_argument, nullptr, 'b'},
- {"number", no_argument, nullptr, 'n'},
- {"squeeze-blank", no_argument, nullptr, 's'},
- {"show-nonprinting", no_argument, nullptr, 'v'},
- {"show-ends", no_argument, nullptr, 'E'},
- {"show-tabs", no_argument, nullptr, 'T'},
- {"show-all", no_argument, nullptr, 'A'},
+ {"number-nonblank", no_argument, NULL, 'b'},
+ {"number", no_argument, NULL, 'n'},
+ {"squeeze-blank", no_argument, NULL, 's'},
+ {"show-nonprinting", no_argument, NULL, 'v'},
+ {"show-ends", no_argument, NULL, 'E'},
+ {"show-tabs", no_argument, NULL, 'T'},
+ {"show-all", no_argument, NULL, 'A'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
initialize_main (&argc, &argv);
/* Parse command line options. */
int c;
- while ((c = getopt_long (argc, argv, "benstuvAET", long_options, nullptr))
+ while ((c = getopt_long (argc, argv, "benstuvAET", long_options, NULL))
!= -1)
{
switch (c)
out_isreg && S_ISREG (istat_buf.st_mode) ? copy_cat () : 0;
if (copy_cat_status != 0)
{
- inbuf = nullptr;
+ inbuf = NULL;
ok &= 0 < copy_cat_status;
}
else
static bool verbose;
/* Pointer to the device and inode numbers of '/', when --recursive.
- Otherwise nullptr. */
+ Otherwise NULL. */
static struct dev_ino *root_dev_ino;
/* The name of the context file is being given. */
static struct option const long_options[] =
{
- {"recursive", no_argument, nullptr, 'R'},
- {"dereference", no_argument, nullptr, DEREFERENCE_OPTION},
- {"no-dereference", no_argument, nullptr, 'h'},
- {"no-preserve-root", no_argument, nullptr, NO_PRESERVE_ROOT},
- {"preserve-root", no_argument, nullptr, PRESERVE_ROOT},
- {"reference", required_argument, nullptr, REFERENCE_FILE_OPTION},
- {"user", required_argument, nullptr, 'u'},
- {"role", required_argument, nullptr, 'r'},
- {"type", required_argument, nullptr, 't'},
- {"range", required_argument, nullptr, 'l'},
- {"verbose", no_argument, nullptr, 'v'},
+ {"recursive", no_argument, NULL, 'R'},
+ {"dereference", no_argument, NULL, DEREFERENCE_OPTION},
+ {"no-dereference", no_argument, NULL, 'h'},
+ {"no-preserve-root", no_argument, NULL, NO_PRESERVE_ROOT},
+ {"preserve-root", no_argument, NULL, PRESERVE_ROOT},
+ {"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
+ {"user", required_argument, NULL, 'u'},
+ {"role", required_argument, NULL, 'r'},
+ {"type", required_argument, NULL, 't'},
+ {"range", required_argument, NULL, 'l'},
+ {"verbose", no_argument, NULL, 'v'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Given a security context, CONTEXT, derive a context_t (*RET),
static int
change_file_context (int fd, char const *file)
{
- char *file_context = nullptr;
+ char *file_context = NULL;
context_t context IF_LINT (= NULL);
char const * context_string;
int errors = 0;
- if (specified_context == nullptr)
+ if (specified_context == NULL)
{
int status = (affect_symlink_referent
? getfileconat (fd, file, &file_context)
/* If the file doesn't have a context, and we're not setting all of
the context components, there isn't really an obvious default.
Thus, we just give up. */
- if (file_context == nullptr)
+ if (file_context == NULL)
{
error (0, 0, _("can't apply partial context to unlabeled file %s"),
quoteaf (file));
context_string = specified_context;
}
- if (file_context == nullptr || ! streq (context_string, file_context))
+ if (file_context == NULL || ! streq (context_string, file_context))
{
int fail = (affect_symlink_referent
? setfileconat (fd, file, context_string)
}
}
- if (specified_context == nullptr)
+ if (specified_context == NULL)
{
context_free (context);
freecon (file_context);
{
bool ok = true;
- FTS *fts = xfts_open (files, bit_flags, nullptr);
+ FTS *fts = xfts_open (files, bit_flags, NULL);
while (true)
{
FTSENT *ent;
ent = fts_read (fts);
- if (ent == nullptr)
+ if (ent == NULL)
{
if (errno != 0)
{
bool ok;
bool preserve_root = false;
bool component_specified = false;
- char *reference_file = nullptr;
+ char *reference_file = NULL;
int optc;
initialize_main (&argc, &argv);
atexit (close_stdout);
while ((optc = getopt_long (argc, argv, "HLPRhvu:r:t:l:",
- long_options, nullptr))
+ long_options, NULL))
!= -1)
{
switch (optc)
if (reference_file)
{
- char *ref_context = nullptr;
+ char *ref_context = NULL;
if (getfilecon (reference_file, &ref_context) < 0)
error (EXIT_FAILURE, errno, _("failed to get security context of %s"),
else if (component_specified)
{
/* FIXME: it's already null, so this is a no-op. */
- specified_context = nullptr;
+ specified_context = NULL;
}
else
{
{
static struct dev_ino dev_ino_buf;
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
- if (root_dev_ino == nullptr)
+ if (root_dev_ino == NULL)
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
quoteaf ("/"));
}
else
{
- root_dev_ino = nullptr;
+ root_dev_ino = NULL;
}
ok = process_files (argv + optind, bit_flags | FTS_NOSTAT);
static enum Verbosity verbosity = V_off;
/* Pointer to the device and inode numbers of '/', when --recursive.
- Otherwise nullptr. */
+ Otherwise NULL. */
static struct dev_ino *root_dev_ino;
/* For long options that have no equivalent short option, use a
static struct option const long_options[] =
{
- {"changes", no_argument, nullptr, 'c'},
- {"dereference", no_argument, nullptr, DEREFERENCE_OPTION},
- {"recursive", no_argument, nullptr, 'R'},
- {"no-dereference", no_argument, nullptr, 'h'},
- {"no-preserve-root", no_argument, nullptr, NO_PRESERVE_ROOT},
- {"preserve-root", no_argument, nullptr, PRESERVE_ROOT},
- {"quiet", no_argument, nullptr, 'f'},
- {"reference", required_argument, nullptr, REFERENCE_FILE_OPTION},
- {"silent", no_argument, nullptr, 'f'},
- {"verbose", no_argument, nullptr, 'v'},
+ {"changes", no_argument, NULL, 'c'},
+ {"dereference", no_argument, NULL, DEREFERENCE_OPTION},
+ {"recursive", no_argument, NULL, 'R'},
+ {"no-dereference", no_argument, NULL, 'h'},
+ {"no-preserve-root", no_argument, NULL, NO_PRESERVE_ROOT},
+ {"preserve-root", no_argument, NULL, PRESERVE_ROOT},
+ {"quiet", no_argument, NULL, 'f'},
+ {"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
+ {"silent", no_argument, NULL, 'f'},
+ {"verbose", no_argument, NULL, 'v'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Return true if the chmodable permission bits of FILE changed.
{
ch.old_mode = file_stats->st_mode;
ch.new_mode = mode_adjust (ch.old_mode, S_ISDIR (ch.old_mode) != 0,
- umask_value, change, nullptr);
+ umask_value, change, NULL);
bool follow_symlink = !!dereference;
if (dereference == -1) /* -H with/without -R, -P without -R. */
follow_symlink = ent->fts_level == FTS_ROOTLEVEL;
{
mode_t naively_expected_mode =
mode_adjust (ch.old_mode, S_ISDIR (ch.old_mode) != 0,
- 0, change, nullptr);
+ 0, change, NULL);
if (ch.new_mode & ~naively_expected_mode)
{
char new_perms[12];
{
bool ok = true;
- FTS *fts = xfts_open (files, bit_flags, nullptr);
+ FTS *fts = xfts_open (files, bit_flags, NULL);
while (true)
{
FTSENT *ent;
ent = fts_read (fts);
- if (ent == nullptr)
+ if (ent == NULL)
{
if (errno != 0)
{
int
main (int argc, char **argv)
{
- char *mode = nullptr;
+ char *mode = NULL;
idx_t mode_len = 0;
idx_t mode_alloc = 0;
bool ok;
bool preserve_root = false;
- char const *reference_file = nullptr;
+ char const *reference_file = NULL;
int c;
int bit_flags = FTS_COMFOLLOW | FTS_PHYSICAL;
while ((c = getopt_long (argc, argv,
("HLPRcfhvr::w::x::X::s::t::u::g::o::a::,::+::=::"
"0::1::2::3::4::5::6::7::"),
- long_options, nullptr))
+ long_options, NULL))
!= -1)
{
switch (c)
{
static struct dev_ino dev_ino_buf;
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
- if (root_dev_ino == nullptr)
+ if (root_dev_ino == NULL)
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
quoteaf ("/"));
}
else
{
- root_dev_ino = nullptr;
+ root_dev_ino = NULL;
}
bit_flags |= FTS_DEFER_STAT;
chopt_init (struct Chown_option *chopt)
{
chopt->verbosity = V_off;
- chopt->root_dev_ino = nullptr;
+ chopt->root_dev_ino = NULL;
chopt->affect_symlink_referent = true;
chopt->recurse = false;
chopt->force_silent = false;
- chopt->user_name = nullptr;
- chopt->group_name = nullptr;
+ chopt->user_name = NULL;
+ chopt->group_name = NULL;
}
extern void
static char *
user_group_str (char const *user, char const *group)
{
- char *spec = nullptr;
+ char *spec = NULL;
if (user)
{
}
spec = user_group_str (user, group);
- old_spec = user_group_str (user ? old_user : nullptr,
- group ? old_group : nullptr);
+ old_spec = user_group_str (user ? old_user : NULL,
+ group ? old_group : NULL);
switch (changed)
{
: _("failed to change ownership of %s\n"));
free (old_spec);
old_spec = spec;
- spec = nullptr;
+ spec = NULL;
}
break;
case CH_NO_CHANGE_REQUESTED:
if (!ok)
{
do_chown = false;
- file_stats = nullptr;
+ file_stats = NULL;
}
else if (required_uid == (uid_t) -1 && required_gid == (gid_t) -1
&& chopt->verbosity == V_off
: !changed ? CH_NO_CHANGE_REQUESTED
: CH_SUCCEEDED);
char *old_usr = (file_stats
- ? uid_to_name (file_stats->st_uid) : nullptr);
+ ? uid_to_name (file_stats->st_uid) : NULL);
char *old_grp = (file_stats
- ? gid_to_name (file_stats->st_gid) : nullptr);
+ ? gid_to_name (file_stats->st_gid) : NULL);
char *new_usr = chopt->user_name
? chopt->user_name : uid != -1
- ? uid_to_str (uid) : nullptr;
+ ? uid_to_str (uid) : NULL;
char *new_grp = chopt->group_name
? chopt->group_name : gid != -1
- ? gid_to_str (gid) : nullptr;
+ ? gid_to_str (gid) : NULL;
describe_change (file_full_name, ch_status,
old_usr, old_grp,
new_usr, new_grp);
? 0
: FTS_NOSTAT);
- FTS *fts = xfts_open (files, bit_flags | stat_flags, nullptr);
+ FTS *fts = xfts_open (files, bit_flags | stat_flags, NULL);
while (true)
{
FTSENT *ent;
ent = fts_read (fts);
- if (ent == nullptr)
+ if (ent == NULL)
{
if (errno != 0)
{
bool recurse;
/* Pointer to the device and inode numbers of '/', when --recursive.
- Need not be freed. Otherwise nullptr. */
+ Need not be freed. Otherwise NULL. */
struct dev_ino *root_dev_ino;
/* This corresponds to the --dereference (opposite of -h) option. */
static struct option const long_options[] =
{
- {"recursive", no_argument, nullptr, 'R'},
- {"changes", no_argument, nullptr, 'c'},
- {"dereference", no_argument, nullptr, DEREFERENCE_OPTION},
- {"from", required_argument, nullptr, FROM_OPTION},
- {"no-dereference", no_argument, nullptr, 'h'},
- {"no-preserve-root", no_argument, nullptr, NO_PRESERVE_ROOT},
- {"preserve-root", no_argument, nullptr, PRESERVE_ROOT},
- {"quiet", no_argument, nullptr, 'f'},
- {"silent", no_argument, nullptr, 'f'},
- {"reference", required_argument, nullptr, REFERENCE_FILE_OPTION},
- {"verbose", no_argument, nullptr, 'v'},
+ {"recursive", no_argument, NULL, 'R'},
+ {"changes", no_argument, NULL, 'c'},
+ {"dereference", no_argument, NULL, DEREFERENCE_OPTION},
+ {"from", required_argument, NULL, FROM_OPTION},
+ {"no-dereference", no_argument, NULL, 'h'},
+ {"no-preserve-root", no_argument, NULL, NO_PRESERVE_ROOT},
+ {"preserve-root", no_argument, NULL, PRESERVE_ROOT},
+ {"quiet", no_argument, NULL, 'f'},
+ {"silent", no_argument, NULL, 'f'},
+ {"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
+ {"verbose", no_argument, NULL, 'v'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
chopt_init (&chopt);
- while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, nullptr))
+ while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, NULL))
!= -1)
{
switch (optc)
bool warn;
char const *e = parse_user_spec_warn (optarg,
&required_uid, &required_gid,
- nullptr, nullptr, &warn);
+ NULL, NULL, &warn);
if (e)
error (warn ? 0 : EXIT_FAILURE, 0, "%s: %s", e, quote (optarg));
break;
{
static struct dev_ino dev_ino_buf;
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
- if (chopt.root_dev_ino == nullptr)
+ if (chopt.root_dev_ino == NULL)
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
quoteaf ("/"));
}
static struct option const long_opts[] =
{
- {"groups", required_argument, nullptr, GROUPS},
- {"userspec", required_argument, nullptr, USERSPEC},
- {"skip-chdir", no_argument, nullptr, SKIP_CHDIR},
+ {"groups", required_argument, NULL, GROUPS},
+ {"userspec", required_argument, NULL, USERSPEC},
+ {"skip-chdir", no_argument, NULL, SKIP_CHDIR},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
#if ! HAVE_SETGROUPS
parse_additional_groups (char const *groups, GETGROUPS_T **pgids,
idx_t *pn_gids, bool show_errors)
{
- GETGROUPS_T *gids = nullptr;
+ GETGROUPS_T *gids = NULL;
idx_t n_gids_allocated = 0;
idx_t n_gids = 0;
char *buffer = xstrdup (groups);
int ret = 0;
for (char const *tmp = strtok (buffer, ","); tmp;
- tmp = strtok (nullptr, ","))
+ tmp = strtok (NULL, ","))
{
struct group *g;
uintmax_t value;
- if (xstrtoumax (tmp, nullptr, 10, &value, "") == LONGINT_OK
+ if (xstrtoumax (tmp, NULL, 10, &value, "") == LONGINT_OK
&& value <= MAXGID)
{
while (isspace (to_uchar (*tmp)))
{
/* Handle the case where the name is numeric. */
g = getgrnam (tmp);
- if (g != nullptr)
+ if (g != NULL)
value = g->gr_gid;
}
/* Flag that we've got a group from the number. */
- g = (struct group *) (intptr_t) ! nullptr;
+ g = (struct group *) (intptr_t) ! NULL;
}
else
{
g = getgrnam (tmp);
- if (g != nullptr)
+ if (g != NULL)
value = g->gr_gid;
}
- if (g == nullptr)
+ if (g == NULL)
{
ret = -1;
int c;
/* Input user and groups spec. */
- char *userspec = nullptr;
- char const *username = nullptr;
- char const *groups = nullptr;
+ char *userspec = NULL;
+ char const *username = NULL;
+ char const *groups = NULL;
bool skip_chdir = false;
/* Parsed user and group IDs. */
uid_t uid = -1;
gid_t gid = -1;
- GETGROUPS_T *out_gids = nullptr;
+ GETGROUPS_T *out_gids = NULL;
idx_t n_gids = 0;
initialize_main (&argc, &argv);
initialize_exit_failure (EXIT_CANCELED);
atexit (close_stdout);
- while ((c = getopt_long (argc, argv, "+", long_opts, nullptr)) != -1)
+ while ((c = getopt_long (argc, argv, "+", long_opts, NULL)) != -1)
{
switch (c)
{
Within chroot lookup is the main justification for having
the --user option supported by the chroot command itself. */
if (userspec)
- ignore_value (parse_user_spec (userspec, &uid, &gid, nullptr, nullptr));
+ ignore_value (parse_user_spec (userspec, &uid, &gid, NULL, NULL));
/* If no gid is supplied or looked up, do so now.
Also lookup the username for use with getgroups. */
{
/* No command. Run an interactive shell. */
char *shell = getenv ("SHELL");
- if (shell == nullptr)
+ if (shell == NULL)
shell = bad_cast ("/bin/sh");
argv[0] = shell;
argv[1] = bad_cast ("-i");
- argv[2] = nullptr;
+ argv[2] = NULL;
}
else
{
{
bool warn;
char const *err = parse_user_spec_warn (userspec, &uid, &gid,
- nullptr, nullptr, &warn);
+ NULL, NULL, &warn);
if (err)
error (warn ? 0 : EXIT_CANCELED, 0, "%s", (err));
}
}
GETGROUPS_T *gids = out_gids;
- GETGROUPS_T *in_gids = nullptr;
+ GETGROUPS_T *in_gids = NULL;
if (groups && *groups)
{
if (parse_additional_groups (groups, &in_gids, &n_gids, !n_gids) != 0)
{
"bsd", "sysv", "crc", "crc32b", "md5", "sha1",
"sha224", "sha256", "sha384", "sha512", /* Legacy naming */
- "sha2", "sha3", "blake2b", "sm3", nullptr
+ "sha2", "sha3", "blake2b", "sm3", NULL
};
static enum Algorithm const algorithm_types[] =
{
{
"BSD", "SYSV", "CRC", "CRC32B", "MD5", "SHA1",
"SHA224", "SHA256", "SHA384", "SHA512",
- "SHA2", "SHA3", "BLAKE2b", "SM3", nullptr
+ "SHA2", "SHA3", "BLAKE2b", "SM3", NULL
};
static int const algorithm_bits[] =
{
#if HASH_ALGO_CKSUM
static struct option const legacy_long_options[] =
{
- { "check", no_argument, nullptr, 'c' },
- { "ignore-missing", no_argument, nullptr, IGNORE_MISSING_OPTION },
- { "quiet", no_argument, nullptr, QUIET_OPTION },
- { "status", no_argument, nullptr, STATUS_OPTION },
- { "warn", no_argument, nullptr, 'w' },
- { "strict", no_argument, nullptr, STRICT_OPTION },
- { "tag", no_argument, nullptr, TAG_OPTION },
- { "zero", no_argument, nullptr, 'z' },
-
- { "binary", no_argument, nullptr, 'b' }, /* Deprecated. */
- { "text", no_argument, nullptr, 't' }, /* Deprecated. */
+ { "check", no_argument, NULL, 'c' },
+ { "ignore-missing", no_argument, NULL, IGNORE_MISSING_OPTION },
+ { "quiet", no_argument, NULL, QUIET_OPTION },
+ { "status", no_argument, NULL, STATUS_OPTION },
+ { "warn", no_argument, NULL, 'w' },
+ { "strict", no_argument, NULL, STRICT_OPTION },
+ { "tag", no_argument, NULL, TAG_OPTION },
+ { "zero", no_argument, NULL, 'z' },
+
+ { "binary", no_argument, NULL, 'b' }, /* Deprecated. */
+ { "text", no_argument, NULL, 't' }, /* Deprecated. */
{ GETOPT_HELP_OPTION_DECL },
{ GETOPT_VERSION_OPTION_DECL },
- { nullptr, 0, nullptr, 0 }
+ { NULL, 0, NULL, 0 }
};
#endif
static struct option const long_options[] =
{
#if HASH_ALGO_BLAKE2 || HASH_ALGO_CKSUM
- { "length", required_argument, nullptr, 'l'},
+ { "length", required_argument, NULL, 'l'},
#endif
#if !HASH_ALGO_SUM
- { "check", no_argument, nullptr, 'c' },
- { "ignore-missing", no_argument, nullptr, IGNORE_MISSING_OPTION},
- { "quiet", no_argument, nullptr, QUIET_OPTION },
- { "status", no_argument, nullptr, STATUS_OPTION },
- { "warn", no_argument, nullptr, 'w' },
- { "strict", no_argument, nullptr, STRICT_OPTION },
- { "tag", no_argument, nullptr, TAG_OPTION },
- { "zero", no_argument, nullptr, 'z' },
+ { "check", no_argument, NULL, 'c' },
+ { "ignore-missing", no_argument, NULL, IGNORE_MISSING_OPTION},
+ { "quiet", no_argument, NULL, QUIET_OPTION },
+ { "status", no_argument, NULL, STATUS_OPTION },
+ { "warn", no_argument, NULL, 'w' },
+ { "strict", no_argument, NULL, STRICT_OPTION },
+ { "tag", no_argument, NULL, TAG_OPTION },
+ { "zero", no_argument, NULL, 'z' },
# if HASH_ALGO_CKSUM
- { "algorithm", required_argument, nullptr, 'a'},
- { "base64", no_argument, nullptr, BASE64_OPTION },
- { "debug", no_argument, nullptr, DEBUG_PROGRAM_OPTION},
- { "raw", no_argument, nullptr, RAW_OPTION},
- { "untagged", no_argument, nullptr, UNTAG_OPTION },
+ { "algorithm", required_argument, NULL, 'a'},
+ { "base64", no_argument, NULL, BASE64_OPTION },
+ { "debug", no_argument, NULL, DEBUG_PROGRAM_OPTION},
+ { "raw", no_argument, NULL, RAW_OPTION},
+ { "untagged", no_argument, NULL, UNTAG_OPTION },
# endif
- { "binary", no_argument, nullptr, 'b' }, /* Deprecated. */
- { "text", no_argument, nullptr, 't' }, /* Deprecated. */
+ { "binary", no_argument, NULL, 'b' }, /* Deprecated. */
+ { "text", no_argument, NULL, 't' }, /* Deprecated. */
#else
- {"sysv", no_argument, nullptr, 's'}, /* Not in cksum. */
+ {"sysv", no_argument, NULL, 's'}, /* Not in cksum. */
#endif
{ GETOPT_HELP_OPTION_DECL },
{ GETOPT_VERSION_OPTION_DECL },
- { nullptr, 0, nullptr, 0 }
+ { NULL, 0, NULL, 0 }
};
void
and each "\\\\" with a single backslash, NUL-terminate it and return S.
If S is not a valid escaped file name, i.e., if it ends with an odd number
of backslashes or if it contains a backslash followed by anything other
- than "n" or another backslash, return nullptr. */
+ than "n" or another backslash, return NULL. */
static char *
filename_unescape (char *s, size_t s_len)
if (i == s_len - 1)
{
/* File name ends with an unescaped backslash: invalid. */
- return nullptr;
+ return NULL;
}
++i;
switch (s[i])
break;
default:
/* Only '\', 'n' or 'r' may follow a backslash. */
- return nullptr;
+ return NULL;
}
break;
case '\0':
/* The file name may not contain a NUL. */
- return nullptr;
+ return NULL;
default:
*dst++ = s[i];
*file_name = s;
- if (escaped_filename && filename_unescape (s, i) == nullptr)
+ if (escaped_filename && filename_unescape (s, i) == NULL)
return false;
s[i++] = '\0';
++i;
uintmax_t length;
char *siend;
- if (xstrtoumax (s + i, &siend, 0, &length, nullptr) != LONGINT_OK)
+ if (xstrtoumax (s + i, &siend, 0, &length, NULL) != LONGINT_OK)
return false;
# if HASH_ALGO_CKSUM
else if (cksum_algorithm == sha2 || cksum_algorithm == sha3)
*file_name = &s[i];
if (escaped_filename)
- return filename_unescape (&s[i], s_len - i) != nullptr;
+ return filename_unescape (&s[i], s_len - i) != NULL;
return true;
}
else
{
fp = fopen (filename, O_BINARY ? (*binary ? "rb" : "rt") : "r");
- if (fp == nullptr)
+ if (fp == NULL)
{
if (ignore_missing && errno == ENOENT)
{
else
{
checkfile_stream = fopen (checkfile_name, "r");
- if (checkfile_stream == nullptr)
+ if (checkfile_stream == NULL)
{
error (0, errno, "%s", quotef (checkfile_name));
return false;
}
line_number = 0;
- line = nullptr;
+ line = NULL;
line_chars_allocated = 0;
do
{
/* Line buffer stdout to ensure lines are written atomically and immediately
so that processes running in parallel do not intersperse their output. */
- setvbuf (stdout, nullptr, _IOLBF, 0);
+ setvbuf (stdout, NULL, _IOLBF, 0);
#if HASH_ALGO_SUM
char const *short_opts = "rs";
char const *short_opts = "bctwz";
#endif
- while ((opt = getopt_long (argc, argv, short_opts, long_opts, nullptr))
+ while ((opt = getopt_long (argc, argv, short_opts, long_opts, NULL))
!= -1)
switch (opt)
{
# endif
# endif
- return nullptr;
+ return NULL;
}
static cksum_fp_t
return cksum_avx2;
# endif
- return nullptr;
+ return NULL;
}
static cksum_fp_t
return cksum_avx512;
# endif
- return nullptr;
+ return NULL;
}
static cksum_fp_t
return cksum_vmull;
# endif
- return nullptr;
+ return NULL;
}
static bool
static struct option const long_options[] =
{
- {"check-order", no_argument, nullptr, CHECK_ORDER_OPTION},
- {"nocheck-order", no_argument, nullptr, NOCHECK_ORDER_OPTION},
- {"output-delimiter", required_argument, nullptr, OUTPUT_DELIMITER_OPTION},
- {"total", no_argument, nullptr, TOTAL_OPTION},
- {"zero-terminated", no_argument, nullptr, 'z'},
+ {"check-order", no_argument, NULL, CHECK_ORDER_OPTION},
+ {"nocheck-order", no_argument, NULL, NOCHECK_ORDER_OPTION},
+ {"output-delimiter", required_argument, NULL, OUTPUT_DELIMITER_OPTION},
+ {"total", no_argument, NULL, TOTAL_OPTION},
+ {"zero-terminated", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
check_input_order = CHECK_ORDER_DEFAULT;
total_option = false;
- while ((c = getopt_long (argc, argv, "123z", long_options, nullptr)) != -1)
+ while ((c = getopt_long (argc, argv, "123z", long_options, NULL)) != -1)
switch (c)
{
case '1':
(SSIZE_MAX, SIZE_MAX) truncated to a value that is
surely aligned well. */
ssize_t copy_max = MIN (SSIZE_MAX, SIZE_MAX) >> 30 << 30;
- ssize_t n_copied = copy_file_range (src_fd, nullptr, dest_fd, nullptr,
+ ssize_t n_copied = copy_file_range (src_fd, NULL, dest_fd, NULL,
MIN (max_n_read, copy_max), 0);
if (n_copied == 0)
{
{
/* Don’t treat EFBIG as a reportable error from copy_file_range.
If the input is at EOF and the output position is 2**63 - 1,
- copy_file_range (ifd, nullptr, ofd, nullptr, 2146435072, 0)
+ copy_file_range (ifd, NULL, ofd, NULL, 2146435072, 0)
incorrectly fails with EFBIG. Problem observed on Ubuntu 25.10
x86-64 with Linux kernel 6.17.0-8-generic #8-Ubuntu. */
if (errno == EFBIG)
static bool
write_zeros (int fd, off_t n_bytes, char **abuf, idx_t buf_size)
{
- char *zeros = nullptr;
+ char *zeros = NULL;
while (n_bytes)
{
idx_t n = MIN (buf_size, n_bytes);
= sparse_copy (src_fd, dest_fd, abuf, buf_size,
allow_reflink, src_name, dst_name,
ext_len,
- sparse_mode == SPARSE_ALWAYS ? hole_size : nullptr,
+ sparse_mode == SPARSE_ALWAYS ? hole_size : NULL,
debug);
if (n_read < 0)
return -1;
buf_size -= buf_size % blcm;
}
- char *buf = nullptr;
+ char *buf = NULL;
intmax_t result;
off_t hole_size = 0;
result = sparse_copy (ifd, ofd, &buf, buf_size,
x->reflink_mode != REFLINK_NEVER,
iname, oname, ibytes,
- make_holes ? &hole_size : nullptr,
+ make_holes ? &hole_size : NULL,
debug);
if (0 <= result && 0 < hole_size)
bool some_errors = (!all_errors && !x->reduce_diagnostics);
int (*check) (char const *, struct error_context *)
= (x->preserve_security_context || x->set_security_context
- ? check_selinux_attr : nullptr);
+ ? check_selinux_attr : NULL);
# if 4 < __GNUC__ + (8 <= __GNUC_MINOR__)
/* Pacify gcc -Wsuggest-attribute=format through at least GCC 13.2.1. */
.quote = copy_attr_quote,
.quote_free = copy_attr_free
})
- : nullptr);
+ : NULL);
# if 4 < __GNUC__ + (8 <= __GNUC_MINOR__)
# pragma GCC diagnostic pop
# endif
bool ok = true;
name_space = savedir (src_name_in, SAVEDIR_SORT_FASTREAD);
- if (name_space == nullptr)
+ if (name_space == NULL)
{
/* This diagnostic is a bit vague because savedir can fail in
several different ways. */
while (*namep != '\0')
{
bool local_copy_into_self;
- char *src_name = file_name_concat (src_name_in, namep, nullptr);
- char *dst_name = file_name_concat (dst_name_in, namep, nullptr);
+ char *src_name = file_name_concat (src_name_in, namep, NULL);
+ char *dst_name = file_name_concat (dst_name_in, namep, NULL);
bool first_dir_created = *first_dir_created_per_command_line_arg;
bool rename_succeeded;
{
x->dest_info
= hash_initialize (DEST_INFO_INITIAL_CAPACITY,
- nullptr,
+ NULL,
triple_hash,
triple_compare,
triple_free);
*/
x->src_info
= hash_initialize (DEST_INFO_INITIAL_CAPACITY,
- nullptr,
+ NULL,
triple_hash_no_name,
triple_compare,
triple_free);
putchar ('\n');
}
-/* A wrapper around "setfscreatecon (nullptr)" that exits upon failure. */
+/* A wrapper around "setfscreatecon (NULL)" that exits upon failure. */
static void
restore_default_fscreatecon_or_die (void)
{
- if (setfscreatecon (nullptr) != 0)
+ if (setfscreatecon (NULL) != 0)
error (EXIT_FAILURE, errno,
_("failed to restore the default file creation context"));
}
if (0 < err)
{
- char *a_src_name = nullptr;
+ char *a_src_name = NULL;
if (!src_name)
src_name = a_src_name = subst_suffix (dst_name, dst_relname,
src_relname);
mode_t dst_mode_bits;
mode_t omitted_permissions;
bool restore_dst_mode = false;
- char *earlier_file = nullptr;
- char *dst_backup = nullptr;
+ char *earlier_file = NULL;
+ char *dst_backup = NULL;
char const *drelname = *dst_relname ? dst_relname : ".";
bool delayed_ok;
bool copied_as_regular = false;
{
/* Note we currently replace DST_NAME unconditionally,
even if it was a newer separate file. */
- if (! create_hard_link (nullptr, dst_dirfd, earlier_file,
+ if (! create_hard_link (NULL, dst_dirfd, earlier_file,
dst_name, dst_dirfd, dst_relname,
true,
x->verbose, dereference))
struct stat *dst_lstat_sb
= (have_dst_lstat ? &dst_sb
: fstatat (dst_dirfd, drelname, &tmp_buf, AT_SYMLINK_NOFOLLOW) < 0
- ? nullptr : &tmp_buf);
+ ? NULL : &tmp_buf);
/* Never copy through a symlink we've just created. */
if (dst_lstat_sb
We'll use that info to detect this problem: cp -R dir dir. */
if (rename_errno == 0 || x->exchange)
- earlier_file = nullptr;
+ earlier_file = NULL;
else if (x->recursive && S_ISDIR (src_mode))
{
if (command_line_arg)
}
else
{
- if (! create_hard_link (nullptr, dst_dirfd, earlier_file,
+ if (! create_hard_link (NULL, dst_dirfd, earlier_file,
dst_name, dst_dirfd, dst_relname,
true, x->verbose, dereference))
goto un_backup;
if (x->move_mode)
printf (_("created directory %s\n"), quoteaf (dst_name));
else
- emit_verbose ("%s -> %s", src_name, dst_name, nullptr);
+ emit_verbose ("%s -> %s", src_name, dst_name, NULL);
}
}
else
{
char *src_link_val = areadlink_with_size (src_name, src_sb.st_size);
dest_is_symlink = true;
- if (src_link_val == nullptr)
+ if (src_link_val == NULL)
{
error (0, errno, _("cannot read symbolic link %s"),
quoteaf (src_name));
remove the entry associating the source dev/ino with the
destination file name, so we don't try to 'preserve' a link
to a file we didn't create. */
- if (earlier_file == nullptr)
+ if (earlier_file == NULL)
forget_created (src_sb.st_ino, src_sb.st_dev);
if (dst_backup)
bool first_dir_created_per_command_line_arg = false;
return copy_internal (src_name, dst_name, dst_dirfd, dst_relname,
- nonexistent_dst, nullptr, nullptr,
+ nonexistent_dst, NULL, NULL,
options, true,
&first_dir_created_per_command_line_arg,
copy_into_self, rename_succeeded);
rm -rf a b c; mkdir a b c; touch a/f b/f; mv a/f b/f c
For now, it protects only regular files when copying (i.e., not renaming).
When renaming, it protects all non-directories.
- Use dest_info_init to initialize it, or set it to nullptr to disable
+ Use dest_info_init to initialize it, or set it to NULL to disable
this feature. */
Hash_table *dest_info;
{
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
static void
launch_program (char const *prog_name, int prog_argc, char **prog_argv)
{
- int (*prog_main) (int, char **) = nullptr;
+ int (*prog_main) (int, char **) = NULL;
/* Ensure that at least one parameter was passed. */
if (!prog_argc || !prog_argv || !prog_argv[0] || !prog_name)
size_t nskip = 0;
if (argc >= 2)
{
- char *arg_name = nullptr;
+ char *arg_name = NULL;
/* If calling coreutils directly, the "script" name isn't passed.
Distinguish the two cases with a -shebang suffix. */
textdomain (PACKAGE);
atexit (close_stdout);
- if ((optc = getopt_long (argc, argv, "", long_options, nullptr)) != -1)
+ if ((optc = getopt_long (argc, argv, "", long_options, NULL)) != -1)
switch (optc)
{
case_GETOPT_HELP_CHAR;
probe.st_ino = ino;
probe.st_dev = dev;
- probe.name = nullptr;
+ probe.name = NULL;
ent = hash_remove (src_to_dest, &probe);
if (ent)
}
/* If INO/DEV correspond to an already-copied source file, return the
- name of the corresponding destination file. Otherwise, return nullptr. */
+ name of the corresponding destination file. Otherwise, return NULL. */
extern char *
src_to_dest_lookup (ino_t ino, dev_t dev)
ent.st_ino = ino;
ent.st_dev = dev;
e = hash_lookup (src_to_dest, &ent);
- return e ? e->name : nullptr;
+ return e ? e->name : NULL;
}
/* Add file NAME, copied from inode number INO and device number DEV,
to the list of files we have copied.
- Return nullptr if inserted, otherwise a non-null pointer. */
+ Return NULL if inserted, otherwise a non-null pointer. */
extern char *
remember_copied (char const *name, ino_t ino, dev_t dev)
ent->st_dev = dev;
ent_from_table = hash_insert (src_to_dest, ent);
- if (ent_from_table == nullptr)
+ if (ent_from_table == NULL)
{
/* Insertion failed due to lack of memory. */
xalloc_die ();
}
/* New key; insertion succeeded. */
- return nullptr;
+ return NULL;
}
/* Initialize the hash table. */
extern void
hash_init (void)
{
- src_to_dest = hash_initialize (INITIAL_TABLE_SIZE, nullptr,
+ src_to_dest = hash_initialize (INITIAL_TABLE_SIZE, NULL,
src_to_dest_hash,
src_to_dest_compare,
src_to_dest_free);
- if (src_to_dest == nullptr)
+ if (src_to_dest == NULL)
xalloc_die ();
}
static char const *const sparse_type_string[] =
{
- "never", "auto", "always", nullptr
+ "never", "auto", "always", NULL
};
static enum Sparse_type const sparse_type[] =
{
static char const *const reflink_type_string[] =
{
- "auto", "always", "never", nullptr
+ "auto", "always", "never", NULL
};
static enum Reflink_type const reflink_type[] =
{
static char const *const update_type_string[] =
{
- "all", "none", "none-fail", "older", nullptr
+ "all", "none", "none-fail", "older", NULL
};
static enum Update_type const update_type[] =
{
static struct option const long_opts[] =
{
- {"archive", no_argument, nullptr, 'a'},
- {"attributes-only", no_argument, nullptr, ATTRIBUTES_ONLY_OPTION},
- {"backup", optional_argument, nullptr, 'b'},
- {"copy-contents", no_argument, nullptr, COPY_CONTENTS_OPTION},
- {"debug", no_argument, nullptr, DEBUG_OPTION},
- {"dereference", no_argument, nullptr, 'L'},
- {"force", no_argument, nullptr, 'f'},
- {"interactive", no_argument, nullptr, 'i'},
- {"link", no_argument, nullptr, 'l'},
- {"no-clobber", no_argument, nullptr, 'n'}, /* Deprecated. */
- {"no-dereference", no_argument, nullptr, 'P'},
- {"no-preserve", required_argument, nullptr, NO_PRESERVE_ATTRIBUTES_OPTION},
- {"no-target-directory", no_argument, nullptr, 'T'},
- {"one-file-system", no_argument, nullptr, 'x'},
- {"parents", no_argument, nullptr, PARENTS_OPTION},
- {"path", no_argument, nullptr, PARENTS_OPTION}, /* Deprecated. */
- {"preserve", optional_argument, nullptr, PRESERVE_ATTRIBUTES_OPTION},
- {"recursive", no_argument, nullptr, 'R'},
- {"remove-destination", no_argument, nullptr, UNLINK_DEST_BEFORE_OPENING},
- {"sparse", required_argument, nullptr, SPARSE_OPTION},
- {"reflink", optional_argument, nullptr, REFLINK_OPTION},
- {"strip-trailing-slashes", no_argument, nullptr,
+ {"archive", no_argument, NULL, 'a'},
+ {"attributes-only", no_argument, NULL, ATTRIBUTES_ONLY_OPTION},
+ {"backup", optional_argument, NULL, 'b'},
+ {"copy-contents", no_argument, NULL, COPY_CONTENTS_OPTION},
+ {"debug", no_argument, NULL, DEBUG_OPTION},
+ {"dereference", no_argument, NULL, 'L'},
+ {"force", no_argument, NULL, 'f'},
+ {"interactive", no_argument, NULL, 'i'},
+ {"link", no_argument, NULL, 'l'},
+ {"no-clobber", no_argument, NULL, 'n'}, /* Deprecated. */
+ {"no-dereference", no_argument, NULL, 'P'},
+ {"no-preserve", required_argument, NULL, NO_PRESERVE_ATTRIBUTES_OPTION},
+ {"no-target-directory", no_argument, NULL, 'T'},
+ {"one-file-system", no_argument, NULL, 'x'},
+ {"parents", no_argument, NULL, PARENTS_OPTION},
+ {"path", no_argument, NULL, PARENTS_OPTION}, /* Deprecated. */
+ {"preserve", optional_argument, NULL, PRESERVE_ATTRIBUTES_OPTION},
+ {"recursive", no_argument, NULL, 'R'},
+ {"remove-destination", no_argument, NULL, UNLINK_DEST_BEFORE_OPENING},
+ {"sparse", required_argument, NULL, SPARSE_OPTION},
+ {"reflink", optional_argument, NULL, REFLINK_OPTION},
+ {"strip-trailing-slashes", no_argument, NULL,
STRIP_TRAILING_SLASHES_OPTION},
- {"suffix", required_argument, nullptr, 'S'},
- {"symbolic-link", no_argument, nullptr, 's'},
- {"target-directory", required_argument, nullptr, 't'},
- {"update", optional_argument, nullptr, 'u'},
- {"verbose", no_argument, nullptr, 'v'},
- {"keep-directory-symlink", no_argument, nullptr,
+ {"suffix", required_argument, NULL, 'S'},
+ {"symbolic-link", no_argument, NULL, 's'},
+ {"target-directory", required_argument, NULL, 't'},
+ {"update", optional_argument, NULL, 'u'},
+ {"verbose", no_argument, NULL, 'v'},
+ {"keep-directory-symlink", no_argument, NULL,
KEEP_DIRECTORY_SYMLINK_OPTION},
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
{
idx_t dirlen = dir_len (const_dir);
- *attr_list = nullptr;
+ *attr_list = NULL;
/* Succeed immediately if the parent of CONST_DIR must already exist,
as the target directory has already been checked. */
}
else
{
- if (verbose_fmt_string != nullptr)
+ if (verbose_fmt_string != NULL)
printf (verbose_fmt_string, src, dir);
}
parent_exists =
(make_dir_parents_private
(dst_name, arg_in_concat - dst_name, target_dirfd,
- (x->verbose ? "%s -> %s\n" : nullptr),
+ (x->verbose ? "%s -> %s\n" : NULL),
&attr_list, &new_dst, x));
}
else
bool copy_into_self;
ok &= copy (arg, dst_name, target_dirfd, dst_relname,
- new_dst, x, ©_into_self, nullptr);
+ new_dst, x, ©_into_self, NULL);
if (parents_option)
ok &= re_protect (dst_name, arg_in_concat, target_dirfd,
}
bool unused;
- ok = copy (source, dest, AT_FDCWD, dest, -new_dst, x, &unused, nullptr);
+ ok = copy (source, dest, AT_FDCWD, dest, -new_dst, x, &unused, NULL);
}
return ok;
x->explicit_no_preserve_mode = false;
x->preserve_security_context = false; /* -a or --preserve=context. */
x->require_preserve_context = false; /* --preserve=context. */
- x->set_security_context = nullptr; /* -Z, set sys default context. */
+ x->set_security_context = NULL; /* -Z, set sys default context. */
x->preserve_xattr = false;
x->reduce_diagnostics = false;
x->require_preserve_xattr = false;
in general one cannot do that safely, give the current semantics of
open's O_EXCL flag, (which POSIX doesn't even allow cp to use, btw).
But POSIX requires it. */
- x->open_dangling_dest_symlink = getenv ("POSIXLY_CORRECT") != nullptr;
+ x->open_dangling_dest_symlink = getenv ("POSIXLY_CORRECT") != NULL;
- x->dest_info = nullptr;
- x->src_info = nullptr;
+ x->dest_info = NULL;
+ x->src_info = NULL;
}
/* Given a string, ARG, containing a comma-separated list of arguments
static char const *const preserve_args[] =
{
"mode", "timestamps",
- "ownership", "links", "context", "xattr", "all", nullptr
+ "ownership", "links", "context", "xattr", "all", NULL
};
ARGMATCH_VERIFY (preserve_args, preserve_vals);
main (int argc, char **argv)
{
bool make_backups = false;
- char const *backup_suffix = nullptr;
- char *version_control_string = nullptr;
+ char const *backup_suffix = NULL;
+ char *version_control_string = NULL;
struct cp_options x;
bool copy_contents = false;
- char *target_directory = nullptr;
+ char *target_directory = NULL;
bool no_target_directory = false;
- char const *scontext = nullptr;
+ char const *scontext = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
int c;
while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:TZ",
- long_opts, nullptr))
+ long_opts, NULL))
!= -1)
{
switch (c)
break;
case REFLINK_OPTION:
- if (optarg == nullptr)
+ if (optarg == NULL)
x.reflink_mode = REFLINK_ALWAYS;
else
x.reflink_mode = XARGMATCH ("--reflink", optarg,
break;
case PRESERVE_ATTRIBUTES_OPTION:
- if (optarg == nullptr)
+ if (optarg == NULL)
{
/* Fall through to the case for 'p' below. */
}
else
{
x.set_security_context = selabel_open (SELABEL_CTX_FILE,
- nullptr, 0);
+ NULL, 0);
if (! x.set_security_context)
error (0, errno, _("warning: ignoring --context"));
}
/* FIXME: This handles new files. But what about existing files?
I.e., if updating a tree, new files would have the specified context,
but shouldn't existing files be updated for consistency like this?
- if (scontext && !restorecon (nullptr, dst_path, 0))
+ if (scontext && !restorecon (NULL, dst_path, 0))
error (...);
*/
if (scontext && setfscreatecon (scontext) < 0)
static void save_line_to_file (const struct cstring *line);
/* Start of buffer list. */
-static struct buffer_record *head = nullptr;
+static struct buffer_record *head = NULL;
/* Partially read line. */
-static char *hold_area = nullptr;
+static char *hold_area = NULL;
/* Number of bytes in 'hold_area'. */
static idx_t hold_count = 0;
static bool have_read_eof = false;
/* Name of output files. */
-static char *volatile filename_space = nullptr;
+static char *volatile filename_space = NULL;
/* Prefix part of output file names. */
-static char const *volatile prefix = nullptr;
+static char const *volatile prefix = NULL;
/* Suffix part of output file names. */
-static char *volatile suffix = nullptr;
+static char *volatile suffix = NULL;
/* Number of digits to use in output file names. */
static int volatile digits = 2;
static intmax_t bytes_written;
/* Output file pointer. */
-static FILE *output_stream = nullptr;
+static FILE *output_stream = NULL;
/* Output file name. */
-static char *output_filename = nullptr;
+static char *output_filename = NULL;
/* Perhaps it would be cleaner to pass arg values instead of indexes. */
static char **global_argv;
static struct option const longopts[] =
{
- {"digits", required_argument, nullptr, 'n'},
- {"quiet", no_argument, nullptr, 'q'}, /* Deprecated. */
- {"silent", no_argument, nullptr, 's'},
- {"keep-files", no_argument, nullptr, 'k'},
- {"elide-empty-files", no_argument, nullptr, 'z'},
- {"prefix", required_argument, nullptr, 'f'},
- {"suffix-format", required_argument, nullptr, 'b'},
- {"suppress-matched", no_argument, nullptr, SUPPRESS_MATCHED_OPTION},
+ {"digits", required_argument, NULL, 'n'},
+ {"quiet", no_argument, NULL, 'q'}, /* Deprecated. */
+ {"silent", no_argument, NULL, 's'},
+ {"keep-files", no_argument, NULL, 'k'},
+ {"elide-empty-files", no_argument, NULL, 'z'},
+ {"prefix", required_argument, NULL, 'f'},
+ {"suffix-format", required_argument, NULL, 'b'},
+ {"suppress-matched", no_argument, NULL, SUPPRESS_MATCHED_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Optionally remove files created so far; then exit.
sigprocmask (SIG_BLOCK, &caught_signals, &oldset);
delete_all_files (false);
- sigprocmask (SIG_SETMASK, &oldset, nullptr);
+ sigprocmask (SIG_SETMASK, &oldset, NULL);
}
static _Noreturn void
{
struct line *p = xmalloc (sizeof *p);
- p->next = nullptr;
+ p->next = NULL;
clear_line_control (p);
return p;
struct line *l;
/* If there is no existing area to keep line info, get some. */
- if (b->line_start == nullptr)
+ if (b->line_start == NULL)
b->line_start = b->curr_line = new_line_control ();
/* If existing area for lines is full, get more. */
{
struct buffer_record *new_buffer = xmalloc (sizeof *new_buffer);
new_buffer->bytes_alloc = 0;
- new_buffer->buffer = xpalloc (nullptr, &new_buffer->bytes_alloc, min_size,
+ new_buffer->buffer = xpalloc (NULL, &new_buffer->bytes_alloc, min_size,
-1, 1);
new_buffer->bytes_used = 0;
new_buffer->start_line = new_buffer->first_available = last_line_number + 1;
new_buffer->num_lines = 0;
- new_buffer->line_start = new_buffer->curr_line = nullptr;
- new_buffer->next = nullptr;
+ new_buffer->line_start = new_buffer->curr_line = NULL;
+ new_buffer->next = NULL;
return new_buffer;
}
static void
save_buffer (struct buffer_record *buf)
{
- buf->next = nullptr;
+ buf->next = NULL;
buf->curr_line = buf->line_start;
- if (head == nullptr)
+ if (head == NULL)
head = buf;
else
{
static intmax_t
get_first_line_in_buffer (void)
{
- if (head == nullptr && !load_buffer ())
+ if (head == NULL && !load_buffer ())
return 0;
return head->first_available;
/* Return a pointer to the logical first line in the buffer and make the
next line the logical first line.
- Return nullptr if there is no more input. */
+ Return NULL if there is no more input. */
static struct cstring *
remove_line (void)
/* If non-null, this is the buffer for which the previous call
returned the final line. So now, presuming that line has been
processed, we can free the buffer and reset this pointer. */
- static struct buffer_record *prev_buf = nullptr;
+ static struct buffer_record *prev_buf = NULL;
struct cstring *line; /* Return value. */
struct line *l; /* For convenience. */
if (prev_buf)
{
free_buffer (prev_buf);
- prev_buf = nullptr;
+ prev_buf = NULL;
}
- if (head == nullptr && !load_buffer ())
- return nullptr;
+ if (head == NULL && !load_buffer ())
+ return NULL;
if (current_line < head->first_available)
current_line = head->first_available;
{
/* Go on to the next line record. */
head->curr_line = l->next;
- if (head->curr_line == nullptr || head->curr_line->used == 0)
+ if (head->curr_line == NULL || head->curr_line->used == 0)
{
/* Go on to the next data block.
but first record the current one so we can free it
}
/* Search the buffers for line LINENUM, reading more input if necessary.
- Return a pointer to the line, or nullptr if it is not found in the file. */
+ Return a pointer to the line, or NULL if it is not found in the file. */
static struct cstring *
find_line (intmax_t linenum)
{
- if (head == nullptr && !load_buffer ())
- return nullptr;
+ if (head == NULL && !load_buffer ())
+ return NULL;
if (linenum < head->start_line)
- return nullptr;
+ return NULL;
for (struct buffer_record *b = head;;)
{
}
return &l->starts[offset];
}
- if (b->next == nullptr && !load_buffer ())
- return nullptr;
+ if (b->next == NULL && !load_buffer ())
+ return NULL;
b = b->next; /* Try the next data block. */
}
}
static bool
no_more_lines (void)
{
- return find_line (current_line + 1) == nullptr;
+ return find_line (current_line + 1) == NULL;
}
/* Open NAME as standard input. */
for (intmax_t i = 0; i < lines; i++)
{
line = remove_line ();
- if (line == nullptr)
+ if (line == NULL)
{
error (0, 0, _("%s: line number out of range"),
quote (global_argv[argnum]));
{
struct cstring *line;
- while ((line = remove_line ()) != nullptr)
+ while ((line = remove_line ()) != NULL)
save_line_to_file (line);
}
while (linenum++ < last_line_to_save)
{
struct cstring *line = remove_line ();
- if (line == nullptr)
+ if (line == NULL)
handle_line_error (p, repetition);
save_line_to_file (line);
}
while (true)
{
line = find_line (++current_line);
- if (line == nullptr)
+ if (line == NULL)
{
if (p->repeat_forever)
{
if (line->str[line_len - 1] == '\n')
line_len--;
ret = re_search (&p->re_compiled, line->str, line_len,
- 0, line_len, nullptr);
+ 0, line_len, NULL);
if (ret == -2)
{
error (0, 0, _("error in regular expression search"));
while (true)
{
line = find_line (++current_line);
- if (line == nullptr)
+ if (line == NULL)
{
if (p->repeat_forever)
{
if (line->str[line_len - 1] == '\n')
line_len--;
ret = re_search (&p->re_compiled, line->str, line_len,
- 0, line_len, nullptr);
+ 0, line_len, NULL);
if (ret == -2)
{
error (0, 0, _("error in regular expression search"));
sigset_t oldset;
sigprocmask (SIG_BLOCK, &caught_signals, &oldset);
output_stream = fopen (output_filename, "w");
- fopen_ok = (output_stream != nullptr);
+ fopen_ok = (output_stream != NULL);
fopen_errno = errno;
files_created = nfiles + fopen_ok;
- sigprocmask (SIG_SETMASK, &oldset, nullptr);
+ sigprocmask (SIG_SETMASK, &oldset, NULL);
}
if (! fopen_ok)
if (ferror (output_stream))
{
error (0, 0, _("write error for %s"), quoteaf (output_filename));
- output_stream = nullptr;
+ output_stream = NULL;
cleanup_fatal ();
}
if (fclose (output_stream) != 0)
{
error (0, errno, "%s", quotef (output_filename));
- output_stream = nullptr;
+ output_stream = NULL;
cleanup_fatal ();
}
if (bytes_written == 0 && elide_empty_files)
unlink_ok = (unlink (output_filename) == 0);
unlink_errno = errno;
files_created--;
- sigprocmask (SIG_SETMASK, &oldset, nullptr);
+ sigprocmask (SIG_SETMASK, &oldset, NULL);
if (! unlink_ok && unlink_errno != ENOENT)
error (0, unlink_errno, "%s", quotef (output_filename));
if (!suppress_count)
fprintf (stdout, "%jd\n", bytes_written);
}
- output_stream = nullptr;
+ output_stream = NULL;
}
}
if (l != line->len)
{
error (0, errno, _("write error for %s"), quoteaf (output_filename));
- output_stream = nullptr;
+ output_stream = NULL;
cleanup_fatal ();
}
bytes_written += line->len;
static void
check_for_offset (struct control *p, char const *str, char const *num)
{
- if (xstrtoimax (num, nullptr, 10, &p->offset, "") != LONGINT_OK)
+ if (xstrtoimax (num, NULL, 10, &p->offset, "") != LONGINT_OK)
error (EXIT_FAILURE, 0, _("%s: integer expected after delimiter"),
quote (str));
}
else
{
uintmax_t val;
- if (xstrtoumax (str + 1, nullptr, 10, &val, "") != LONGINT_OK
+ if (xstrtoumax (str + 1, NULL, 10, &val, "") != LONGINT_OK
|| ckd_add (&p->repeat, val, 0))
{
error (EXIT_FAILURE, 0,
char const *err;
closing_delim = strrchr (str + 1, delim);
- if (closing_delim == nullptr)
+ if (closing_delim == NULL)
error (EXIT_FAILURE, 0,
_("%s: closing delimiter '%c' missing"), str, delim);
p->ignore = ignore;
p->regexpr = true;
- p->re_compiled.buffer = nullptr;
+ p->re_compiled.buffer = NULL;
p->re_compiled.allocated = 0;
p->re_compiled.fastmap = xmalloc (UCHAR_MAX + 1);
- p->re_compiled.translate = nullptr;
+ p->re_compiled.translate = NULL;
re_syntax_options =
RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES;
err = re_compile_pattern (str + 1, len, &p->re_compiled);
p->argnum = i;
uintmax_t val;
- if (xstrtoumax (argv[i], nullptr, 10, &val, "") != LONGINT_OK
+ if (xstrtoumax (argv[i], NULL, 10, &val, "") != LONGINT_OK
|| INTMAX_MAX < val)
error (EXIT_FAILURE, 0, _("%s: invalid pattern"), quote (argv[i]));
if (val == 0)
error (EXIT_FAILURE, 0,
_("missing %% conversion specification in suffix"));
- int maxlen = snprintf (nullptr, 0, format, INT_MAX);
+ int maxlen = snprintf (NULL, 0, format, INT_MAX);
if (! (0 <= maxlen && maxlen <= IDX_MAX))
xalloc_die ();
return maxlen;
atexit (close_stdout);
global_argv = argv;
- controls = nullptr;
+ controls = NULL;
control_used = 0;
suppress_count = false;
remove_files = true;
suppress_matched = false;
prefix = DEFAULT_PREFIX;
- while ((optc = getopt_long (argc, argv, "f:b:kn:sqz", longopts, nullptr))
+ while ((optc = getopt_long (argc, argv, "f:b:kn:sqz", longopts, NULL))
!= -1)
switch (optc)
{
sigemptyset (&caught_signals);
for (int i = 0; i < nsigs; i++)
{
- sigaction (term_sig[i], nullptr, &act);
+ sigaction (term_sig[i], NULL, &act);
if (act.sa_handler != SIG_IGN)
sigaddset (&caught_signals, term_sig[i]);
}
for (int i = 0; i < nsigs; i++)
if (sigismember (&caught_signals, term_sig[i]))
- sigaction (term_sig[i], &act, nullptr);
+ sigaction (term_sig[i], &act, NULL);
}
split_file ();
static struct option const longopts[] =
{
- {"bytes", required_argument, nullptr, 'b'},
- {"characters", required_argument, nullptr, 'c'},
- {"fields", required_argument, nullptr, 'f'},
- {"delimiter", required_argument, nullptr, 'd'},
- {"only-delimited", no_argument, nullptr, 's'},
- {"output-delimiter", required_argument, nullptr, OUTPUT_DELIMITER_OPTION},
- {"complement", no_argument, nullptr, COMPLEMENT_OPTION},
- {"zero-terminated", no_argument, nullptr, 'z'},
+ {"bytes", required_argument, NULL, 'b'},
+ {"characters", required_argument, NULL, 'c'},
+ {"fields", required_argument, NULL, 'f'},
+ {"delimiter", required_argument, NULL, 'd'},
+ {"only-delimited", no_argument, NULL, 's'},
+ {"output-delimiter", required_argument, NULL, OUTPUT_DELIMITER_OPTION},
+ {"complement", no_argument, NULL, COMPLEMENT_OPTION},
+ {"zero-terminated", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
if (len < 0)
{
free (field_1_buffer);
- field_1_buffer = nullptr;
+ field_1_buffer = NULL;
if (ferror (stream) || feof (stream))
break;
xalloc_die ();
else
{
stream = fopen (file, "r");
- if (stream == nullptr)
+ if (stream == NULL)
{
error (0, errno, "%s", quotef (file));
return false;
bool ok;
bool delim_specified = false;
bool byte_mode = false;
- char *spec_list_string = nullptr;
+ char *spec_list_string = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
delim = '\0';
have_read_stdin = false;
- while ((optc = getopt_long (argc, argv, "b:c:d:f:nsz", longopts, nullptr))
+ while ((optc = getopt_long (argc, argv, "b:c:d:f:nsz", longopts, NULL))
!= -1)
{
switch (optc)
if (!delim_specified)
delim = '\t';
- if (output_delimiter_string == nullptr)
+ if (output_delimiter_string == NULL)
{
output_delimiter_default[0] = delim;
output_delimiter_string = output_delimiter_default;
/* Put "hours" and "minutes" first, since they aren't valid for
--rfc-3339. */
"hours", "minutes",
- "date", "seconds", "ns", nullptr
+ "date", "seconds", "ns", NULL
};
static enum Time_spec const time_spec[] =
{
static struct option const long_options[] =
{
- {"date", required_argument, nullptr, 'd'},
- {"debug", no_argument, nullptr, DEBUG_DATE_PARSING_OPTION},
- {"file", required_argument, nullptr, 'f'},
- {"iso-8601", optional_argument, nullptr, 'I'},
- {"reference", required_argument, nullptr, 'r'},
- {"resolution", no_argument, nullptr, RESOLUTION_OPTION},
- {"rfc-email", no_argument, nullptr, 'R'},
- {"rfc-822", no_argument, nullptr, 'R'}, /* Deprecated. */
- {"rfc-2822", no_argument, nullptr, 'R'}, /* Deprecated. */
- {"rfc-3339", required_argument, nullptr, RFC_3339_OPTION},
- {"set", required_argument, nullptr, 's'},
- {"uct", no_argument, nullptr, 'u'}, /* Deprecated. */
- {"utc", no_argument, nullptr, 'u'},
- {"universal", no_argument, nullptr, 'u'},
+ {"date", required_argument, NULL, 'd'},
+ {"debug", no_argument, NULL, DEBUG_DATE_PARSING_OPTION},
+ {"file", required_argument, NULL, 'f'},
+ {"iso-8601", optional_argument, NULL, 'I'},
+ {"reference", required_argument, NULL, 'r'},
+ {"resolution", no_argument, NULL, RESOLUTION_OPTION},
+ {"rfc-email", no_argument, NULL, 'R'},
+ {"rfc-822", no_argument, NULL, 'R'}, /* Deprecated. */
+ {"rfc-2822", no_argument, NULL, 'R'}, /* Deprecated. */
+ {"rfc-3339", required_argument, NULL, RFC_3339_OPTION},
+ {"set", required_argument, NULL, 's'},
+ {"uct", no_argument, NULL, 'u'}, /* Deprecated. */
+ {"utc", no_argument, NULL, 'u'},
+ {"universal", no_argument, NULL, 'u'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* flags for parse_datetime2 */
/* Return a newly allocated copy of FORMAT with each "%-N" adjusted to
be "%9N", "%6N", or whatever other resolution is appropriate for
- the current platform. If no "%-N" appears, return nullptr. */
+ the current platform. If no "%-N" appears, return NULL. */
static char *
adjust_resolution (char const *format)
{
- char *copy = nullptr;
+ char *copy = NULL;
for (char const *f = format; *f; f++)
if (f[0] == '%')
(in order to distinguish the default locale from the C locale on platforms
like macOS). */
char const *all = getenv ("LC_ALL");
- if (all != nullptr && *all != '\0')
+ if (all != NULL && *all != '\0')
{
/* Setting LC_TIME when LC_ALL is set would have no effect. Therefore we
have to unset LC_ALL and sets its value to all locale categories that
/* Set LC_TIME as an environment variable. */
char const *value = getenv ("LC_TIME");
- char *ret = (value == nullptr || *value == '\0' ? nullptr : xstrdup (value));
- if (locale != nullptr)
+ char *ret = (value == NULL || *value == '\0' ? NULL : xstrdup (value));
+ if (locale != NULL)
xsetenv ("LC_TIME", locale, 1);
else
unsetenv ("LC_TIME");
else
{
in_stream = fopen (input_filename, "r");
- if (in_stream == nullptr)
+ if (in_stream == NULL)
error (EXIT_FAILURE, errno, "%s", quotef (input_filename));
}
- char *line = nullptr;
+ char *line = NULL;
size_t buflen = 0;
bool ok = true;
while (true)
}
struct timespec when;
- if (! parse_datetime2 (&when, line, nullptr,
+ if (! parse_datetime2 (&when, line, NULL,
parse_datetime_flags, tz, tzstring))
{
if (line[line_length - 1] == '\n')
int
main (int argc, char **argv)
{
- char const *datestr = nullptr;
- char const *set_datestr = nullptr;
+ char const *datestr = NULL;
+ char const *set_datestr = NULL;
bool set_date = false;
- char const *format = nullptr;
+ char const *format = NULL;
bool format_in_c_locale = false;
bool get_resolution = false;
- char *batch_file = nullptr;
- char *reference = nullptr;
+ char *batch_file = NULL;
+ char *reference = NULL;
bool discarded_datestr = false;
bool discarded_set_datestr = false;
atexit (close_stdout);
int optc;
- while ((optc = getopt_long (argc, argv, short_options, long_options, nullptr))
+ while ((optc = getopt_long (argc, argv, short_options, long_options, NULL))
!= -1)
{
switch (optc)
timezone_t tz = tzalloc (tzstring);
bool ok = true;
- if (batch_file != nullptr)
+ if (batch_file != NULL)
ok = batch_convert (batch_file, format_res, format_in_c_locale,
tz, tzstring);
else
else
{
/* (option_specified_date || set_date) */
- if (reference != nullptr)
+ if (reference != NULL)
{
struct stat refstats;
if (stat (reference, &refstats) != 0)
{
if (set_datestr)
datestr = set_datestr;
- valid_date = parse_datetime2 (&when, datestr, nullptr,
+ valid_date = parse_datetime2 (&when, datestr, NULL,
parse_datetime_flags,
tz, tzstring);
}
STATUS_PROGRESS = 4
};
-/* The name of the input file, or nullptr for the standard input. */
-static char const *input_file = nullptr;
+/* The name of the input file, or NULL for the standard input. */
+static char const *input_file = NULL;
-/* The name of the output file, or nullptr for the standard output. */
-static char const *output_file = nullptr;
+/* The name of the output file, or NULL for the standard output. */
+static char const *output_file = NULL;
/* The page size on this host. */
static idx_t page_size;
sigemptyset (&caught_signals);
if (catch_siginfo)
sigaddset (&caught_signals, SIGINFO);
- sigaction (SIGINT, nullptr, &act);
+ sigaction (SIGINT, NULL, &act);
if (act.sa_handler != SIG_IGN)
sigaddset (&caught_signals, SIGINT);
act.sa_mask = caught_signals;
handle EINTR explicitly in iftruncate etc.
to avoid blocking on uncommitted read/write calls. */
act.sa_flags = 0;
- sigaction (SIGINFO, &act, nullptr);
+ sigaction (SIGINFO, &act, NULL);
}
if (sigismember (&caught_signals, SIGINT))
{
act.sa_handler = interrupt_handler;
act.sa_flags = SA_NODEFER | SA_RESETHAND;
- sigaction (SIGINT, &act, nullptr);
+ sigaction (SIGINT, &act, NULL);
}
}
if (infos)
info_signal_count = infos - 1;
- sigprocmask (SIG_SETMASK, &oldset, nullptr);
+ sigprocmask (SIG_SETMASK, &oldset, NULL);
if (interrupt)
cleanup ();
char const *name = argv[i];
char const *val = strchr (name, '=');
- if (val == nullptr)
+ if (val == NULL)
{
diagnose (0, _("unrecognized operand %s"), quoteaf (name));
usage (EXIT_FAILURE);
bool has_B = !!strchr (val, 'B');
intmax_t n_min = 0;
intmax_t n_max = INTMAX_MAX;
- idx_t *converted_idx = nullptr;
+ idx_t *converted_idx = NULL;
/* Maximum blocksize. Keep it smaller than IDX_MAX, so that
it fits into blocksize vars even if 1 is added for conv=swab.
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE, Version,
true, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
close_stdout_required = false;
/* Initialize translation table to identity translation. */
apply_translations ();
- if (input_file == nullptr)
+ if (input_file == NULL)
{
input_file = _("standard input");
set_fd_flags (STDIN_FILENO, input_flags, input_file);
input_offset = MAX (0, offset);
input_seek_errno = errno;
- if (output_file == nullptr)
+ if (output_file == NULL)
{
output_file = _("standard output");
set_fd_flags (STDOUT_FILENO, output_flags, output_file);
display_field_t field;
char const *arg;
field_type_t field_type;
- char const *caption;/* nullptr means use default header of this field. */
+ char const *caption;/* NULL means use default header of this field. */
int width; /* Auto adjusted (up) widths used to align columns. */
bool align_right; /* Whether to right-align columns, not left-align. */
bool used;
static struct option const long_options[] =
{
- {"all", no_argument, nullptr, 'a'},
- {"block-size", required_argument, nullptr, 'B'},
- {"inodes", no_argument, nullptr, 'i'},
- {"human-readable", no_argument, nullptr, 'h'},
- {"si", no_argument, nullptr, 'H'},
- {"local", no_argument, nullptr, 'l'},
- {"output", optional_argument, nullptr, OUTPUT_OPTION},
- {"portability", no_argument, nullptr, 'P'},
- {"print-type", no_argument, nullptr, 'T'},
- {"sync", no_argument, nullptr, SYNC_OPTION},
- {"no-sync", no_argument, nullptr, NO_SYNC_OPTION},
- {"total", no_argument, nullptr, TOTAL_OPTION},
- {"type", required_argument, nullptr, 't'},
- {"exclude-type", required_argument, nullptr, 'x'},
+ {"all", no_argument, NULL, 'a'},
+ {"block-size", required_argument, NULL, 'B'},
+ {"inodes", no_argument, NULL, 'i'},
+ {"human-readable", no_argument, NULL, 'h'},
+ {"si", no_argument, NULL, 'H'},
+ {"local", no_argument, NULL, 'l'},
+ {"output", optional_argument, NULL, OUTPUT_OPTION},
+ {"portability", no_argument, NULL, 'P'},
+ {"print-type", no_argument, NULL, 'T'},
+ {"sync", no_argument, NULL, SYNC_OPTION},
+ {"no-sync", no_argument, NULL, NO_SYNC_OPTION},
+ {"total", no_argument, NULL, TOTAL_OPTION},
+ {"type", required_argument, NULL, 't'},
+ {"exclude-type", required_argument, NULL, 'x'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Stat FILE and put the results into *ST. Return 0 if successful, an
if (ncolumns == ncolumns_alloc)
columns = xpalloc (columns, &ncolumns_alloc, 1, -1, sizeof *columns);
columns[ncolumns++] = &field_data[f];
- if (c != nullptr)
+ if (c != NULL)
field_data[f].caption = c;
affirm (!field_data[f].used);
case IPCENT_FIELD:
case TARGET_FIELD:
case FILE_FIELD:
- alloc_field (field, nullptr);
+ alloc_field (field, NULL);
break;
case SIZE_FIELD:
switch (header_mode)
{
case DEFAULT_MODE:
- alloc_field (SOURCE_FIELD, nullptr);
+ alloc_field (SOURCE_FIELD, NULL);
if (print_type)
- alloc_field (FSTYPE_FIELD, nullptr);
- alloc_field (SIZE_FIELD, nullptr);
- alloc_field (USED_FIELD, nullptr);
- alloc_field (AVAIL_FIELD, nullptr);
- alloc_field (PCENT_FIELD, nullptr);
- alloc_field (TARGET_FIELD, nullptr);
+ alloc_field (FSTYPE_FIELD, NULL);
+ alloc_field (SIZE_FIELD, NULL);
+ alloc_field (USED_FIELD, NULL);
+ alloc_field (AVAIL_FIELD, NULL);
+ alloc_field (PCENT_FIELD, NULL);
+ alloc_field (TARGET_FIELD, NULL);
break;
case HUMAN_MODE:
- alloc_field (SOURCE_FIELD, nullptr);
+ alloc_field (SOURCE_FIELD, NULL);
if (print_type)
- alloc_field (FSTYPE_FIELD, nullptr);
+ alloc_field (FSTYPE_FIELD, NULL);
alloc_field (SIZE_FIELD, N_("Size"));
- alloc_field (USED_FIELD, nullptr);
+ alloc_field (USED_FIELD, NULL);
alloc_field (AVAIL_FIELD, N_("Avail"));
- alloc_field (PCENT_FIELD, nullptr);
- alloc_field (TARGET_FIELD, nullptr);
+ alloc_field (PCENT_FIELD, NULL);
+ alloc_field (TARGET_FIELD, NULL);
break;
case INODES_MODE:
- alloc_field (SOURCE_FIELD, nullptr);
+ alloc_field (SOURCE_FIELD, NULL);
if (print_type)
- alloc_field (FSTYPE_FIELD, nullptr);
- alloc_field (ITOTAL_FIELD, nullptr);
- alloc_field (IUSED_FIELD, nullptr);
- alloc_field (IAVAIL_FIELD, nullptr);
- alloc_field (IPCENT_FIELD, nullptr);
- alloc_field (TARGET_FIELD, nullptr);
+ alloc_field (FSTYPE_FIELD, NULL);
+ alloc_field (ITOTAL_FIELD, NULL);
+ alloc_field (IUSED_FIELD, NULL);
+ alloc_field (IAVAIL_FIELD, NULL);
+ alloc_field (IPCENT_FIELD, NULL);
+ alloc_field (TARGET_FIELD, NULL);
break;
case POSIX_MODE:
- alloc_field (SOURCE_FIELD, nullptr);
+ alloc_field (SOURCE_FIELD, NULL);
if (print_type)
- alloc_field (FSTYPE_FIELD, nullptr);
- alloc_field (SIZE_FIELD, nullptr);
- alloc_field (USED_FIELD, nullptr);
- alloc_field (AVAIL_FIELD, nullptr);
+ alloc_field (FSTYPE_FIELD, NULL);
+ alloc_field (SIZE_FIELD, NULL);
+ alloc_field (USED_FIELD, NULL);
+ alloc_field (AVAIL_FIELD, NULL);
alloc_field (PCENT_FIELD, N_("Capacity"));
- alloc_field (TARGET_FIELD, nullptr);
+ alloc_field (TARGET_FIELD, NULL);
break;
case OUTPUT_MODE:
static bool
selected_fstype (char const *fstype)
{
- if (fs_select_list == nullptr || fstype == nullptr)
+ if (fs_select_list == NULL || fstype == NULL)
return true;
for (const struct fs_type_list *fsp = fs_select_list; fsp;
fsp = fsp->fs_next)
static bool
excluded_fstype (char const *fstype)
{
- if (fs_exclude_list == nullptr || fstype == nullptr)
+ if (fs_exclude_list == NULL || fstype == NULL)
return false;
for (const struct fs_type_list *fsp = fs_exclude_list; fsp;
fsp = fsp->fs_next)
static struct devlist *
devlist_for_dev (dev_t dev)
{
- if (devlist_table == nullptr)
- return nullptr;
+ if (devlist_table == NULL)
+ return NULL;
struct devlist dev_entry;
dev_entry.dev_num = dev;
struct devlist *found = hash_lookup (devlist_table, &dev_entry);
- if (found == nullptr)
- return nullptr;
+ if (found == NULL)
+ return NULL;
/* Return the last devlist entry we have seen with this dev_num */
return found->seen_last;
filter_mount_list (bool devices_only)
{
/* Temporary list to keep entries ordered. */
- struct devlist *device_list = nullptr;
+ struct devlist *device_list = NULL;
int mount_list_size = 0;
for (struct mount_entry *me = mount_list; me; me = me->me_next)
mount_list_size++;
- devlist_table = hash_initialize (mount_list_size, nullptr,
- devlist_hash, devlist_compare, nullptr);
- if (devlist_table == nullptr)
+ devlist_table = hash_initialize (mount_list_size, NULL,
+ devlist_hash, devlist_compare, NULL);
+ if (devlist_table == NULL)
xalloc_die ();
/* Sort all 'wanted' entries into the list device_list. */
for (struct mount_entry *me = mount_list; me;)
{
struct stat buf;
- struct mount_entry *discard_me = nullptr;
+ struct mount_entry *discard_me = NULL;
/* Avoid stating remote file systems as that may hang.
On Linux we probably have me_dev populated from /proc/self/mountinfo,
bool target_nearer_root = strlen (seen_dev->me->me_mountdir)
> strlen (me->me_mountdir);
/* With bind mounts, prefer items nearer the root of the source */
- bool source_below_root = seen_dev->me->me_mntroot != nullptr
- && me->me_mntroot != nullptr
+ bool source_below_root = seen_dev->me->me_mntroot != NULL
+ && me->me_mntroot != NULL
&& (strlen (seen_dev->me->me_mntroot)
< strlen (me->me_mntroot));
if (! print_grand_total
device_list = devlist;
struct devlist *hash_entry = hash_insert (devlist_table, devlist);
- if (hash_entry == nullptr)
+ if (hash_entry == NULL)
xalloc_die ();
/* Ensure lookups use this latest devlist. */
hash_entry->seen_last = devlist;
/* Finally rebuild the mount_list from the devlist. */
if (! devices_only)
{
- mount_list = nullptr;
+ mount_list = NULL;
while (device_list)
{
/* Add the mount entry. */
device_list = next;
}
hash_free (devlist_table);
- devlist_table = nullptr;
+ devlist_table = NULL;
}
}
/* Search a mount entry list for device id DEV.
- Return the corresponding mount entry if found or nullptr if not. */
+ Return the corresponding mount entry if found or NULL if not. */
ATTRIBUTE_PURE
static struct mount_entry const *
if (dl)
return dl->me;
- return nullptr;
+ return NULL;
}
/* Return true if N is a known integer value. On many file systems,
v = &inode_values;
break;
case OTHER_FLD:
- v = nullptr;
+ v = NULL;
break;
default:
affirm (!"bad field_type");
}
/* Scan the mount list returning the _last_ device found for MOUNT.
- nullptr is returned if MOUNT not found. The result is malloced. */
+ NULL is returned if MOUNT not found. The result is malloced. */
static char *
last_device_for_mount (char const *mount)
{
- struct mount_entry const *le = nullptr;
+ struct mount_entry const *le = NULL;
for (struct mount_entry const *me = mount_list; me; me = me->me_next)
{
return xstrdup (le->me_devname);
}
else
- return nullptr;
+ return NULL;
}
/* If DEVICE corresponds to a mount point, show its usage
static bool
get_device (char const *device)
{
- struct mount_entry const *best_match = nullptr;
+ struct mount_entry const *best_match = NULL;
bool best_match_accessible = false;
bool eclipsed_device = false;
char const *file = device;
if (best_match)
{
- get_dev (best_match->me_devname, best_match->me_mountdir, file, nullptr,
+ get_dev (best_match->me_devname, best_match->me_mountdir, file, NULL,
best_match->me_type, best_match->me_dummy,
- best_match->me_remote, nullptr, false);
+ best_match->me_remote, NULL, false);
return true;
}
else if (eclipsed_device)
get_point (char const *point, const struct stat *statp)
{
struct stat device_stats;
- struct mount_entry const *best_match = nullptr;
+ struct mount_entry const *best_match = NULL;
/* Calculate the real absolute file name for POINT, and use that to find
the mount point. This avoids statting unavailable mount points,
if (best_match
&& (stat (best_match->me_mountdir, &device_stats) != 0
|| device_stats.st_dev != statp->st_dev))
- best_match = nullptr;
+ best_match = NULL;
if (! best_match)
for (struct mount_entry *me = mount_list; me; me = me->me_next)
if (best_match)
get_dev (best_match->me_devname, best_match->me_mountdir, point, point,
best_match->me_type, best_match->me_dummy, best_match->me_remote,
- nullptr, false);
+ NULL, false);
else
{
/* We couldn't find the mount entry corresponding to POINT. Go ahead and
char *mp = find_mount_point (point, statp);
if (mp)
{
- get_dev (nullptr, mp, point, nullptr, nullptr,
- false, false, nullptr, false);
+ get_dev (NULL, mp, point, NULL, NULL,
+ false, false, NULL, false);
free (mp);
}
}
filter_mount_list (show_all_fs);
for (struct mount_entry *me = mount_list; me; me = me->me_next)
- get_dev (me->me_devname, me->me_mountdir, nullptr, nullptr, me->me_type,
- me->me_dummy, me->me_remote, nullptr, true);
+ get_dev (me->me_devname, me->me_mountdir, NULL, NULL, me->me_type,
+ me->me_dummy, me->me_remote, NULL, true);
}
/* Add FSTYPE to the list of file system types to display. */
int
main (int argc, char **argv)
{
- struct stat *stats = nullptr;
+ struct stat *stats = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
atexit (close_stdout);
- fs_select_list = nullptr;
- fs_exclude_list = nullptr;
+ fs_select_list = NULL;
+ fs_exclude_list = NULL;
show_all_fs = false;
show_listed_fs = false;
human_output_opts = -1;
{
error (0, err, "%s", quotef (argv[i]));
exit_status = EXIT_FAILURE;
- argv[i] = nullptr;
+ argv[i] = NULL;
}
}
}
mount_list =
- read_file_system_list ((fs_select_list != nullptr
- || fs_exclude_list != nullptr
+ read_file_system_list ((fs_select_list != NULL
+ || fs_exclude_list != NULL
|| print_type
|| field_data[FSTYPE_FIELD].used
|| show_local_fs));
- if (mount_list == nullptr)
+ if (mount_list == NULL)
{
/* Couldn't read the table of mounted file systems.
Fail if df was invoked with no file name arguments,
if ( ! (optind < argc)
|| (show_all_fs
|| show_local_fs
- || fs_select_list != nullptr
- || fs_exclude_list != nullptr))
+ || fs_select_list != NULL
+ || fs_exclude_list != NULL))
{
status = EXIT_FAILURE;
}
if (print_grand_total)
get_dev ("total",
(field_data[SOURCE_FIELD].used ? "-" : "total"),
- nullptr, nullptr, nullptr, false, false, &grand_fsu, false);
+ NULL, NULL, NULL, false, false, &grand_fsu, false);
print_table ();
}
"CHR", "CHAR", "DOOR", "EXEC", "LEFT", "LEFTCODE", "RIGHT", "RIGHTCODE",
"END", "ENDCODE", "SUID", "SETUID", "SGID", "SETGID", "STICKY",
"OTHER_WRITABLE", "OWR", "STICKY_OTHER_WRITABLE", "OWT", "CAPABILITY",
- "MULTIHARDLINK", "CLRTOEOL", nullptr
+ "MULTIHARDLINK", "CLRTOEOL", NULL
};
static char const *const ls_codes[] =
"no", "no", "fi", "rs", "di", "ln", "ln", "ln", "or", "mi", "pi", "pi",
"so", "bd", "bd", "cd", "cd", "do", "ex", "lc", "lc", "rc", "rc", "ec", "ec",
"su", "su", "sg", "sg", "st", "ow", "ow", "tw", "tw", "ca", "mh", "cl",
- nullptr
+ NULL
};
static_assert (countof (slack_codes) == countof (ls_codes));
static struct option const long_options[] =
{
- {"bourne-shell", no_argument, nullptr, 'b'},
- {"sh", no_argument, nullptr, 'b'},
- {"csh", no_argument, nullptr, 'c'},
- {"c-shell", no_argument, nullptr, 'c'},
- {"print-database", no_argument, nullptr, 'p'},
- {"print-ls-colors", no_argument, nullptr, PRINT_LS_COLORS_OPTION},
+ {"bourne-shell", no_argument, NULL, 'b'},
+ {"sh", no_argument, NULL, 'b'},
+ {"csh", no_argument, NULL, 'c'},
+ {"c-shell", no_argument, NULL, 'c'},
+ {"print-database", no_argument, NULL, 'p'},
+ {"print-ls-colors", no_argument, NULL, PRINT_LS_COLORS_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
char *shell;
shell = getenv ("SHELL");
- if (shell == nullptr || *shell == '\0')
+ if (shell == NULL || *shell == '\0')
return SHELL_SYNTAX_UNKNOWN;
shell = last_component (shell);
char const *keyword_start;
char const *arg_start;
- *keyword = nullptr;
- *arg = nullptr;
+ *keyword = NULL;
+ *arg = NULL;
for (p = line; c_isspace (*p); ++p)
continue;
{
idx_t line_number = 0;
char const *next_G_line = G_line;
- char *input_line = nullptr;
+ char *input_line = NULL;
size_t input_line_size = 0;
char const *line;
char const *term;
/* Get terminal type */
term = getenv ("TERM");
- if (term == nullptr || *term == '\0')
+ if (term == NULL || *term == '\0')
term = "none";
/* Also match $COLORTERM. */
colorterm = getenv ("COLORTERM");
- if (colorterm == nullptr)
+ if (colorterm == NULL)
colorterm = ""; /* Doesn't match default "?*" */
while (true)
parse_line (line, &keywd, &arg);
- if (keywd == nullptr)
+ if (keywd == NULL)
continue;
- if (arg == nullptr)
+ if (arg == NULL)
{
error (0, 0, _("%s:%td: invalid line; missing second token"),
quotef (filename), line_number);
{
int i;
- for (i = 0; slack_codes[i] != nullptr; ++i)
+ for (i = 0; slack_codes[i] != NULL; ++i)
if (c_strcasecmp (keywd, slack_codes[i]) == 0)
break;
- if (slack_codes[i] != nullptr)
+ if (slack_codes[i] != NULL)
append_entry (0, ls_codes[i], arg);
else
unrecognized = true;
{
bool ok;
- if (! streq (filename, "-") && freopen (filename, "r", stdin) == nullptr)
+ if (! streq (filename, "-") && freopen (filename, "r", stdin) == NULL)
{
error (0, errno, "%s", quotef (filename));
return false;
atexit (close_stdout);
- while ((optc = getopt_long (argc, argv, "bcp", long_options, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "bcp", long_options, NULL)) != -1)
switch (optc)
{
case 'b': /* Bourne shell syntax. */
obstack_init (&lsc_obstack);
if (argc == 0)
- ok = dc_parse_stream (nullptr, nullptr);
+ ok = dc_parse_stream (NULL, NULL);
else
ok = dc_parse_file (argv[0]);
static struct option const longopts[] =
{
- {"zero", no_argument, nullptr, 'z'},
+ {"zero", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
while (true)
{
- int c = getopt_long (argc, argv, "z", longopts, nullptr);
+ int c = getopt_long (argc, argv, "z", longopts, NULL);
if (c == -1)
break;
static enum time_type time_type = time_mtime;
/* User specified date / time style */
-static char const *time_style = nullptr;
+static char const *time_style = NULL;
/* Format used to display date / time. Controlled by --time-style */
-static char const *time_format = nullptr;
+static char const *time_format = NULL;
/* The local time zone rules, as per the TZ environment variable. */
static timezone_t localtz;
static struct option const long_options[] =
{
- {"all", no_argument, nullptr, 'a'},
- {"apparent-size", no_argument, nullptr, 'A'},
- {"block-size", required_argument, nullptr, 'B'},
- {"bytes", no_argument, nullptr, 'b'},
- {"count-links", no_argument, nullptr, 'l'},
+ {"all", no_argument, NULL, 'a'},
+ {"apparent-size", no_argument, NULL, 'A'},
+ {"block-size", required_argument, NULL, 'B'},
+ {"bytes", no_argument, NULL, 'b'},
+ {"count-links", no_argument, NULL, 'l'},
#if GNULIB_FTS_DEBUG
- {"-debug", no_argument, nullptr, FTS_DEBUG},
+ {"-debug", no_argument, NULL, FTS_DEBUG},
#endif
- {"dereference", no_argument, nullptr, 'L'},
- {"dereference-args", no_argument, nullptr, 'D'},
- {"exclude", required_argument, nullptr, EXCLUDE_OPTION},
- {"exclude-from", required_argument, nullptr, 'X'},
- {"files0-from", required_argument, nullptr, FILES0_FROM_OPTION},
- {"human-readable", no_argument, nullptr, 'h'},
- {"inodes", no_argument, nullptr, INODES_OPTION},
- {"si", no_argument, nullptr, HUMAN_SI_OPTION},
- {"max-depth", required_argument, nullptr, 'd'},
- {"null", no_argument, nullptr, '0'},
- {"no-dereference", no_argument, nullptr, 'P'},
- {"one-file-system", no_argument, nullptr, 'x'},
- {"separate-dirs", no_argument, nullptr, 'S'},
- {"summarize", no_argument, nullptr, 's'},
- {"total", no_argument, nullptr, 'c'},
- {"threshold", required_argument, nullptr, 't'},
- {"time", optional_argument, nullptr, TIME_OPTION},
- {"time-style", required_argument, nullptr, TIME_STYLE_OPTION},
+ {"dereference", no_argument, NULL, 'L'},
+ {"dereference-args", no_argument, NULL, 'D'},
+ {"exclude", required_argument, NULL, EXCLUDE_OPTION},
+ {"exclude-from", required_argument, NULL, 'X'},
+ {"files0-from", required_argument, NULL, FILES0_FROM_OPTION},
+ {"human-readable", no_argument, NULL, 'h'},
+ {"inodes", no_argument, NULL, INODES_OPTION},
+ {"si", no_argument, NULL, HUMAN_SI_OPTION},
+ {"max-depth", required_argument, NULL, 'd'},
+ {"null", no_argument, NULL, '0'},
+ {"no-dereference", no_argument, NULL, 'P'},
+ {"one-file-system", no_argument, NULL, 'x'},
+ {"separate-dirs", no_argument, NULL, 'S'},
+ {"summarize", no_argument, NULL, 's'},
+ {"total", no_argument, NULL, 'c'},
+ {"threshold", required_argument, NULL, 't'},
+ {"time", optional_argument, NULL, TIME_OPTION},
+ {"time-style", required_argument, NULL, TIME_STYLE_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
static char const *const time_args[] =
{
- "atime", "access", "use", "ctime", "status", nullptr
+ "atime", "access", "use", "ctime", "status", NULL
};
static enum time_type const time_types[] =
{
static char const *const time_style_args[] =
{
- "full-iso", "long-iso", "iso", nullptr
+ "full-iso", "long-iso", "iso", NULL
};
static enum time_style const time_style_types[] =
{
if (*files)
{
- FTS *fts = xfts_open (files, bit_flags, nullptr);
+ FTS *fts = xfts_open (files, bit_flags, NULL);
while (true)
{
FTSENT *ent;
ent = fts_read (fts);
- if (ent == nullptr)
+ if (ent == NULL)
{
if (errno != 0)
{
char *cwd_only[2];
bool max_depth_specified = false;
bool ok = true;
- char *files_from = nullptr;
+ char *files_from = NULL;
/* Bit flags that control how fts works. */
int bit_flags = FTS_NOSTAT;
bool opt_summarize_only = false;
cwd_only[0] = bad_cast (".");
- cwd_only[1] = nullptr;
+ cwd_only[1] = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
case 'd': /* --max-depth=N */
{
intmax_t tmp;
- if (xstrtoimax (optarg, nullptr, 0, &tmp, "") == LONGINT_OK
+ if (xstrtoimax (optarg, NULL, 0, &tmp, "") == LONGINT_OK
&& tmp <= IDX_MAX)
{
max_depth_specified = true;
case 't':
{
enum strtol_error e;
- e = xstrtoimax (optarg, nullptr, 0, &opt_threshold,
+ e = xstrtoimax (optarg, NULL, 0, &opt_threshold,
"kKmMGTPEZYRQ0");
if (e != LONGINT_OK)
xstrtol_fatal (e, oi, c, long_options, optarg);
bit_flags |= FTS_TIGHT_CYCLE_CHECK;
bit_flags |= symlink_deref_bits;
- static char *temp_argv[] = { nullptr, nullptr };
+ static char *temp_argv[] = { NULL, NULL };
while (true)
{
among many, knowing the record number may help.
FIXME: currently print the record number only with
--files0-from=FILE. Maybe do it for argv, too? */
- if (files_from == nullptr)
+ if (files_from == NULL)
error (0, 0, "%s", _("invalid zero-length file name"));
else
{
if (streq (argv[1], "--version"))
{
version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
- (char *) nullptr);
+ (char *) NULL);
return EXIT_SUCCESS;
}
}
static struct option const longopts[] =
{
- {"argv0", required_argument, nullptr, 'a'},
- {"ignore-environment", no_argument, nullptr, 'i'},
- {"null", no_argument, nullptr, '0'},
- {"unset", required_argument, nullptr, 'u'},
- {"chdir", required_argument, nullptr, 'C'},
- {"default-signal", optional_argument, nullptr, DEFAULT_SIGNAL_OPTION},
- {"ignore-signal", optional_argument, nullptr, IGNORE_SIGNAL_OPTION},
- {"block-signal", optional_argument, nullptr, BLOCK_SIGNAL_OPTION},
- {"list-signal-handling", no_argument, nullptr, LIST_SIGNAL_HANDLING_OPTION},
- {"debug", no_argument, nullptr, 'v'},
- {"split-string", required_argument, nullptr, 'S'},
+ {"argv0", required_argument, NULL, 'a'},
+ {"ignore-environment", no_argument, NULL, 'i'},
+ {"null", no_argument, NULL, '0'},
+ {"unset", required_argument, NULL, 'u'},
+ {"chdir", required_argument, NULL, 'C'},
+ {"default-signal", optional_argument, NULL, DEFAULT_SIGNAL_OPTION},
+ {"ignore-signal", optional_argument, NULL, IGNORE_SIGNAL_OPTION},
+ {"block-signal", optional_argument, NULL, BLOCK_SIGNAL_OPTION},
+ {"list-signal-handling", no_argument, NULL, LIST_SIGNAL_HANDLING_OPTION},
+ {"debug", no_argument, NULL, 'v'},
+ {"split-string", required_argument, NULL, 'S'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
}
}
-/* Return a pointer to the end of a valid ${VARNAME} string, or nullptr.
+/* Return a pointer to the end of a valid ${VARNAME} string, or NULL.
'str' should point to the '$' character.
First letter in VARNAME must be alpha or underscore,
rest of letters are alnum or underscore.
return end;
}
- return nullptr;
+ return NULL;
}
/* Return a pointer to a static buffer containing the VARNAME as
extracted from a '${VARNAME}' string.
The returned string will be NUL terminated.
The returned pointer should not be freed.
- Return nullptr if not a valid ${VARNAME} syntax. */
+ Return NULL if not a valid ${VARNAME} syntax. */
static char *
extract_varname (char const *str)
{
char const *p = scan_varname (str);
if (!p)
- return nullptr;
+ return NULL;
/* -2 and +2 (below) account for the '${' prefix. */
idx_t i = p - str - 2;
if (i >= vnlen)
{
free (varname);
- varname = xpalloc (nullptr, &vnlen, i + 1 - vnlen, -1, sizeof *varname);
+ varname = xpalloc (NULL, &vnlen, i + 1 - vnlen, -1, sizeof *varname);
}
memcpy (varname, str + 2, i);
argv[1] = "-S-i -C/tmp A=B"
argv[2] = "foo"
argv[3] = "bar"
- argv[4] = nullptr
+ argv[4] = NULL
This function will modify argv to be:
argv[0] = "env"
argv[1] = "-i"
argv[3] = "A=B"
argv[4] = "foo"
argv[5] = "bar"
- argv[6] = nullptr
+ argv[6] = NULL
argc will be updated from 4 to 6.
optind will be reset to 0 to force getopt_long to rescan all arguments. */
static void
signals[signum] = set_default ? DEFAULT : IGNORE;
- opt_sig = strtok (nullptr, ",");
+ opt_sig = strtok (NULL, ",");
}
free (optarg_writable);
bool set_to_default = (signals[i] == DEFAULT
|| signals[i] == DEFAULT_NOERR);
- int sig_err = sigaction (i, nullptr, &act);
+ int sig_err = sigaction (i, NULL, &act);
if (sig_err && !ignore_errors)
error (EXIT_CANCELED, errno,
if (! sig_err)
{
act.sa_handler = set_to_default ? SIG_DFL : SIG_IGN;
- sig_err = sigaction (i, &act, nullptr);
+ sig_err = sigaction (i, &act, NULL);
if (sig_err && !ignore_errors)
error (EXIT_CANCELED, errno,
_("failed to set signal action for signal %d"), i);
else
sigdelset (block ? &unblock_signals : &block_signals, signum);
- opt_sig = strtok (nullptr, ",");
+ opt_sig = strtok (NULL, ",");
}
free (optarg_writable);
sigemptyset (&set);
- if (sigprocmask (0, nullptr, &set))
+ if (sigprocmask (0, NULL, &set))
error (EXIT_CANCELED, errno, _("failed to get signal process mask"));
for (int i = 1; i <= SIGNUM_BOUND; i++)
{
- char const *debug_act = nullptr;
+ char const *debug_act = NULL;
if (sigismember (&block_signals, i))
{
}
}
- if (sigprocmask (SIG_SETMASK, &set, nullptr))
+ if (sigprocmask (SIG_SETMASK, &set, NULL))
error (EXIT_CANCELED, errno, _("failed to set signal process mask"));
}
sigset_t set;
sigemptyset (&set);
- if (sigprocmask (0, nullptr, &set))
+ if (sigprocmask (0, NULL, &set))
error (EXIT_CANCELED, errno, _("failed to get signal process mask"));
for (int i = 1; i <= SIGNUM_BOUND; i++)
{
struct sigaction act;
- if (sigaction (i, nullptr, &act))
+ if (sigaction (i, NULL, &act))
continue;
char const *ignored = act.sa_handler == SIG_IGN ? "IGNORE" : "";
{
bool ignore_environment = false;
bool opt_nul_terminate_output = false;
- char const *newdir = nullptr;
- char *argv0 = nullptr;
+ char const *newdir = NULL;
+ char *argv0 = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
initialize_signals ();
int optc;
- while ((optc = getopt_long (argc, argv, shortopts, longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1)
{
switch (optc)
{
if (ignore_environment)
{
devmsg ("cleaning environ\n");
- static char *dummy_environ[] = { nullptr };
+ static char *dummy_environ[] = { NULL };
environ = dummy_environ;
}
else
/* Array of the explicit column numbers of the tab stops;
after 'tab_list' is exhausted, each additional tab is replaced
by a space. The first column is column 0. */
-static colno *tab_list = nullptr;
+static colno *tab_list = NULL;
/* The number of allocated entries in 'tab_list'. */
static idx_t n_tabs_allocated = 0;
static idx_t first_free_tab = 0;
/* Null-terminated array of input filenames. */
-static char **file_list = nullptr;
+static char **file_list = NULL;
/* Default for 'file_list' if no files are given on the command line. */
static char *stdin_argv[] =
{
- (char *) "-", nullptr
+ (char *) "-", NULL
};
/* True if we have ever read standard input. */
colno tabval = 0;
bool extend_tabval = false;
bool increment_tabval = false;
- char const *num_start = nullptr;
+ char const *num_start = NULL;
bool ok = true;
for (; *stops; stops++)
/* Close the old stream pointer FP if it is non-null,
and return a new one opened to read the next input file.
Open a filename of '-' as the standard input.
- Return nullptr if there are no more input files. */
+ Return NULL if there are no more input files. */
extern FILE *
next_file (FILE *fp)
}
}
- while ((file = *file_list++) != nullptr)
+ while ((file = *file_list++) != NULL)
{
if (streq (file, "-"))
{
error (0, errno, "%s", quotef (file));
exit_status = EXIT_FAILURE;
}
- return nullptr;
+ return NULL;
}
/* Close standard input if we have read from it. */
/* Close the old stream pointer FP if it is non-null,
and return a new one opened to read the next input file.
Open a filename of '-' as the standard input.
- Return nullptr if there are no more input files. */
+ Return NULL if there are no more input files. */
extern FILE *
next_file (FILE *fp);
static struct option const longopts[] =
{
- {"tabs", required_argument, nullptr, 't'},
- {"initial", no_argument, nullptr, 'i'},
+ {"tabs", required_argument, NULL, 't'},
+ {"initial", no_argument, NULL, 'i'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
expand (void)
{
/* Input stream. */
- FILE *fp = next_file (nullptr);
+ FILE *fp = next_file (NULL);
if (!fp)
return;
atexit (close_stdout);
convert_entire_line = true;
- while ((c = getopt_long (argc, argv, shortopts, longopts, nullptr)) != -1)
+ while ((c = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1)
{
switch (c)
{
finalize_tab_stops ();
- set_file_list (optind < argc ? &argv[optind] : nullptr);
+ set_file_list (optind < argc ? &argv[optind] : NULL);
expand ();
atexit (close_stdout);
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
- usage, AUTHORS, (char const *) nullptr);
+ usage, AUTHORS, (char const *) NULL);
/* The above handles --help and --version.
Since there is no other invocation of getopt, handle '--' here. */
{
case integer:
{
- char *s = mpz_get_str (nullptr, 10, v->u.i);
+ char *s = mpz_get_str (NULL, 10, v->u.i);
mpz_clear (v->u.i);
v->u.s = s;
v->type = string;
static bool
nextarg (char const *str)
{
- if (*args == nullptr)
+ if (*args == NULL)
return false;
else
{
tostring (pv);
re_regs.num_regs = 0;
- re_regs.start = nullptr;
- re_regs.end = nullptr;
+ re_regs.start = NULL;
+ re_regs.end = NULL;
- re_buffer.buffer = nullptr;
+ re_buffer.buffer = NULL;
re_buffer.allocated = 0;
re_buffer.fastmap = fastmap;
- re_buffer.translate = nullptr;
+ re_buffer.translate = NULL;
re_syntax_options =
RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES;
errmsg = re_compile_pattern (pv->u.s, strlen (pv->u.s), &re_buffer);
free (re_regs.start);
free (re_regs.end);
}
- re_buffer.fastmap = nullptr;
+ re_buffer.fastmap = NULL;
regfree (&re_buffer);
return v;
}
static struct option const long_options[] =
{
- {"exponents", no_argument, nullptr, 'h'},
- {"-debug", no_argument, nullptr, DEV_DEBUG_OPTION},
+ {"exponents", no_argument, NULL, 'h'},
+ {"-debug", no_argument, NULL, DEV_DEBUG_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* If true, use p^e output format. */
mp_limb_t const *dp, mp_size_t dn)
{
mpz_t q, r, n, d;
- mpz_inits (q, r, nullptr);
+ mpz_inits (q, r, NULL);
mpz_tdiv_qr (q, r, mpz_roinit_n (n, np, nn), mpz_roinit_n (d, dp, dn));
copy_mpn_from_mpz (qp, nn - dn + 1, q);
copy_mpn_from_mpz (rp, dn, r);
- mpz_clears (q, r, nullptr);
+ mpz_clears (q, r, NULL);
}
#endif
atexit (close_stdout);
int c;
- while ((c = getopt_long (argc, argv, "h", long_options, nullptr)) != -1)
+ while ((c = getopt_long (argc, argv, "h", long_options, NULL)) != -1)
{
switch (c)
{
/* Return the root mountpoint of the file system on which FILE exists, in
malloced storage. FILE_STAT should be the result of stating FILE.
- Give a diagnostic and return nullptr if unable to determine the mount point.
+ Give a diagnostic and return NULL if unable to determine the mount point.
Exit if unable to restore current working directory. */
extern char *
find_mount_point (char const *file, struct stat const *file_stat)
{
struct saved_cwd cwd;
struct stat last_stat;
- char *mp = nullptr; /* The malloc'd mount point. */
+ char *mp = NULL; /* The malloc'd mount point. */
if (save_cwd (&cwd) != 0)
{
error (0, errno, _("cannot get current directory"));
- return nullptr;
+ return NULL;
}
if (S_ISDIR (file_stat->st_mode))
if (chdir (file) < 0)
{
error (0, errno, _("cannot change to directory %s"), quoteaf (file));
- return nullptr;
+ return NULL;
}
}
else
if (chdir (dir) < 0)
{
error (0, errno, _("cannot change to directory %s"), quoteaf (dir));
- return nullptr;
+ return NULL;
}
if (stat (".", &last_stat) < 0)
/* Extra ctype(3)-style macros. */
-#define isopen(c) (strchr ("(['`\"", c) != nullptr)
-#define isclose(c) (strchr (")]'\"", c) != nullptr)
-#define isperiod(c) (strchr (".?!", c) != nullptr)
+#define isopen(c) (strchr ("(['`\"", c) != NULL)
+#define isclose(c) (strchr (")]'\"", c) != NULL)
+#define isperiod(c) (strchr (".?!", c) != NULL)
/* Size of a tab stop, for expansion on input and re-introduction on
output. */
static struct option const long_options[] =
{
- {"crown-margin", no_argument, nullptr, 'c'},
- {"prefix", required_argument, nullptr, 'p'},
- {"split-only", no_argument, nullptr, 's'},
- {"tagged-paragraph", no_argument, nullptr, 't'},
- {"uniform-spacing", no_argument, nullptr, 'u'},
- {"width", required_argument, nullptr, 'w'},
- {"goal", required_argument, nullptr, 'g'},
+ {"crown-margin", no_argument, NULL, 'c'},
+ {"prefix", required_argument, NULL, 'p'},
+ {"split-only", no_argument, NULL, 's'},
+ {"tagged-paragraph", no_argument, NULL, 't'},
+ {"uniform-spacing", no_argument, NULL, 'u'},
+ {"width", required_argument, NULL, 'w'},
+ {"goal", required_argument, NULL, 'g'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0},
+ {NULL, 0, NULL, 0},
};
int
{
int optchar;
bool ok = true;
- char const *max_width_option = nullptr;
- char const *goal_width_option = nullptr;
+ char const *max_width_option = NULL;
+ char const *goal_width_option = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
}
while ((optchar = getopt_long (argc, argv, "0123456789cstuw:p:g:",
- long_options, nullptr))
+ long_options, NULL))
!= -1)
switch (optchar)
{
/* Limit goal_width to max_width. */
goal_width = xdectoumax (goal_width_option, 0, max_width, "",
_("invalid width"), 0);
- if (max_width_option == nullptr)
+ if (max_width_option == NULL)
max_width = goal_width + 10;
}
else
{
FILE *in_stream;
in_stream = fopen (file, "r");
- if (in_stream != nullptr)
+ if (in_stream != NULL)
ok &= fmt (in_stream, file);
else
{
static struct option const longopts[] =
{
- {"bytes", no_argument, nullptr, 'b'},
- {"characters", no_argument, nullptr, 'c'},
- {"spaces", no_argument, nullptr, 's'},
- {"width", required_argument, nullptr, 'w'},
+ {"bytes", no_argument, NULL, 'b'},
+ {"characters", no_argument, NULL, 'c'},
+ {"spaces", no_argument, NULL, 's'},
+ {"width", required_argument, NULL, 'w'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
else
istream = fopen (filename, "r");
- if (istream == nullptr)
+ if (istream == NULL)
{
error (0, errno, "%s", quotef (filename));
return false;
break_spaces = have_read_stdin = false;
- while ((optc = getopt_long (argc, argv, shortopts, longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1)
{
char optargbuf[2];
enum { smallsize = 256 };
/* Return a template for a file in the same directory as DSTNAME.
- Use BUF if the template fits, otherwise use malloc and return nullptr
+ Use BUF if the template fits, otherwise use malloc and return NULL
(setting errno) if unsuccessful. */
static char *
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
VERSION, true, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
#define print_int(TYPE) \
sprintf (limit + 1, "%ju", (uintmax_t) TYPE##_MAX); \
bool use_names, char delim)
{
bool ok = true;
- struct passwd *pwd = nullptr;
+ struct passwd *pwd = NULL;
if (username)
{
pwd = getpwuid (ruid);
- if (pwd == nullptr)
+ if (pwd == NULL)
ok = false;
}
extern bool
print_group (gid_t gid, bool use_name)
{
- struct group *grp = nullptr;
+ struct group *grp = NULL;
bool ok = true;
if (use_name)
{
grp = getgrgid (gid);
- if (grp == nullptr)
+ if (grp == NULL)
{
if (TYPE_SIGNED (gid_t))
{
{
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
/* Processing the arguments this way makes groups.c behave differently to
groups.sh if one of the arguments is "--". */
int optc;
- while ((optc = getopt_long (argc, argv, "", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "", longopts, NULL)) != -1)
{
switch (optc)
{
if (rgid == NO_GID && errno)
error (EXIT_FAILURE, errno, _("cannot get real GID"));
- if (!print_group_list (nullptr, ruid, rgid, egid, true, ' '))
+ if (!print_group_list (NULL, ruid, rgid, egid, true, ' '))
ok = false;
putchar ('\n');
}
for ( ; optind < argc; optind++)
{
struct passwd *pwd = getpwnam (argv[optind]);
- if (pwd == nullptr)
+ if (pwd == NULL)
{
error (0, 0, _("%s: no such user"), quote (argv[optind]));
ok = false;
static struct option const long_options[] =
{
- {"bytes", required_argument, nullptr, 'c'},
- {"lines", required_argument, nullptr, 'n'},
- {"-presume-input-pipe", no_argument, nullptr,
+ {"bytes", required_argument, NULL, 'c'},
+ {"lines", required_argument, NULL, 'n'},
+ {"-presume-input-pipe", no_argument, NULL,
PRESUME_INPUT_PIPE_OPTION}, /* do not document */
- {"quiet", no_argument, nullptr, 'q'},
- {"silent", no_argument, nullptr, 'q'},
- {"verbose", no_argument, nullptr, 'v'},
- {"zero-terminated", no_argument, nullptr, 'z'},
+ {"quiet", no_argument, NULL, 'q'},
+ {"silent", no_argument, NULL, 'q'},
+ {"verbose", no_argument, NULL, 'v'},
+ {"zero-terminated", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
bool eof = false;
idx_t n_read;
- char **b = nullptr;
+ char **b = NULL;
idx_t remainder = n_elide % READ_BUFSIZE;
/* The number of buffers needed to hold n_elide bytes plus one
first = last = xmalloc (sizeof (LBUFFER));
first->nbytes = first->nlines = 0;
- first->next = nullptr;
+ first->next = NULL;
tmp = xmalloc (sizeof (LBUFFER));
/* Always read into a fresh buffer.
tmp->nbytes = n_read;
tmp->nlines = 0;
- tmp->next = nullptr;
+ tmp->next = NULL;
/* Count the number of newlines just read. */
{
{
char const *nl;
nl = memrchr (buffer, line_end, n);
- if (nl == nullptr)
+ if (nl == NULL)
break;
n = nl - buffer;
}
/* Initializer for file_list if no file-arguments
were specified on the command line. */
- static char const *const default_file_list[] = {"-", nullptr};
+ static char const *const default_file_list[] = {"-", NULL};
char const *const *file_list;
initialize_main (&argc, &argv);
}
while ((c = getopt_long (argc, argv, "c:n:qvz0123456789",
- long_options, nullptr))
+ long_options, NULL))
!= -1)
{
switch (c)
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
Version, true, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
if (optind < argc)
{
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
Version, true, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
if (optind + 1 < argc)
{
else
{
hostname = xgethostname ();
- if (hostname == nullptr)
+ if (hostname == NULL)
error (EXIT_FAILURE, errno, _("cannot determine hostname"));
puts (hostname);
}
/* The SELinux context. Start with a known invalid value so print_full_info
knows when 'context' has not been set to a meaningful value. */
-static char *context = nullptr;
+static char *context = NULL;
static void print_user (uid_t uid);
static void print_full_info (char const *username);
static struct option const longopts[] =
{
- {"context", no_argument, nullptr, 'Z'},
- {"group", no_argument, nullptr, 'g'},
- {"groups", no_argument, nullptr, 'G'},
- {"name", no_argument, nullptr, 'n'},
- {"real", no_argument, nullptr, 'r'},
- {"user", no_argument, nullptr, 'u'},
- {"zero", no_argument, nullptr, 'z'},
+ {"context", no_argument, NULL, 'Z'},
+ {"group", no_argument, NULL, 'g'},
+ {"groups", no_argument, NULL, 'G'},
+ {"name", no_argument, NULL, 'n'},
+ {"real", no_argument, NULL, 'r'},
+ {"user", no_argument, NULL, 'u'},
+ {"zero", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
atexit (close_stdout);
- while ((optc = getopt_long (argc, argv, "agnruzGZ", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "agnruzGZ", longopts, NULL)) != -1)
{
switch (optc)
{
/* For each username/userid to get its pw_name field */
for (; optind < n_ids; optind++)
{
- char *pw_name = nullptr;
- struct passwd *pwd = nullptr;
+ char *pw_name = NULL;
+ struct passwd *pwd = NULL;
char const *spec = argv[optind];
/* Disallow an empty spec here as parse_user_spec() doesn't
give an error for that as it seems it's a valid way to
specify a noop or "reset special bits" depending on the system. */
if (*spec)
{
- if (! parse_user_spec (spec, &euid, nullptr, &pw_name, nullptr))
+ if (! parse_user_spec (spec, &euid, NULL, &pw_name, NULL))
pwd = pw_name ? getpwnam (pw_name) : getpwuid (euid);
}
- if (pwd == nullptr)
+ if (pwd == NULL)
{
error (0, errno, _("%s: no such user"), quote (spec));
ok &= false;
if (rgid == NO_GID && errno)
error (EXIT_FAILURE, errno, _("cannot get real GID"));
}
- print_stuff (nullptr);
+ print_stuff (NULL);
}
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
static void
print_user (uid_t uid)
{
- struct passwd *pwd = nullptr;
+ struct passwd *pwd = NULL;
if (use_name)
{
pwd = getpwuid (uid);
- if (pwd == nullptr)
+ if (pwd == NULL)
{
error (0, 0, _("cannot find name for user ID %ju"), (uintmax_t) uid);
ok &= false;
# define endpwent() ((void) 0)
#endif
-/* The user name that will own the files, or nullptr to make the owner
+/* The user name that will own the files, or NULL to make the owner
the current user ID. */
static char *owner_name;
/* The user ID corresponding to 'owner_name'. */
static uid_t owner_id;
-/* The group name that will own the files, or nullptr to make the group
+/* The group name that will own the files, or NULL to make the group
the current group ID. */
static char *group_name;
static struct option const long_options[] =
{
- {"backup", optional_argument, nullptr, 'b'},
- {"compare", no_argument, nullptr, 'C'},
+ {"backup", optional_argument, NULL, 'b'},
+ {"compare", no_argument, NULL, 'C'},
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
- {"debug", no_argument, nullptr, DEBUG_OPTION},
- {"directory", no_argument, nullptr, 'd'},
- {"group", required_argument, nullptr, 'g'},
- {"mode", required_argument, nullptr, 'm'},
- {"no-target-directory", no_argument, nullptr, 'T'},
- {"owner", required_argument, nullptr, 'o'},
- {"preserve-timestamps", no_argument, nullptr, 'p'},
- {"preserve-context", no_argument, nullptr, PRESERVE_CONTEXT_OPTION},
- {"strip", no_argument, nullptr, 's'},
- {"strip-program", required_argument, nullptr, STRIP_PROGRAM_OPTION},
- {"suffix", required_argument, nullptr, 'S'},
- {"target-directory", required_argument, nullptr, 't'},
- {"verbose", no_argument, nullptr, 'v'},
+ {"debug", no_argument, NULL, DEBUG_OPTION},
+ {"directory", no_argument, NULL, 'd'},
+ {"group", required_argument, NULL, 'g'},
+ {"mode", required_argument, NULL, 'm'},
+ {"no-target-directory", no_argument, NULL, 'T'},
+ {"owner", required_argument, NULL, 'o'},
+ {"preserve-timestamps", no_argument, NULL, 'p'},
+ {"preserve-context", no_argument, NULL, PRESERVE_CONTEXT_OPTION},
+ {"strip", no_argument, NULL, 's'},
+ {"strip-program", required_argument, NULL, STRIP_PROGRAM_OPTION},
+ {"suffix", required_argument, NULL, 'S'},
+ {"target-directory", required_argument, NULL, 't'},
+ {"verbose", no_argument, NULL, 'v'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Compare content of opened files using file descriptors A_FD and B_FD. Return
/* compare SELinux context if preserving */
if (selinux_enabled && x->preserve_security_context)
{
- char *file_scontext_raw = nullptr;
+ char *file_scontext_raw = NULL;
if (getfilecon_raw (src_name, &file_scontext_raw) == -1)
return true;
- char *to_scontext_raw = nullptr;
+ char *to_scontext_raw = NULL;
if (getfilecon_raw (dest_name, &to_scontext_raw) == -1)
{
freecon (file_scontext_raw);
x->update = UPDATE_ALL;
x->require_preserve_context = false; /* Not used by install currently. */
x->preserve_security_context = false; /* Whether to copy context from src. */
- x->set_security_context = nullptr; /* Whether to set sys default context. */
+ x->set_security_context = NULL; /* Whether to set sys default context. */
x->preserve_xattr = false;
x->verbose = false;
- x->dest_info = nullptr;
- x->src_info = nullptr;
+ x->dest_info = NULL;
+ x->src_info = NULL;
}
static struct selabel_handle *
if (!initialized)
{
initialized = true;
- hnd = selabel_open (SELABEL_CTX_FILE, nullptr, 0);
+ hnd = selabel_open (SELABEL_CTX_FILE, NULL, 0);
if (!hnd)
error (0, errno, _("warning: security labeling handle failed"));
}
if (!hnd)
return;
- char *scontext_raw = nullptr;
+ char *scontext_raw = NULL;
if (selabel_lookup_raw (hnd, &scontext_raw, file, st.st_mode) != 0)
{
if (errno != ENOENT && ! ignorable_ctx_err (errno))
However, since !x->recursive, the call to "copy" will fail if FROM
is a directory. */
- return copy (from, to, to_dirfd, to_relname, 0, x, ©_into_self, nullptr);
+ return copy (from, to, to_dirfd, to_relname, 0, x, ©_into_self, NULL);
}
/* Set the attributes of file or directory NAME aka DIRFD+RELNAME.
strip (char const *name)
{
posix_spawnattr_t attr;
- posix_spawnattr_t *attrp = nullptr;
+ posix_spawnattr_t *attrp = NULL;
/* Try to use vfork for systems where it matters. */
if (posix_spawnattr_init (&attr) == 0)
}
/* Construct the arguments to 'strip'. */
- char *concat_name = nullptr;
+ char *concat_name = NULL;
char const *safe_name = name;
if (name && *name == '-')
- safe_name = concat_name = file_name_concat (".", name, nullptr);
- char const *const argv[] = { strip_program, safe_name, nullptr };
+ safe_name = concat_name = file_name_concat (".", name, NULL);
+ char const *const argv[] = { strip_program, safe_name, NULL };
/* Run 'strip'. */
pid_t pid;
- int result = posix_spawnp (&pid, strip_program, nullptr, attrp,
+ int result = posix_spawnp (&pid, strip_program, NULL, attrp,
(char * const *) argv, environ);
bool ok = false;
if (owner_name)
{
struct passwd *pw = getpwnam (owner_name);
- if (pw == nullptr)
+ if (pw == NULL)
{
uintmax_t tmp;
- if (xstrtoumax (owner_name, nullptr, 0, &tmp, "") != LONGINT_OK
+ if (xstrtoumax (owner_name, NULL, 0, &tmp, "") != LONGINT_OK
|| ckd_add (&owner_id, tmp, 0))
error (EXIT_FAILURE, 0, _("invalid user %s"),
quoteaf (owner_name));
if (group_name)
{
struct group *gr = getgrnam (group_name);
- if (gr == nullptr)
+ if (gr == NULL)
{
uintmax_t tmp;
- if (xstrtoumax (group_name, nullptr, 0, &tmp, "") != LONGINT_OK
+ if (xstrtoumax (group_name, NULL, 0, &tmp, "") != LONGINT_OK
|| ckd_add (&group_id, tmp, 0))
error (EXIT_FAILURE, 0, _("invalid group %s"),
quoteaf (group_name));
int
main (int argc, char **argv)
{
- char const *specified_mode = nullptr;
+ char const *specified_mode = NULL;
bool make_backups = false;
- char const *backup_suffix = nullptr;
- char *version_control_string = nullptr;
+ char const *backup_suffix = NULL;
+ char *version_control_string = NULL;
bool mkdir_and_install = false;
struct cp_options x;
- char const *target_directory = nullptr;
+ char const *target_directory = NULL;
bool no_target_directory = false;
bool strip_program_specified = false;
- char const *scontext = nullptr;
+ char const *scontext = NULL;
/* set iff kernel has extra selinux system calls */
selinux_enabled = (0 < is_selinux_enabled ());
cp_option_init (&x);
- owner_name = nullptr;
- group_name = nullptr;
+ owner_name = NULL;
+ group_name = NULL;
strip_files = false;
dir_arg = false;
umask (0);
int optc;
while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pt:TvS:Z", long_options,
- nullptr))
+ NULL))
!= -1)
{
switch (optc)
struct mode_change *change = mode_compile (specified_mode);
if (!change)
error (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode));
- mode = mode_adjust (0, false, 0, change, nullptr);
+ mode = mode_adjust (0, false, 0, change, NULL);
dir_mode = mode_adjust (0, true, 0, change, &dir_mode_bits);
free (change);
}
struct timeval delay = {0};
ret = select (nfds,
- broken_output ? &fds : nullptr,
- broken_output ? nullptr : &fds,
- nullptr, block ? nullptr : &delay);
+ broken_output ? &fds : NULL,
+ broken_output ? NULL : &fds,
+ NULL, block ? NULL : &delay);
if (ret < 0)
continue;
};
/* The previous line read from each file. */
-static struct line *prevline[2] = {nullptr, nullptr};
+static struct line *prevline[2] = {NULL, NULL};
/* The number of lines read from each file. */
static uintmax_t line_no[2] = {0, 0};
/* This provides an extra line buffer for each file. We need these if we
try to read two consecutive lines into the same buffer, since we don't
want to overwrite the previous buffer before we check order. */
-static struct line *spareline[2] = {nullptr, nullptr};
+static struct line *spareline[2] = {NULL, NULL};
/* True if the LC_COLLATE locale is hard. */
static bool hard_LC_COLLATE;
static struct option const longopts[] =
{
- {"ignore-case", no_argument, nullptr, 'i'},
- {"check-order", no_argument, nullptr, CHECK_ORDER_OPTION},
- {"nocheck-order", no_argument, nullptr, NOCHECK_ORDER_OPTION},
- {"zero-terminated", no_argument, nullptr, 'z'},
- {"header", no_argument, nullptr, HEADER_LINE_OPTION},
+ {"ignore-case", no_argument, NULL, 'i'},
+ {"check-order", no_argument, NULL, CHECK_ORDER_OPTION},
+ {"nocheck-order", no_argument, NULL, NOCHECK_ORDER_OPTION},
+ {"zero-terminated", no_argument, NULL, 'z'},
+ {"header", no_argument, NULL, HEADER_LINE_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Used to print non-joining lines */
static void
freeline (struct line *line)
{
- if (line == nullptr)
+ if (line == NULL)
return;
free (line->fields);
- line->fields = nullptr;
+ line->fields = NULL;
free (line->buf.buffer);
- line->buf.buffer = nullptr;
+ line->buf.buffer = NULL;
}
/* Return <0 if the join field in LINE1 compares less than the one in LINE2;
}
else
{
- beg1 = nullptr;
+ beg1 = NULL;
len1 = 0;
}
}
else
{
- beg2 = nullptr;
+ beg2 = NULL;
len2 = 0;
}
{
seq->count = 0;
seq->alloc = 0;
- seq->lines = nullptr;
+ seq->lines = NULL;
}
/* Read a line from FP and add it to SEQ. Return true if successful. */
{
seq->lines = xpalloc (seq->lines, &seq->alloc, 1, -1, sizeof *seq->lines);
for (idx_t i = seq->count; i < seq->alloc; i++)
- seq->lines[i] = nullptr;
+ seq->lines[i] = NULL;
}
if (get_line (fp, &seq->lines[seq->count], whichfile))
}
prfield (field, line);
o = o->next;
- if (o == nullptr)
+ if (o == NULL)
break;
fwrite (output_separator, 1, output_seplen, stdout);
}
struct line const *hline1 = seq1.count ? seq1.lines[0] : &uni_blank;
struct line const *hline2 = seq2.count ? seq2.lines[0] : &uni_blank;
prjoin (hline1, hline2);
- prevline[0] = nullptr;
- prevline[1] = nullptr;
+ prevline[0] = NULL;
+ prevline[1] = NULL;
if (seq1.count)
advance_seq (fp1, &seq1, true, 1);
if (seq2.count)
tail ends of both inputs to verify that they are in order. We
skip the rest of the tail once we have issued a warning for that
file, unless we actually need to print the unpairable lines. */
- struct line *line = nullptr;
+ struct line *line = NULL;
bool checktail = false;
if (check_input_order != CHECK_ORDER_DISABLED
o = xmalloc (sizeof *o);
o->file = file;
o->field = field;
- o->next = nullptr;
+ o->next = NULL;
/* Add to the end of the list so the fields are in the right order. */
outlist_end->next = o;
{
intmax_t val;
- strtol_error s_err = xstrtoimax (str, nullptr, 10, &val, "");
+ strtol_error s_err = xstrtoimax (str, NULL, 10, &val, "");
if (s_err == LONGINT_OVERFLOW || (s_err == LONGINT_OK && PTRDIFF_MAX < val))
val = PTRDIFF_MAX;
else if (s_err != LONGINT_OK || val <= 0)
check_input_order = CHECK_ORDER_DEFAULT;
while ((optc = getopt_long (argc, argv, "-a:e:i1:2:j:o:t:v:z",
- longopts, nullptr))
+ longopts, NULL))
!= -1)
{
optc_status = MUST_BE_OPERAND;
case 'a':
{
long int val;
- if (xstrtol (optarg, nullptr, 10, &val, "") != LONGINT_OK
+ if (xstrtol (optarg, NULL, 10, &val, "") != LONGINT_OK
|| (val != 1 && val != 2))
error (EXIT_FAILURE, 0,
_("invalid file number: %s"), quote (optarg));
static struct option const long_options[] =
{
- {"list", no_argument, nullptr, 'l'},
- {"signal", required_argument, nullptr, 's'},
- {"table", no_argument, nullptr, 't'},
+ {"list", no_argument, NULL, 'l'},
+ {"signal", required_argument, NULL, 's'},
+ {"table", no_argument, NULL, 't'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
atexit (close_stdout);
- while ((optc = getopt_long (argc, argv, short_options, long_options, nullptr))
+ while ((optc = getopt_long (argc, argv, short_options, long_options, NULL))
!= -1)
switch (optc)
{
}
return (list
- ? list_signals (table, optind < argc ? argv + optind : nullptr)
+ ? list_signals (table, optind < argc ? argv + optind : NULL)
: send_signals (signum, argv + optind));
}
the buffer size, and more problematically does not give any indication
that the new size request was ignored:
- setvbuf (stdout, nullptr, _IOFBF, 8192);
+ setvbuf (stdout, NULL, _IOFBF, 8192);
The ISO C99 standard section 7.19.5.6 on the setvbuf function says:
static void
apply_mode (FILE *stream, char const *stream_name, char const *envvar)
{
- char *buf = nullptr;
+ char *buf = NULL;
int setvbuf_mode;
unsigned long int size = 0;
Huge sizes can cause problems with some stdio implementations. */
buf = (size <= ((unsigned long int) -2 < (size_t) -1 / 2
? (unsigned long int) -2 : (size_t) -1 / 2)
- ? malloc (size) : nullptr);
+ ? malloc (size) : NULL);
if (!buf)
{
/* We could defer the allocation to libc, however since
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
Version, true, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
if (argc < optind + 2)
{
static struct option const long_options[] =
{
- {"backup", optional_argument, nullptr, 'b'},
- {"directory", no_argument, nullptr, 'F'},
- {"no-dereference", no_argument, nullptr, 'n'},
- {"no-target-directory", no_argument, nullptr, 'T'},
- {"force", no_argument, nullptr, 'f'},
- {"interactive", no_argument, nullptr, 'i'},
- {"suffix", required_argument, nullptr, 'S'},
- {"target-directory", required_argument, nullptr, 't'},
- {"logical", no_argument, nullptr, 'L'},
- {"physical", no_argument, nullptr, 'P'},
- {"relative", no_argument, nullptr, 'r'},
- {"symbolic", no_argument, nullptr, 's'},
- {"verbose", no_argument, nullptr, 'v'},
+ {"backup", optional_argument, NULL, 'b'},
+ {"directory", no_argument, NULL, 'F'},
+ {"no-dereference", no_argument, NULL, 'n'},
+ {"no-target-directory", no_argument, NULL, 'T'},
+ {"force", no_argument, NULL, 'f'},
+ {"interactive", no_argument, NULL, 'i'},
+ {"suffix", required_argument, NULL, 'S'},
+ {"target-directory", required_argument, NULL, 't'},
+ {"logical", no_argument, NULL, 'L'},
+ {"physical", no_argument, NULL, 'P'},
+ {"relative", no_argument, NULL, 'r'},
+ {"symbolic", no_argument, NULL, 's'},
+ {"verbose", no_argument, NULL, 'v'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Return an errno value for a system call that returned STATUS.
char *realdest = canonicalize_filename_mode (targetdir, CAN_MISSING);
char *realfrom = canonicalize_filename_mode (from, CAN_MISSING);
- char *relative_from = nullptr;
+ char *relative_from = NULL;
if (realdest && realfrom)
{
/* Write to a PATH_MAX buffer. */
if (!relpath (realfrom, realdest, relative_from, PATH_MAX))
{
free (relative_from);
- relative_from = nullptr;
+ relative_from = NULL;
}
}
{
struct stat source_stats;
int source_status = 1;
- char *backup_base = nullptr;
- char *rel_source = nullptr;
+ char *backup_base = NULL;
+ char *rel_source = NULL;
int nofollow_flag = logical ? 0 : AT_SYMLINK_NOFOLLOW;
if (link_errno < 0)
link_errno = atomic_link (source, destdir_fd, dest_base);
{
int rename_errno = errno;
free (backup_base);
- backup_base = nullptr;
+ backup_base = NULL;
if (rename_errno != ENOENT)
{
error (0, rename_errno, _("cannot backup %s"),
if (backup_base)
{
char *backup = backup_base;
- void *alloc = nullptr;
+ void *alloc = NULL;
ptrdiff_t destdirlen = dest_base - dest;
if (0 < destdirlen)
{
int c;
bool ok;
bool make_backups = false;
- char const *backup_suffix = nullptr;
- char *version_control_string = nullptr;
- char const *target_directory = nullptr;
+ char const *backup_suffix = NULL;
+ char *version_control_string = NULL;
+ char const *target_directory = NULL;
int destdir_fd;
bool no_target_directory = false;
int n_files;
= hard_dir_link = false;
while ((c = getopt_long (argc, argv, "bdfinrst:vFLPS:T",
- long_options, nullptr))
+ long_options, NULL))
!= -1)
{
switch (c)
&& backup_type != numbered_backups)
{
dest_set = hash_initialize (DEST_INFO_INITIAL_CAPACITY,
- nullptr,
+ NULL,
triple_hash,
triple_compare,
triple_free);
- if (dest_set == nullptr)
+ if (dest_set == NULL)
xalloc_die ();
}
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
Version, true, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
if (optind < argc)
{
static char const *const time_style_args[] =
{
- "full-iso", "long-iso", "iso", "locale", nullptr
+ "full-iso", "long-iso", "iso", "locale", NULL
};
static enum time_style const time_style_types[] =
{
/* Names of indicator styles. */
static char const *const indicator_style_args[] =
{
- "none", "slash", "file-type", "classify", nullptr
+ "none", "slash", "file-type", "classify", NULL
};
static enum indicator_style const indicator_style_types[] =
{
{
{ 2, (char const []) {'\033','['} },/* lc: Left of color sequence */
{ 1, (char const []) {'m'} }, /* rc: Right of color sequence */
- { 0, nullptr }, /* ec: End color (replaces lc+rs+rc) */
+ { 0, NULL }, /* ec: End color (replaces lc+rs+rc) */
{ 1, (char const []) {'0'} }, /* rs: Reset to ordinary colors */
- { 0, nullptr }, /* no: Normal */
- { 0, nullptr }, /* fi: File: default */
+ { 0, NULL }, /* no: Normal */
+ { 0, NULL }, /* fi: File: default */
{ 5, ((char const [])
{'0','1',';','3','4'}) }, /* di: Directory: bright blue */
{ 5, ((char const [])
{'0','1',';','3','3'}) }, /* bd: Block device: bright yellow */
{ 5, ((char const [])
{'0','1',';','3','3'}) }, /* cd: Char device: bright yellow */
- { 0, nullptr }, /* mi: Missing file: undefined */
- { 0, nullptr }, /* or: Orphaned symlink: undefined */
+ { 0, NULL }, /* mi: Missing file: undefined */
+ { 0, NULL }, /* or: Orphaned symlink: undefined */
{ 5, ((char const [])
{'0','1',';','3','2'}) }, /* ex: Executable: bright green */
{ 5, ((char const [])
{'3','4',';','4','2'}) }, /* ow: other-writable: blue on green */
{ 5, ((char const [])
{'3','0',';','4','2'}) }, /* tw: ow w/ sticky: black on green */
- { 0, nullptr }, /* ca: disabled by default */
- { 0, nullptr }, /* mh: disabled by default */
+ { 0, NULL }, /* ca: disabled by default */
+ { 0, NULL }, /* mh: disabled by default */
{ 3, ((char const [])
{'\033','[','K'}) }, /* cl: clear to end of line */
};
/* A list mapping file extensions to corresponding display sequence. */
-static struct color_ext_type *color_ext_list = nullptr;
+static struct color_ext_type *color_ext_list = NULL;
/* Buffer for color sequences */
static char *color_buf;
static struct option const long_options[] =
{
- {"all", no_argument, nullptr, 'a'},
- {"escape", no_argument, nullptr, 'b'},
- {"directory", no_argument, nullptr, 'd'},
- {"dired", no_argument, nullptr, 'D'},
- {"full-time", no_argument, nullptr, FULL_TIME_OPTION},
- {"group-directories-first", no_argument, nullptr,
+ {"all", no_argument, NULL, 'a'},
+ {"escape", no_argument, NULL, 'b'},
+ {"directory", no_argument, NULL, 'd'},
+ {"dired", no_argument, NULL, 'D'},
+ {"full-time", no_argument, NULL, FULL_TIME_OPTION},
+ {"group-directories-first", no_argument, NULL,
GROUP_DIRECTORIES_FIRST_OPTION},
- {"human-readable", no_argument, nullptr, 'h'},
- {"inode", no_argument, nullptr, 'i'},
- {"kibibytes", no_argument, nullptr, 'k'},
- {"numeric-uid-gid", no_argument, nullptr, 'n'},
- {"no-group", no_argument, nullptr, 'G'},
- {"hide-control-chars", no_argument, nullptr, 'q'},
- {"reverse", no_argument, nullptr, 'r'},
- {"size", no_argument, nullptr, 's'},
- {"width", required_argument, nullptr, 'w'},
- {"almost-all", no_argument, nullptr, 'A'},
- {"ignore-backups", no_argument, nullptr, 'B'},
- {"classify", optional_argument, nullptr, 'F'},
- {"file-type", no_argument, nullptr, FILE_TYPE_INDICATOR_OPTION},
- {"si", no_argument, nullptr, SI_OPTION},
- {"dereference-command-line", no_argument, nullptr, 'H'},
- {"dereference-command-line-symlink-to-dir", no_argument, nullptr,
+ {"human-readable", no_argument, NULL, 'h'},
+ {"inode", no_argument, NULL, 'i'},
+ {"kibibytes", no_argument, NULL, 'k'},
+ {"numeric-uid-gid", no_argument, NULL, 'n'},
+ {"no-group", no_argument, NULL, 'G'},
+ {"hide-control-chars", no_argument, NULL, 'q'},
+ {"reverse", no_argument, NULL, 'r'},
+ {"size", no_argument, NULL, 's'},
+ {"width", required_argument, NULL, 'w'},
+ {"almost-all", no_argument, NULL, 'A'},
+ {"ignore-backups", no_argument, NULL, 'B'},
+ {"classify", optional_argument, NULL, 'F'},
+ {"file-type", no_argument, NULL, FILE_TYPE_INDICATOR_OPTION},
+ {"si", no_argument, NULL, SI_OPTION},
+ {"dereference-command-line", no_argument, NULL, 'H'},
+ {"dereference-command-line-symlink-to-dir", no_argument, NULL,
DEREFERENCE_COMMAND_LINE_SYMLINK_TO_DIR_OPTION},
- {"hide", required_argument, nullptr, HIDE_OPTION},
- {"ignore", required_argument, nullptr, 'I'},
- {"indicator-style", required_argument, nullptr, INDICATOR_STYLE_OPTION},
- {"dereference", no_argument, nullptr, 'L'},
- {"literal", no_argument, nullptr, 'N'},
- {"quote-name", no_argument, nullptr, 'Q'},
- {"quoting-style", required_argument, nullptr, QUOTING_STYLE_OPTION},
- {"recursive", no_argument, nullptr, 'R'},
- {"format", required_argument, nullptr, FORMAT_OPTION},
- {"show-control-chars", no_argument, nullptr, SHOW_CONTROL_CHARS_OPTION},
- {"sort", required_argument, nullptr, SORT_OPTION},
- {"tabsize", required_argument, nullptr, 'T'},
- {"time", required_argument, nullptr, TIME_OPTION},
- {"time-style", required_argument, nullptr, TIME_STYLE_OPTION},
- {"zero", no_argument, nullptr, ZERO_OPTION},
- {"color", optional_argument, nullptr, COLOR_OPTION},
- {"hyperlink", optional_argument, nullptr, HYPERLINK_OPTION},
- {"block-size", required_argument, nullptr, BLOCK_SIZE_OPTION},
+ {"hide", required_argument, NULL, HIDE_OPTION},
+ {"ignore", required_argument, NULL, 'I'},
+ {"indicator-style", required_argument, NULL, INDICATOR_STYLE_OPTION},
+ {"dereference", no_argument, NULL, 'L'},
+ {"literal", no_argument, NULL, 'N'},
+ {"quote-name", no_argument, NULL, 'Q'},
+ {"quoting-style", required_argument, NULL, QUOTING_STYLE_OPTION},
+ {"recursive", no_argument, NULL, 'R'},
+ {"format", required_argument, NULL, FORMAT_OPTION},
+ {"show-control-chars", no_argument, NULL, SHOW_CONTROL_CHARS_OPTION},
+ {"sort", required_argument, NULL, SORT_OPTION},
+ {"tabsize", required_argument, NULL, 'T'},
+ {"time", required_argument, NULL, TIME_OPTION},
+ {"time-style", required_argument, NULL, TIME_STYLE_OPTION},
+ {"zero", no_argument, NULL, ZERO_OPTION},
+ {"color", optional_argument, NULL, COLOR_OPTION},
+ {"hyperlink", optional_argument, NULL, HYPERLINK_OPTION},
+ {"block-size", required_argument, NULL, BLOCK_SIZE_OPTION},
{"context", no_argument, NULL, 'Z'},
- {"author", no_argument, nullptr, AUTHOR_OPTION},
+ {"author", no_argument, NULL, AUTHOR_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
static char const *const format_args[] =
{
"verbose", "long", "commas", "horizontal", "across",
- "vertical", "single-column", nullptr
+ "vertical", "single-column", NULL
};
static enum format const format_types[] =
{
static char const *const sort_args[] =
{
"none", "size", "time", "version", "extension",
- "name", "width", nullptr
+ "name", "width", NULL
};
static enum sort_type const sort_types[] =
{
"ctime", "status",
"mtime", "modification",
"birth", "creation",
- nullptr
+ NULL
};
static enum time_type const time_types[] =
{
/* force and none are for compatibility with another color-ls version */
"always", "yes", "force",
"never", "no", "none",
- "auto", "tty", "if-tty", nullptr
+ "auto", "tty", "if-tty", NULL
};
static enum when_type const when_types[] =
{
}
#endif
-/* Return the address of the first plain %b spec in FMT, or nullptr if
+/* Return the address of the first plain %b spec in FMT, or NULL if
there is no such spec. %5b etc. do not match, so that user
widths/flags are honored. */
case 'b': return fmt;
case '%': fmt++; break;
}
- return nullptr;
+ return NULL;
}
static char RFC3986[256];
/* Attempt to insert this entry into the table. */
ent_from_table = hash_insert (active_dir_set, ent);
- if (ent_from_table == nullptr)
+ if (ent_from_table == NULL)
{
/* Insertion failed due to lack of memory. */
xalloc_die ();
/* Exit or suspend the program. */
raise (sig);
- sigprocmask (SIG_SETMASK, &oldset, nullptr);
+ sigprocmask (SIG_SETMASK, &oldset, NULL);
/* If execution reaches here, then the program has been
continued (after being suspended). */
for (int j = 0; j < nsigs + nstop; j++)
{
int sig = j < nsigs ? term_sig[j]: stop_sig[j - nsigs];
- sigaction (sig, nullptr, &act);
+ sigaction (sig, NULL, &act);
if (act.sa_handler != SIG_IGN)
sigaddset (&caught_signals, sig);
}
if (sigismember (&caught_signals, sig))
{
act.sa_handler = j < nsigs ? sighandler : stophandler;
- sigaction (sig, &act, nullptr);
+ sigaction (sig, &act, NULL);
}
}
}
exit_status = EXIT_SUCCESS;
print_dir_name = true;
- pending_dirs = nullptr;
+ pending_dirs = NULL;
current_time.tv_sec = TYPE_MINIMUM (time_t);
current_time.tv_nsec = -1;
detect any directory cycles. */
if (recursive)
{
- active_dir_set = hash_initialize (INITIAL_TABLE_SIZE, nullptr,
+ active_dir_set = hash_initialize (INITIAL_TABLE_SIZE, NULL,
dev_ino_hash,
dev_ino_compare,
dev_ino_free);
- if (active_dir_set == nullptr)
+ if (active_dir_set == NULL)
xalloc_die ();
obstack_init (&dev_ino_obstack);
if (n_files <= 0)
{
if (immediate_dirs)
- gobble_file (".", directory, NOT_AN_INODE_NUMBER, true, nullptr);
+ gobble_file (".", directory, NOT_AN_INODE_NUMBER, true, NULL);
else
- queue_directory (".", nullptr, true);
+ queue_directory (".", NULL, true);
}
else
do
- gobble_file (argv[i++], unknown, NOT_AN_INODE_NUMBER, true, nullptr);
+ gobble_file (argv[i++], unknown, NOT_AN_INODE_NUMBER, true, NULL);
while (i < argc);
if (cwd_n_used)
{
sort_files ();
if (!immediate_dirs)
- extract_dirs_from_files (nullptr, true);
+ extract_dirs_from_files (NULL, true);
/* 'cwd_n_used' might be zero now. */
}
if (LOOP_DETECT)
{
- if (thispend->name == nullptr)
+ if (thispend->name == NULL)
{
- /* thispend->name == nullptr means this is a marker entry
+ /* thispend->name == NULL means this is a marker entry
indicating we've finished processing the directory.
Use its dev/ino numbers to remove the corresponding
entry from the active_dir_set hash table. */
/* Treat too-large values as if they were 0, which is
effectively infinity. */
- switch (xstrtoumax (spec, nullptr, 0, &val, ""))
+ switch (xstrtoumax (spec, NULL, 0, &val, ""))
{
case LONGINT_OK:
return val <= MIN (PTRDIFF_MAX, SIZE_MAX) ? val : 0;
static int
decode_switches (int argc, char **argv)
{
- char *time_style_option = nullptr;
+ char *time_style_option = NULL;
/* These variables are false or -1 unless a switch says otherwise. */
bool kibibytes_specified = false;
if (p)
{
uintmax_t tmp;
- if (xstrtoumax (p, nullptr, 0, &tmp, "") == LONGINT_OK
+ if (xstrtoumax (p, NULL, 0, &tmp, "") == LONGINT_OK
&& tmp <= SIZE_MAX)
tabsize = tmp;
else
? (stdout_isatty () ? shell_escape_quoting_style : -1)
: escape_quoting_style);
if (0 <= qs)
- set_quoting_style (nullptr, qs);
- qs = get_quoting_style (nullptr);
+ set_quoting_style (NULL, qs);
+ qs = get_quoting_style (NULL);
align_variable_outer_quotes
= ((format == long_format
|| ((format == many_per_line || format == horizontal) && line_length))
&& (qs == shell_quoting_style
|| qs == shell_escape_quoting_style
|| qs == c_maybe_quoting_style));
- filename_quoting_options = clone_quoting_options (nullptr);
+ filename_quoting_options = clone_quoting_options (NULL);
if (qs == escape_quoting_style)
set_char_quoting (filename_quoting_options, ' ', 1);
if (file_type <= indicator_style)
set_char_quoting (filename_quoting_options, *p, 1);
}
- dirname_quoting_options = clone_quoting_options (nullptr);
+ dirname_quoting_options = clone_quoting_options (NULL);
set_char_quoting (dirname_quoting_options, ':', 1);
/* --dired implies --format=long (-l) and sans --hyperlink.
if (format == long_format)
{
- char *envstyle = nullptr;
+ char *envstyle = NULL;
char *style = time_style_option;
if (! style)
style = envstyle = getenv ("TIME_STYLE");
{
for (int i = 0; i < 2; i++)
long_time_format[i] =
- dcgettext (nullptr, long_time_format[i], LC_TIME);
+ dcgettext (NULL, long_time_format[i], LC_TIME);
}
}
}
char label0, label1; /* Indicator label */
struct color_ext_type *ext; /* Extension we are working on */
- if ((p = getenv ("LS_COLORS")) == nullptr || *p == '\0')
+ if ((p = getenv ("LS_COLORS")) == NULL || *p == '\0')
{
/* LS_COLORS takes precedence, but if that's not set then
honor the COLORTERM and TERM env variables so that
return;
}
- ext = nullptr;
+ ext = NULL;
/* This is an overly conservative estimate, but any possible
LS_COLORS string will *not* generate a color_buf longer than
error (0, 0,
_("unparsable value for LS_COLORS environment variable"));
free (color_buf);
- for (struct color_ext_type *e = color_ext_list; e != nullptr;
+ for (struct color_ext_type *e = color_ext_list; e != NULL;
/* empty */)
{
struct color_ext_type *e2 = e;
different cased extensions with separate sequences defined.
Also set ext.len to SIZE_MAX on any entries that can't
match due to precedence, to avoid redundant string compares. */
- for (struct color_ext_type *e1 = color_ext_list; e1 != nullptr;
+ for (struct color_ext_type *e1 = color_ext_list; e1 != NULL;
e1 = e1->next)
{
bool case_ignored = false;
- for (struct color_ext_type *e2 = e1->next; e2 != nullptr;
+ for (struct color_ext_type *e2 = e1->next; e2 != NULL;
e2 = e2->next)
{
if (e2->ext.len < SIZE_MAX && e1->ext.len == e2->ext.len)
If REALNAME is nonzero, it will be used instead of NAME when the
directory name is printed. This allows symbolic links to directories
to be treated as regular directories but still be listed under their
- real names. NAME == nullptr is used to insert a marker entry for the
+ real names. NAME == NULL is used to insert a marker entry for the
directory named in REALNAME.
If NAME is non-null, we use its dev/ino information to save
a call to stat -- when doing a recursive (-R) traversal.
queue_directory (char const *name, char const *realname, bool command_line_arg)
{
struct pending *new = xmalloc (sizeof *new);
- new->realname = realname ? xstrdup (realname) : nullptr;
- new->name = name ? xstrdup (name) : nullptr;
+ new->realname = realname ? xstrdup (realname) : NULL;
+ new->name = name ? xstrdup (name) : NULL;
new->command_line_arg = command_line_arg;
new->next = pending_dirs;
pending_dirs = new;
first = false;
dired_indent ();
- char *absolute_name = nullptr;
+ char *absolute_name = NULL;
if (print_hyperlink)
{
absolute_name = canonicalize_filename_mode (name, CAN_MISSING);
_("error canonicalizing %s"), name);
}
quote_name (realname ? realname : name, dirname_quoting_options, -1,
- nullptr, true, &subdired_obstack, absolute_name);
+ NULL, true, &subdired_obstack, absolute_name);
free (absolute_name);
bool has_cap;
cap_t cap_d = cap_get_file (name);
- if (cap_d == nullptr)
+ if (cap_d == NULL)
return false;
- result = cap_to_text (cap_d, nullptr);
+ result = cap_to_text (cap_d, NULL);
cap_free (cap_d);
if (!result)
return false;
f->has_capability = has_capability_cache (full_name, f);
f->scontext = ai.scontext;
- ai.scontext = nullptr;
+ ai.scontext = NULL;
aclinfo_free (&ai);
}
get_link_name (char const *filename, struct fileinfo *f, bool command_line_arg)
{
f->linkname = areadlink_with_size (filename, f->stat.st_size);
- if (f->linkname == nullptr)
+ if (f->linkname == NULL)
file_failure (command_line_arg, _("cannot read symbolic link %s"),
filename);
}
extract_dirs_from_files (char const *dirname, bool command_line_arg)
{
idx_t i, j;
- bool ignore_dot_and_dot_dot = (dirname != nullptr);
+ bool ignore_dot_and_dot_dot = (dirname != NULL);
if (dirname && LOOP_DETECT)
{
/* Insert a marker entry first. When we dequeue this marker entry,
we'll know that DIRNAME has been processed and may be removed
from the set of active directories. */
- queue_directory (nullptr, dirname, false);
+ queue_directory (NULL, dirname, false);
}
/* Queue the directories last one first, because queueing reverses the
queue_directory (f->name, f->linkname, command_line_arg);
else
{
- char *name = file_name_concat (dirname, f->name, nullptr);
+ char *name = file_name_concat (dirname, f->name, NULL);
queue_directory (name, f->linkname, command_line_arg);
free (name);
}
{ rev_xstrcoll_version, rev_xstrcoll_df_version },
},
- /* We use nullptr for the strcmp variants of version comparison
+ /* We use NULL for the strcmp variants of version comparison
since as explained in cmp_version definition, version comparison
does not rely on xstrcoll, so it will never longjmp, and never
need to try the strcmp fallback. */
{
- { nullptr, nullptr },
- { nullptr, nullptr },
+ { NULL, NULL },
+ { NULL, NULL },
}
},
format_user (uid_t u, int width, bool stat_ok)
{
format_user_or_group (! stat_ok ? "?" :
- (numeric_ids ? nullptr : getuser (u)), u, width);
+ (numeric_ids ? NULL : getuser (u)), u, width);
}
/* Likewise, for groups. */
format_group (gid_t g, int width, bool stat_ok)
{
format_user_or_group (! stat_ok ? "?" :
- (numeric_ids ? nullptr : getgroup (g)), g, width);
+ (numeric_ids ? NULL : getgroup (g)), g, width);
}
/* Return the number of columns that format_user_or_group will print,
{
return (name
? mbswidth (name, MBSWIDTH_FLAGS)
- : snprintf (nullptr, 0, "%ju", id));
+ : snprintf (NULL, 0, "%ju", id));
}
/* Return the number of columns that format_user will print,
static int
format_user_width (uid_t u)
{
- return format_user_or_group_width (numeric_ids ? nullptr : getuser (u), u);
+ return format_user_or_group_width (numeric_ids ? NULL : getuser (u), u);
}
/* Likewise, for groups. */
static int
format_group_width (gid_t g)
{
- return format_user_or_group_width (numeric_ids ? nullptr : getgroup (g), g);
+ return format_user_or_group_width (numeric_ids ? NULL : getgroup (g), g);
}
/* Return a pointer to a formatted version of F->stat.st_ino,
if (f->linkname)
{
dired_outstring (" -> ");
- print_name_with_quoting (f, true, nullptr, (p - buf) + w + 4);
+ print_name_with_quoting (f, true, NULL, (p - buf) + w + 4);
if (indicator_style != none)
print_type_indicator (true, f->linkmode, unknown);
}
displayed_width = len;
}
}
- else if (width != nullptr)
+ else if (width != NULL)
{
if (MB_CUR_MAX > 1)
{
not actually part of the name. */
*pad = (align_variable_outer_quotes && cwd_some_quoted && ! quoted);
- if (width != nullptr)
+ if (width != NULL)
*width = displayed_width;
*inbuf = buf;
bool pad;
len = quote_name_buf (&buf, sizeof smallbuf, (char *) name, options,
- needs_general_quoting, nullptr, &pad);
+ needs_general_quoting, NULL, &pad);
if (pad && allow_pad)
dired_outbyte (' ');
char const *name = symlink_target ? f->linkname : f->name;
const struct bin_str *color
- = print_with_color ? get_color_indicator (f, symlink_target) : nullptr;
+ = print_with_color ? get_color_indicator (f, symlink_target) : NULL;
bool used_color_this_time = (print_with_color
&& (color || is_colored (C_NORM)));
static void
prep_non_filename_text (void)
{
- if (color_indicator[C_END].string != nullptr)
+ if (color_indicator[C_END].string != NULL)
put_indicator (&color_indicator[C_END]);
else
{
if (print_scontext)
printf ("%*s ", format == with_commas ? 0 : scontext_width, f->scontext);
- size_t width = print_name_with_quoting (f, false, nullptr, start_col);
+ size_t width = print_name_with_quoting (f, false, NULL, start_col);
if (indicator_style != none)
width += print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype);
put_indicator (&color_indicator[C_RIGHT]);
}
- return ind != nullptr;
+ return ind != NULL;
}
-/* Returns color indicator or nullptr if none. */
+/* Returns color indicator or NULL if none. */
ATTRIBUTE_PURE
static const struct bin_str*
get_color_indicator (const struct fileinfo *f, bool symlink_target)
}
/* Check the file's suffix only if still classified as C_FILE. */
- ext = nullptr;
+ ext = NULL;
if (type == C_FILE)
{
/* Test if NAME has a recognized suffix. */
len = strlen (name);
name += len; /* Pointer to final \0. */
- for (ext = color_ext_list; ext != nullptr; ext = ext->next)
+ for (ext = color_ext_list; ext != NULL; ext = ext->next)
{
if (ext->ext.len <= len)
{
const struct bin_str *const s
= ext ? &(ext->seq) : &color_indicator[type];
- return s->string ? s : nullptr;
+ return s->string ? s : NULL;
}
/* Output a color indicator (which may contain nulls). */
static struct option const longopts[] =
{
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
- {"mode", required_argument, nullptr, 'm'},
- {"parents", no_argument, nullptr, 'p'},
- {"verbose", no_argument, nullptr, 'v'},
+ {"mode", required_argument, NULL, 'm'},
+ {"parents", no_argument, NULL, 'p'},
+ {"verbose", no_argument, NULL, 'v'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
/* Options passed to subsidiary functions. */
struct mkdir_options
{
- /* Function to make an ancestor, or nullptr if ancestors should not be
+ /* Function to make an ancestor, or NULL if ancestors should not be
made. */
int (*make_ancestor_function) (char const *, char const *, void *);
int
main (int argc, char **argv)
{
- char const *specified_mode = nullptr;
+ char const *specified_mode = NULL;
int optc;
- char const *scontext = nullptr;
+ char const *scontext = NULL;
struct mkdir_options options;
- options.make_ancestor_function = nullptr;
+ options.make_ancestor_function = NULL;
options.mode = S_IRWXUGO;
options.mode_bits = 0;
- options.created_directory_format = nullptr;
- options.set_security_context = nullptr;
+ options.created_directory_format = NULL;
+ options.set_security_context = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
atexit (close_stdout);
- while ((optc = getopt_long (argc, argv, "pm:vZ", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "pm:vZ", longopts, NULL)) != -1)
{
switch (optc)
{
else
{
options.set_security_context = selabel_open (SELABEL_CTX_FILE,
- nullptr, 0);
+ NULL, 0);
if (! options.set_security_context)
error (0, errno, _("warning: ignoring --context"));
}
static struct option const longopts[] =
{
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
- {"mode", required_argument, nullptr, 'm'},
+ {"mode", required_argument, NULL, 'm'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
int
main (int argc, char **argv)
{
- char const *specified_mode = nullptr;
- char const *scontext = nullptr;
- struct selabel_handle *set_security_context = nullptr;
+ char const *specified_mode = NULL;
+ char const *scontext = NULL;
+ struct selabel_handle *set_security_context = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
atexit (close_stdout);
int optc;
- while ((optc = getopt_long (argc, argv, "m:Z", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "m:Z", longopts, NULL)) != -1)
{
switch (optc)
{
else
{
set_security_context = selabel_open (SELABEL_CTX_FILE,
- nullptr, 0);
+ NULL, 0);
if (! set_security_context)
error (0, errno, _("warning: ignoring --context"));
}
error (EXIT_FAILURE, 0, _("invalid mode"));
mode_t umask_value = umask (0);
umask (umask_value);
- newmode = mode_adjust (newmode, false, umask_value, change, nullptr);
+ newmode = mode_adjust (newmode, false, umask_value, change, NULL);
free (change);
if (newmode & ~S_IRWXUGO)
error (EXIT_FAILURE, 0,
static struct option const longopts[] =
{
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
- {"mode", required_argument, nullptr, 'm'},
+ {"mode", required_argument, NULL, 'm'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
int
main (int argc, char **argv)
{
- char const *specified_mode = nullptr;
- char const *scontext = nullptr;
- struct selabel_handle *set_security_context = nullptr;
+ char const *specified_mode = NULL;
+ char const *scontext = NULL;
+ struct selabel_handle *set_security_context = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
atexit (close_stdout);
int optc;
- while ((optc = getopt_long (argc, argv, "m:Z", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "m:Z", longopts, NULL)) != -1)
{
switch (optc)
{
else
{
set_security_context = selabel_open (SELABEL_CTX_FILE,
- nullptr, 0);
+ NULL, 0);
if (! set_security_context)
error (0, errno, _("warning: ignoring --context"));
}
error (EXIT_FAILURE, 0, _("invalid mode"));
mode_t umask_value = umask (0);
umask (umask_value);
- newmode = mode_adjust (newmode, false, umask_value, change, nullptr);
+ newmode = mode_adjust (newmode, false, umask_value, change, NULL);
free (change);
if (newmode & ~S_IRWXUGO)
error (EXIT_FAILURE, 0,
{
char const *s_major = argv[optind + 2];
uintmax_t i_major;
- if (xstrtoumax (s_major, nullptr, 0, &i_major, "") != LONGINT_OK
+ if (xstrtoumax (s_major, NULL, 0, &i_major, "") != LONGINT_OK
|| i_major != (major_t) i_major)
error (EXIT_FAILURE, 0,
_("invalid major device number %s"), quote (s_major));
char const *s_minor = argv[optind + 3];
uintmax_t i_minor;
- if (xstrtoumax (s_minor, nullptr, 0, &i_minor, "") != LONGINT_OK
+ if (xstrtoumax (s_minor, NULL, 0, &i_minor, "") != LONGINT_OK
|| i_minor != (minor_t) i_minor)
error (EXIT_FAILURE, 0,
_("invalid minor device number %s"), quote (s_minor));
static struct option const longopts[] =
{
- {"directory", no_argument, nullptr, 'd'},
- {"quiet", no_argument, nullptr, 'q'},
- {"dry-run", no_argument, nullptr, 'u'},
- {"suffix", required_argument, nullptr, SUFFIX_OPTION},
- {"tmpdir", optional_argument, nullptr, 'p'},
+ {"directory", no_argument, NULL, 'd'},
+ {"quiet", no_argument, NULL, 'q'},
+ {"dry-run", no_argument, NULL, 'u'},
+ {"suffix", required_argument, NULL, SUFFIX_OPTION},
+ {"tmpdir", optional_argument, NULL, 'p'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
main (int argc, char **argv)
{
char const *dest_dir;
- char const *dest_dir_arg = nullptr;
+ char const *dest_dir_arg = NULL;
bool suppress_file_err = false;
int c;
char *template;
- char *suffix = nullptr;
+ char *suffix = NULL;
bool use_dest_dir = false;
bool deprecated_t_option = false;
bool create_directory = false;
int status = EXIT_SUCCESS;
size_t x_count;
size_t suffix_len;
- char *dest_name = nullptr;
+ char *dest_name = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
atexit (maybe_close_stdout);
- while ((c = getopt_long (argc, argv, "dp:qtuV", longopts, nullptr)) != -1)
+ while ((c = getopt_long (argc, argv, "dp:qtuV", longopts, NULL)) != -1)
{
switch (c)
{
quote (template));
}
- dest_name = file_name_concat (dest_dir, template, nullptr);
+ dest_name = file_name_concat (dest_dir, template, NULL);
free (template);
template = dest_name;
/* Note that suffix is now invalid. */
static char const *const update_type_string[] =
{
- "all", "none", "none-fail", "older", nullptr
+ "all", "none", "none-fail", "older", NULL
};
static enum Update_type const update_type[] =
{
static struct option const long_options[] =
{
- {"backup", optional_argument, nullptr, 'b'},
- {"context", no_argument, nullptr, 'Z'},
- {"debug", no_argument, nullptr, DEBUG_OPTION},
- {"exchange", no_argument, nullptr, EXCHANGE_OPTION},
- {"force", no_argument, nullptr, 'f'},
- {"interactive", no_argument, nullptr, 'i'},
- {"no-clobber", no_argument, nullptr, 'n'}, /* Deprecated. */
- {"no-copy", no_argument, nullptr, NO_COPY_OPTION},
- {"no-target-directory", no_argument, nullptr, 'T'},
- {"strip-trailing-slashes", no_argument, nullptr,
+ {"backup", optional_argument, NULL, 'b'},
+ {"context", no_argument, NULL, 'Z'},
+ {"debug", no_argument, NULL, DEBUG_OPTION},
+ {"exchange", no_argument, NULL, EXCHANGE_OPTION},
+ {"force", no_argument, NULL, 'f'},
+ {"interactive", no_argument, NULL, 'i'},
+ {"no-clobber", no_argument, NULL, 'n'}, /* Deprecated. */
+ {"no-copy", no_argument, NULL, NO_COPY_OPTION},
+ {"no-target-directory", no_argument, NULL, 'T'},
+ {"strip-trailing-slashes", no_argument, NULL,
STRIP_TRAILING_SLASHES_OPTION},
- {"suffix", required_argument, nullptr, 'S'},
- {"target-directory", required_argument, nullptr, 't'},
- {"update", optional_argument, nullptr, 'u'},
- {"verbose", no_argument, nullptr, 'v'},
+ {"suffix", required_argument, NULL, 'S'},
+ {"target-directory", required_argument, NULL, 't'},
+ {"update", optional_argument, NULL, 'u'},
+ {"verbose", no_argument, NULL, 'v'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
static void
{
static struct dev_ino dev_ino_buf;
x->root_dev_ino = get_root_dev_ino (&dev_ino_buf);
- if (x->root_dev_ino == nullptr)
+ if (x->root_dev_ino == NULL)
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
quoteaf ("/"));
}
x->preserve_timestamps = true;
x->explicit_no_preserve_mode= false;
x->preserve_security_context = selinux_enabled;
- x->set_security_context = nullptr;
+ x->set_security_context = NULL;
x->reduce_diagnostics = false;
x->data_copy_required = true;
x->require_preserve = false; /* FIXME: maybe make this an option */
x->open_dangling_dest_symlink = false;
x->update = UPDATE_ALL;
x->verbose = false;
- x->dest_info = nullptr;
- x->src_info = nullptr;
+ x->dest_info = NULL;
+ x->src_info = NULL;
}
/* Move SOURCE onto DEST aka DEST_DIRFD+DEST_RELNAME.
copied-into-self directory, DEST ('b/b' in the example),
and failing. */
- dir_to_remove = nullptr;
+ dir_to_remove = NULL;
ok = false;
}
else if (rename_succeeded)
{
/* No need to remove anything. SOURCE was successfully
renamed to DEST. Or the user declined to rename a file. */
- dir_to_remove = nullptr;
+ dir_to_remove = NULL;
}
else
{
dir_to_remove = source;
}
- if (dir_to_remove != nullptr)
+ if (dir_to_remove != NULL)
{
struct rm_options rm_options;
rm_option_init (&rm_options);
rm_options.verbose = x->verbose;
- char const *dir[2] = { dir_to_remove, nullptr };
+ char const *dir[2] = { dir_to_remove, NULL };
enum RM_status status = rm ((void *) dir, &rm_options);
affirm (VALID_STATUS (status));
main (int argc, char **argv)
{
bool make_backups = false;
- char const *backup_suffix = nullptr;
- char *version_control_string = nullptr;
+ char const *backup_suffix = NULL;
+ char *version_control_string = NULL;
struct cp_options x;
bool remove_trailing_slashes = false;
- char const *target_directory = nullptr;
+ char const *target_directory = NULL;
bool no_target_directory = false;
bool selinux_enabled = (0 < is_selinux_enabled ());
priv_set_remove_linkdir ();
int c;
- while ((c = getopt_long (argc, argv, "bfint:uvS:TZ", long_options, nullptr))
+ while ((c = getopt_long (argc, argv, "bfint:uvS:TZ", long_options, NULL))
!= -1)
{
switch (c)
{
x.preserve_security_context = false;
x.set_security_context = selabel_open (SELABEL_CTX_FILE,
- nullptr, 0);
+ NULL, 0);
if (! x.set_security_context)
error (0, errno, _("warning: ignoring --context"));
}
static struct option const longopts[] =
{
- {"adjustment", required_argument, nullptr, 'n'},
+ {"adjustment", required_argument, NULL, 'n'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
{
int current_niceness;
int adjustment = 10;
- char const *adjustment_given = nullptr;
+ char const *adjustment_given = NULL;
bool ok;
int i;
/* Initialize getopt_long's internal state. */
optind = 0;
- c = getopt_long (fake_argc, fake_argv, "+n:", longopts, nullptr);
+ c = getopt_long (fake_argc, fake_argv, "+n:", longopts, NULL);
i += optind - 1;
switch (c)
enum { MIN_ADJUSTMENT = 1 - 2 * NZERO, MAX_ADJUSTMENT = 2 * NZERO - 1 };
#endif
long int tmp;
- if (LONGINT_OVERFLOW < xstrtol (adjustment_given, nullptr, 10, &tmp, ""))
+ if (LONGINT_OVERFLOW < xstrtol (adjustment_given, NULL, 10, &tmp, ""))
error (EXIT_CANCELED, 0, _("invalid adjustment %s"),
quote (adjustment_given));
#if (defined __gnu_hurd__ \
static char footer_fastmap[UCHAR_MAX + 1];
/* Pointer to current regex, if any. */
-static struct re_pattern_buffer *current_regex = nullptr;
+static struct re_pattern_buffer *current_regex = NULL;
/* Separator string to print after line number (-s). */
static char const *separator_str = "\t";
static char *section_del = DEFAULT_SECTION_DELIMITERS;
/* Header delimiter string. */
-static char *header_del = nullptr;
+static char *header_del = NULL;
/* Header section delimiter length. */
static size_t header_del_len;
/* Body delimiter string. */
-static char *body_del = nullptr;
+static char *body_del = NULL;
/* Body section delimiter length. */
static size_t body_del_len;
/* Footer delimiter string. */
-static char *footer_del = nullptr;
+static char *footer_del = NULL;
/* Footer section delimiter length. */
static size_t footer_del_len;
static struct linebuffer line_buf;
/* printf format string for unnumbered lines. */
-static char *print_no_line_fmt = nullptr;
+static char *print_no_line_fmt = NULL;
/* Starting line number on each page (-v). */
static intmax_t starting_line_number = 1;
static struct option const longopts[] =
{
- {"header-numbering", required_argument, nullptr, 'h'},
- {"body-numbering", required_argument, nullptr, 'b'},
- {"footer-numbering", required_argument, nullptr, 'f'},
- {"starting-line-number", required_argument, nullptr, 'v'},
- {"line-increment", required_argument, nullptr, 'i'},
- {"no-renumber", no_argument, nullptr, 'p'},
- {"join-blank-lines", required_argument, nullptr, 'l'},
- {"number-separator", required_argument, nullptr, 's'},
- {"number-width", required_argument, nullptr, 'w'},
- {"number-format", required_argument, nullptr, 'n'},
- {"section-delimiter", required_argument, nullptr, 'd'},
+ {"header-numbering", required_argument, NULL, 'h'},
+ {"body-numbering", required_argument, NULL, 'b'},
+ {"footer-numbering", required_argument, NULL, 'f'},
+ {"starting-line-number", required_argument, NULL, 'v'},
+ {"line-increment", required_argument, NULL, 'i'},
+ {"no-renumber", no_argument, NULL, 'p'},
+ {"join-blank-lines", required_argument, NULL, 'l'},
+ {"number-separator", required_argument, NULL, 's'},
+ {"number-width", required_argument, NULL, 'w'},
+ {"number-format", required_argument, NULL, 'n'},
+ {"section-delimiter", required_argument, NULL, 'd'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Print a usage message and quit. */
break;
case 'p':
*typep = optarg++;
- regexp->buffer = nullptr;
+ regexp->buffer = NULL;
regexp->allocated = 0;
regexp->fastmap = fastmap;
- regexp->translate = nullptr;
+ regexp->translate = NULL;
re_syntax_options =
RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES;
errmsg = re_compile_pattern (optarg, strlen (optarg), regexp);
break;
case 'p':
switch (re_search (current_regex, line_buf.buffer, line_buf.length - 1,
- 0, line_buf.length - 1, nullptr))
+ 0, line_buf.length - 1, NULL))
{
case -2:
error (EXIT_FAILURE, errno, _("error in regular expression search"));
else
{
stream = fopen (file, "r");
- if (stream == nullptr)
+ if (stream == NULL)
{
error (0, errno, "%s", quotef (file));
return false;
have_read_stdin = false;
while ((c = getopt_long (argc, argv, "h:b:f:v:i:pl:s:w:n:d:", longopts,
- nullptr))
+ NULL))
!= -1)
{
switch (c)
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
Version, false, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
if (argc <= optind)
{
int out_fd = STDOUT_FILENO;
if (redirecting_stdout || (redirecting_stderr && stdout_is_closed))
{
- char *in_home = nullptr;
+ char *in_home = NULL;
char const *file = "nohup.out";
int flags = O_CREAT | O_WRONLY | O_APPEND;
mode_t mode = S_IRUSR | S_IWUSR;
char const *home = getenv ("HOME");
if (home)
{
- in_home = file_name_concat (home, file, nullptr);
+ in_home = file_name_concat (home, file, NULL);
out_fd = (redirecting_stdout
? fd_reopen (STDOUT_FILENO, in_home, flags, mode)
: open (in_home, flags, mode));
static struct option const longopts[] =
{
- {"all", no_argument, nullptr, ALL_OPTION},
- {"ignore", required_argument, nullptr, IGNORE_OPTION},
+ {"all", no_argument, NULL, ALL_OPTION},
+ {"ignore", required_argument, NULL, IGNORE_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
while (true)
{
- int c = getopt_long (argc, argv, "", longopts, nullptr);
+ int c = getopt_long (argc, argv, "", longopts, NULL);
if (c == -1)
break;
switch (c)
static char const *const scale_from_args[] =
{
- "none", "auto", "si", "iec", "iec-i", nullptr
+ "none", "auto", "si", "iec", "iec-i", NULL
};
static enum scale_type const scale_from_types[] =
static char const *const scale_to_args[] =
{
- "none", "si", "iec", "iec-i", nullptr
+ "none", "si", "iec", "iec-i", NULL
};
static enum scale_type const scale_to_types[] =
static char const *const round_args[] =
{
- "up", "down", "from-zero", "towards-zero", "nearest", nullptr
+ "up", "down", "from-zero", "towards-zero", "nearest", NULL
};
static enum round_type const round_types[] =
static char const *const inval_args[] =
{
- "abort", "fail", "warn", "ignore", nullptr
+ "abort", "fail", "warn", "ignore", NULL
};
static enum inval_type const inval_types[] =
static struct option const longopts[] =
{
- {"from", required_argument, nullptr, FROM_OPTION},
- {"from-unit", required_argument, nullptr, FROM_UNIT_OPTION},
- {"to", required_argument, nullptr, TO_OPTION},
- {"to-unit", required_argument, nullptr, TO_UNIT_OPTION},
- {"round", required_argument, nullptr, ROUND_OPTION},
- {"padding", required_argument, nullptr, PADDING_OPTION},
- {"suffix", required_argument, nullptr, SUFFIX_OPTION},
- {"unit-separator", required_argument, nullptr, UNIT_SEPARATOR_OPTION},
- {"grouping", no_argument, nullptr, GROUPING_OPTION},
- {"delimiter", required_argument, nullptr, 'd'},
- {"field", required_argument, nullptr, FIELD_OPTION},
- {"debug", no_argument, nullptr, DEBUG_OPTION},
- {"-debug", no_argument, nullptr, DEV_DEBUG_OPTION},
- {"header", optional_argument, nullptr, HEADER_OPTION},
- {"format", required_argument, nullptr, FORMAT_OPTION},
- {"invalid", required_argument, nullptr, INVALID_OPTION},
- {"zero-terminated", no_argument, nullptr, 'z'},
+ {"from", required_argument, NULL, FROM_OPTION},
+ {"from-unit", required_argument, NULL, FROM_UNIT_OPTION},
+ {"to", required_argument, NULL, TO_OPTION},
+ {"to-unit", required_argument, NULL, TO_UNIT_OPTION},
+ {"round", required_argument, NULL, ROUND_OPTION},
+ {"padding", required_argument, NULL, PADDING_OPTION},
+ {"suffix", required_argument, NULL, SUFFIX_OPTION},
+ {"unit-separator", required_argument, NULL, UNIT_SEPARATOR_OPTION},
+ {"grouping", no_argument, NULL, GROUPING_OPTION},
+ {"delimiter", required_argument, NULL, 'd'},
+ {"field", required_argument, NULL, FIELD_OPTION},
+ {"debug", no_argument, NULL, DEBUG_OPTION},
+ {"-debug", no_argument, NULL, DEV_DEBUG_OPTION},
+ {"header", optional_argument, NULL, HEADER_OPTION},
+ {"format", required_argument, NULL, FORMAT_OPTION},
+ {"invalid", required_argument, NULL, INVALID_OPTION},
+ {"zero-terminated", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Maximum number of digits we can safely handle
static enum scale_type scale_to = scale_none;
static enum round_type round_style = round_from_zero;
static enum inval_type inval_style = inval_abort;
-static char const *suffix = nullptr;
-static char const *unit_separator = nullptr;
+static char const *suffix = NULL;
+static char const *unit_separator = NULL;
static uintmax_t from_unit_size = 1;
static uintmax_t to_unit_size = 1;
static int grouping = 0;
-static char *padding_buffer = nullptr;
+static char *padding_buffer = NULL;
static idx_t padding_buffer_size = 0;
static intmax_t padding_width = 0;
static int zero_padding_width = 0;
static long int user_precision = -1;
-static char const *format_str = nullptr;
-static char *format_str_prefix = nullptr;
-static char *format_str_suffix = nullptr;
+static char const *format_str = NULL;
+static char *format_str_prefix = NULL;
+static char *format_str_suffix = NULL;
/* By default, any conversion error will terminate the program. */
static int conv_exit_code = EXIT_CONVERSION_WARNINGS;
/* auto-pad each line based on skipped whitespace. */
static int auto_padding = 0;
-/* field delimiter - if nullptr, blanks separate fields. */
-static char const *delimiter = nullptr;
+/* field delimiter - if NULL, blanks separate fields. */
+static char const *delimiter = NULL;
/* line delimiter. */
static unsigned char line_delim = '\n';
static inline bool
valid_suffix (const char suf)
{
- return strchr (valid_suffixes, suf) != nullptr;
+ return strchr (valid_suffixes, suf) != NULL;
}
static inline int
static void
simple_strtod_fatal (enum simple_strtod_error err, char const *input_str)
{
- char const *msgid = nullptr;
+ char const *msgid = NULL;
switch (err)
{
{
strtol_error s_err;
char const *c_string = n_string;
- char *t_string = nullptr;
+ char *t_string = NULL;
size_t n_len = strlen (n_string);
- char *end = nullptr;
+ char *end = NULL;
uintmax_t n;
char const *suffixes = valid_suffixes;
size_t i;
size_t prefix_len = 0;
size_t suffix_pos;
- char *endptr = nullptr;
+ char *endptr = NULL;
bool zero_padding = false;
for (i = 0; !(fmt[i] == '%' && fmt[i + 1] != '%'); i += (fmt[i] == '%') + 1)
parse_human_number (char const *str, long double /*output */ *value,
size_t *precision)
{
- char *ptr = nullptr;
+ char *ptr = NULL;
enum simple_strtod_error e =
simple_strtod_human (str, &ptr, value, precision, scale_from);
}
/* Search for multi-byte character C in multi-byte string S.
- Return a pointer to the character, or nullptr if not found. */
+ Return a pointer to the character, or NULL if not found. */
ATTRIBUTE_PURE
static char *
mbsmbchr (char const* s, char const* c)
if (! process_field (next, field))
valid_number = false;
- if (delimiter != nullptr)
+ if (delimiter != NULL)
fputs (delimiter, stdout);
else
fputc (' ', stdout);
#endif
decimal_point = nl_langinfo (RADIXCHAR);
- if (decimal_point == nullptr || strlen (decimal_point) == 0)
+ if (decimal_point == NULL || strlen (decimal_point) == 0)
decimal_point = ".";
decimal_point_length = strlen (decimal_point);
thousands_sep = nl_langinfo (THOUSEP);
- if (thousands_sep == nullptr)
+ if (thousands_sep == NULL)
thousands_sep = "";
thousands_sep_length = strlen (thousands_sep);
while (true)
{
- int c = getopt_long (argc, argv, "d:z", longopts, nullptr);
+ int c = getopt_long (argc, argv, "d:z", longopts, NULL);
if (c == -1)
break;
break;
case PADDING_OPTION:
- if (((xstrtoimax (optarg, nullptr, 10, &padding_width, "")
+ if (((xstrtoimax (optarg, NULL, 10, &padding_width, "")
& ~LONGINT_OVERFLOW)
!= LONGINT_OK)
|| padding_width == 0)
case HEADER_OPTION:
if (optarg)
{
- if (xstrtoumax (optarg, nullptr, 10, &header, "") != LONGINT_OK
+ if (xstrtoumax (optarg, NULL, 10, &header, "") != LONGINT_OK
|| header == 0)
error (EXIT_FAILURE, 0, _("invalid header value %s"),
quote (optarg));
}
}
- if (format_str != nullptr && grouping)
+ if (format_str != NULL && grouping)
error (EXIT_FAILURE, 0, _("--grouping cannot be combined with --format"));
if (debug && ! locale_ok)
/* Warn about no-op. */
if (debug && scale_from == scale_none && scale_to == scale_none
- && !grouping && (padding_width == 0) && (format_str == nullptr))
+ && !grouping && (padding_width == 0) && (format_str == NULL))
error (0, 0, _("no conversion option specified"));
- if (debug && unit_separator && delimiter == nullptr)
+ if (debug && unit_separator && delimiter == NULL)
error (0, 0,
_("field delimiters have higher precedence than unit separators"));
error (0, 0, _("grouping has no effect in this locale"));
}
- auto_padding = (padding_width == 0 && delimiter == nullptr);
+ auto_padding = (padding_width == 0 && delimiter == NULL);
if (inval_style != inval_abort)
conv_exit_code = 0;
}
else
{
- char *line = nullptr;
+ char *line = NULL;
size_t line_allocated = 0;
ssize_t len;
/* Initializer for file_list if no file-arguments
were specified on the command line. */
-static char const *const default_file_list[] = {"-", nullptr};
+static char const *const default_file_list[] = {"-", NULL};
/* The input stream associated with the current file. */
static FILE *in_stream;
static char const *const endian_args[] =
{
- "little", "big", nullptr
+ "little", "big", NULL
};
static enum endian_type const endian_types[] =
static struct option const long_options[] =
{
- {"skip-bytes", required_argument, nullptr, 'j'},
- {"address-radix", required_argument, nullptr, 'A'},
- {"read-bytes", required_argument, nullptr, 'N'},
- {"format", required_argument, nullptr, 't'},
- {"output-duplicates", no_argument, nullptr, 'v'},
- {"strings", optional_argument, nullptr, 'S'},
- {"traditional", no_argument, nullptr, TRADITIONAL_OPTION},
- {"width", optional_argument, nullptr, 'w'},
- {"endian", required_argument, nullptr, ENDIAN_OPTION },
+ {"skip-bytes", required_argument, NULL, 'j'},
+ {"address-radix", required_argument, NULL, 'A'},
+ {"read-bytes", required_argument, NULL, 'N'},
+ {"format", required_argument, NULL, 't'},
+ {"output-duplicates", no_argument, NULL, 'v'},
+ {"strings", optional_argument, NULL, 'S'},
+ {"traditional", no_argument, NULL, TRADITIONAL_OPTION},
+ {"width", optional_argument, NULL, 'w'},
+ {"endian", required_argument, NULL, ENDIAN_OPTION },
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
? print_intmax
: LONG < LONG_LONG && LONG_LONG < INTMAX && size_spec == LONG_LONG
? print_long_long
- : (affirm (false), (print_function_type) nullptr));
+ : (affirm (false), (print_function_type) NULL));
break;
case 'f':
do
{
input_filename = *file_list;
- if (input_filename == nullptr)
+ if (input_filename == NULL)
return ok;
++file_list;
else
{
in_stream = fopen (input_filename, (O_BINARY ? "rb" : "r"));
- if (in_stream == nullptr)
+ if (in_stream == NULL)
{
error (0, errno, "%s", quotef (input_filename));
ok = false;
}
}
}
- while (in_stream == nullptr);
+ while (in_stream == NULL);
if (0 <= end_offset && !flag_dump_strings)
- setvbuf (in_stream, nullptr, _IONBF, 0);
+ setvbuf (in_stream, NULL, _IONBF, 0);
return ok;
}
{
bool ok = true;
- if (in_stream != nullptr)
+ if (in_stream != NULL)
{
if (!ferror (in_stream))
in_errno = 0;
ok = false;
}
- in_stream = nullptr;
+ in_stream = NULL;
}
if (ferror (stdout))
if (n_skip == 0)
return true;
- while (in_stream != nullptr) /* EOF. */
+ while (in_stream != NULL) /* EOF. */
{
struct stat file_stats;
*n_bytes_in_buffer = 0;
- while (in_stream != nullptr) /* EOF. */
+ while (in_stream != NULL) /* EOF. */
{
idx_t n_needed = n - *n_bytes_in_buffer;
idx_t n_read = fread (block + *n_bytes_in_buffer,
return l_c_m;
}
-/* Act like xstrtoimax (NPTR, nullptr, BASE, VAL, VALID_SUFFIXES),
+/* Act like xstrtoimax (NPTR, NULL, BASE, VAL, VALID_SUFFIXES),
except reject negative values, and *VAL may be set if
LONGINT_INVALID is returned. */
static strtol_error
xstr2nonneg (char const *restrict nptr, int base, intmax_t *val,
char const *restrict valid_suffixes)
{
- strtol_error s_err = xstrtoimax (nptr, nullptr, base, val, valid_suffixes);
+ strtol_error s_err = xstrtoimax (nptr, NULL, base, val, valid_suffixes);
return s_err != LONGINT_INVALID && *val < 0 ? LONGINT_INVALID : s_err;
}
it's hexadecimal, else octal. */
char *dot = strchr (s, '.');
if (dot && dot[(dot[1] == 'b' || dot[1] == 'B') + 1])
- dot = nullptr;
+ dot = NULL;
int radix = dot ? 10 : s[0] == '0' && (s[1] == 'x' || s[1] == 'X') ? 16 : 8;
if (dot)
case 'S':
modern = true;
- if (optarg == nullptr)
+ if (optarg == NULL)
string_min = 3;
else
{
case 'w':
modern = true;
- if (optarg == nullptr)
+ if (optarg == NULL)
{
desired_width = 32;
}
/* open the first input file */
ok = open_next_file ();
- if (in_stream == nullptr)
+ if (in_stream == NULL)
goto cleanup;
/* skip over any unwanted header bytes */
ok &= skip (n_bytes_to_skip);
- if (in_stream == nullptr)
+ if (in_stream == NULL)
goto cleanup;
pseudo_offset = (flag_pseudo_start ? pseudo_start - n_bytes_to_skip : 0);
static struct option const longopts[] =
{
- {"serial", no_argument, nullptr, 's'},
- {"delimiters", required_argument, nullptr, 'd'},
- {"zero-terminated", no_argument, nullptr, 'z'},
+ {"serial", no_argument, NULL, 's'},
+ {"delimiters", required_argument, NULL, 'd'},
+ {"zero-terminated", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Set globals delims, delim_lens, and num_delims.
else
{
fileptr[files_open] = fopen (fnamptr[files_open], "r");
- if (fileptr[files_open] == nullptr)
+ if (fileptr[files_open] == NULL)
error (EXIT_FAILURE, errno, "%s", quotef (fnamptr[files_open]));
else if (fileno (fileptr[files_open]) == STDIN_FILENO)
opened_stdin = true;
ok = false;
}
- fileptr[i] = nullptr;
+ fileptr[i] = NULL;
files_open--;
}
else
{
fileptr = fopen (*fnamptr, "r");
- if (fileptr == nullptr)
+ if (fileptr == NULL)
{
error (0, errno, "%s", quotef (*fnamptr));
ok = false;
have_read_stdin = false;
serial_merge = false;
- while ((optc = getopt_long (argc, argv, "d:sz", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "d:sz", longopts, NULL)) != -1)
{
switch (optc)
{
static struct option const longopts[] =
{
- {"portability", no_argument, nullptr, PORTABILITY_OPTION},
+ {"portability", no_argument, NULL, PORTABILITY_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
atexit (close_stdout);
- while ((optc = getopt_long (argc, argv, "+pP", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "+pP", longopts, NULL)) != -1)
{
switch (optc)
{
static struct option const longopts[] =
{
- {"lookup", no_argument, nullptr, LOOKUP_OPTION},
+ {"lookup", no_argument, NULL, LOOKUP_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Count and return the number of ampersands in STR. */
if (include_fullname)
{
struct passwd *pw = getpwnam (ut_user);
- if (pw == nullptr)
+ if (pw == NULL)
/* TRANSLATORS: Real name is unknown; at most 19 characters. */
printf (" %19s", _(" ???"));
else
#ifdef HAVE_STRUCT_XTMP_UT_HOST
if (include_where && utmp_ent->ut_host[0])
{
- char *host = nullptr;
- char *display = nullptr;
+ char *host = NULL;
+ char *display = NULL;
char *ut_host = utmp_ent->ut_host;
/* Look for an X display. */
static void
cat_file (char const *header, char const *home, char const *file)
{
- char *full_name = file_name_concat (home, file, nullptr);
+ char *full_name = file_name_concat (home, file, NULL);
int fd = open (full_name, O_RDONLY);
if (0 <= fd)
printf ("%-28s", name);
printf (_("In real life: "));
- if (pw == nullptr)
+ if (pw == NULL)
{
/* TRANSLATORS: Real name is unknown; no hard limit. */
printf (" %s", _("???\n"));
atexit (close_stdout);
- while ((optc = getopt_long (argc, argv, "sfwiqbhlp", longopts, nullptr))
+ while ((optc = getopt_long (argc, argv, "sfwiqbhlp", longopts, NULL))
!= -1)
{
switch (optc)
static struct option const long_options[] =
{
- {"pages", required_argument, nullptr, PAGES_OPTION},
- {"columns", required_argument, nullptr, COLUMNS_OPTION},
- {"across", no_argument, nullptr, 'a'},
- {"show-control-chars", no_argument, nullptr, 'c'},
- {"double-space", no_argument, nullptr, 'd'},
- {"date-format", required_argument, nullptr, 'D'},
- {"expand-tabs", optional_argument, nullptr, 'e'},
- {"form-feed", no_argument, nullptr, 'f'},
- {"header", required_argument, nullptr, 'h'},
- {"output-tabs", optional_argument, nullptr, 'i'},
- {"join-lines", no_argument, nullptr, 'J'},
- {"length", required_argument, nullptr, 'l'},
- {"merge", no_argument, nullptr, 'm'},
- {"number-lines", optional_argument, nullptr, 'n'},
- {"first-line-number", required_argument, nullptr, 'N'},
- {"indent", required_argument, nullptr, 'o'},
- {"no-file-warnings", no_argument, nullptr, 'r'},
- {"separator", optional_argument, nullptr, 's'},
- {"sep-string", optional_argument, nullptr, 'S'},
- {"omit-header", no_argument, nullptr, 't'},
- {"omit-pagination", no_argument, nullptr, 'T'},
- {"show-nonprinting", no_argument, nullptr, 'v'},
- {"width", required_argument, nullptr, 'w'},
- {"page-width", required_argument, nullptr, 'W'},
+ {"pages", required_argument, NULL, PAGES_OPTION},
+ {"columns", required_argument, NULL, COLUMNS_OPTION},
+ {"across", no_argument, NULL, 'a'},
+ {"show-control-chars", no_argument, NULL, 'c'},
+ {"double-space", no_argument, NULL, 'd'},
+ {"date-format", required_argument, NULL, 'D'},
+ {"expand-tabs", optional_argument, NULL, 'e'},
+ {"form-feed", no_argument, NULL, 'f'},
+ {"header", required_argument, NULL, 'h'},
+ {"output-tabs", optional_argument, NULL, 'i'},
+ {"join-lines", no_argument, NULL, 'J'},
+ {"length", required_argument, NULL, 'l'},
+ {"merge", no_argument, NULL, 'm'},
+ {"number-lines", optional_argument, NULL, 'n'},
+ {"first-line-number", required_argument, NULL, 'N'},
+ {"indent", required_argument, NULL, 'o'},
+ {"no-file-warnings", no_argument, NULL, 'r'},
+ {"separator", optional_argument, NULL, 's'},
+ {"sep-string", optional_argument, NULL, 'S'},
+ {"omit-header", no_argument, NULL, 't'},
+ {"omit-pagination", no_argument, NULL, 'T'},
+ {"show-nonprinting", no_argument, NULL, 'v'},
+ {"width", required_argument, NULL, 'w'},
+ {"page-width", required_argument, NULL, 'W'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
static _Noreturn void
char **file_names;
/* Accumulate the digits of old-style options like -99. */
- char *column_count_string = nullptr;
+ char *column_count_string = NULL;
idx_t n_digits = 0;
idx_t n_alloc = 0;
n_files = 0;
file_names = (argc > 1
? xnmalloc (argc - 1, sizeof (char *))
- : nullptr);
+ : NULL);
while (true)
{
short-named option syntax, e.g., -9, ensure that this
long-name-specified value overrides it. */
free (column_count_string);
- column_count_string = nullptr;
+ column_count_string = NULL;
n_alloc = 0;
break;
}
if (n_files == 0)
{
/* No file arguments specified; read from standard input. */
- print_files (0, nullptr);
+ print_files (0, NULL);
}
else
{
if (*arg)
{
long int tmp_long;
- strtol_error e = xstrtol (arg, nullptr, 10, &tmp_long, "");
+ strtol_error e = xstrtol (arg, NULL, 10, &tmp_long, "");
if (e == LONGINT_OK)
{
if (tmp_long <= 0)
p->name = name;
p->fp = fopen (name, "r");
}
- if (p->fp == nullptr)
+ if (p->fp == NULL)
{
failed_opens = true;
if (!ignore_failed_opens)
static void
init_header (char const *filename, int desc)
{
- char *buf = nullptr;
+ char *buf = NULL;
struct stat st;
struct timespec t;
int ns;
ns = t.tv_nsec;
if (localtime_rz (localtz, &t.tv_sec, &tm))
{
- ptrdiff_t len = nstrftime (nullptr, MIN (PTRDIFF_MAX, SIZE_MAX),
+ ptrdiff_t len = nstrftime (NULL, MIN (PTRDIFF_MAX, SIZE_MAX),
date_format, &tm, localtz, ns);
if (0 <= len)
{
static struct option const longopts[] =
{
- {"null", no_argument, nullptr, '0'},
+ {"null", no_argument, NULL, '0'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
atexit (close_stdout);
int optc;
- while ((optc = getopt_long (argc, argv, "+iu:0", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "+iu:0", longopts, NULL)) != -1)
{
switch (optc)
{
bool ok;
if (optind >= argc)
{
- for (char **env = environ; *env != nullptr; ++env)
+ for (char **env = environ; *env != NULL; ++env)
printf ("%s%c", *env, opt_nul_terminate_output ? '\0' : '\n');
ok = true;
}
print_direc (direc, *ac.f,
have_field_width, field_width,
have_precision, precision,
- ac.curr_arg < argc ? argv[ac.curr_arg] : nullptr);
+ ac.curr_arg < argc ? argv[ac.curr_arg] : NULL);
break;
exit_status = EXIT_SUCCESS;
- posixly_correct = (getenv ("POSIXLY_CORRECT") != nullptr);
+ posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
/* We directly parse options, rather than use parse_long_options, in
order to avoid accepting abbreviations. */
if (streq (argv[1], "--version"))
{
version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
- (char *) nullptr);
+ (char *) NULL);
return EXIT_SUCCESS;
}
}
/* output format */
static bool ignore_case = false; /* fold lower to upper for sorting */
-static char const *break_file = nullptr; /* name of the 'Break chars' file */
-static char const *only_file = nullptr; /* name of the 'Only words' file */
-static char const *ignore_file = nullptr; /* name of the 'Ignore words' file */
+static char const *break_file = NULL; /* name of the 'Break chars' file */
+static char const *only_file = NULL; /* name of the 'Only words' file */
+static char const *ignore_file = NULL; /* name of the 'Ignore words' file */
/* Options that use regular expressions. */
struct regex_data
{ \
regoff_t count; \
count = re_match (&word_regex.pattern, cursor, limit - cursor, \
- 0, nullptr); \
+ 0, NULL); \
if (count == -2) \
matcher_error (); \
cursor += count == -1 ? 1 : count; \
char const *string = regex->string;
char const *message;
- pattern->buffer = nullptr;
+ pattern->buffer = NULL;
pattern->allocated = 0;
pattern->fastmap = regex->fastmap;
- pattern->translate = ignore_case ? folded_chars : nullptr;
+ pattern->translate = ignore_case ? folded_chars : NULL;
message = re_compile_pattern (string, strlen (string), pattern);
if (message)
if (context_regex.string)
{
if (!*context_regex.string)
- context_regex.string = nullptr;
+ context_regex.string = NULL;
}
else if (gnu_extensions && !input_reference)
context_regex.string = "[.?!][]\"')}]*\\($\\|\t\\| \\)[ \t\n]*";
swallow_file_in_memory (file_name, &file_contents);
- table->start = nullptr;
+ table->start = NULL;
table->alloc = 0;
table->length = 0;
if (truncation_string && *truncation_string)
truncation_string_length = strlen (truncation_string);
else
- truncation_string = nullptr;
+ truncation_string = NULL;
if (gnu_extensions)
{
/* No place left for a tail field. */
- tail.start = nullptr;
- tail.end = nullptr;
+ tail.start = NULL;
+ tail.end = NULL;
tail_truncation = false;
}
/* No place left for a head field. */
- head.start = nullptr;
- head.end = nullptr;
+ head.start = NULL;
+ head.end = NULL;
head_truncation = false;
}
line contexts or references are not used, in which case these variables
would never be computed. */
- tail.start = nullptr;
- tail.end = nullptr;
+ tail.start = NULL;
+ tail.end = NULL;
tail_truncation = false;
- head.start = nullptr;
- head.end = nullptr;
+ head.start = NULL;
+ head.end = NULL;
head_truncation = false;
/* Loop over all keyword occurrences. */
/* Long options equivalences. */
static struct option const long_options[] =
{
- {"auto-reference", no_argument, nullptr, 'A'},
- {"break-file", required_argument, nullptr, 'b'},
- {"flag-truncation", required_argument, nullptr, 'F'},
- {"ignore-case", no_argument, nullptr, 'f'},
- {"gap-size", required_argument, nullptr, 'g'},
- {"ignore-file", required_argument, nullptr, 'i'},
- {"macro-name", required_argument, nullptr, 'M'},
- {"only-file", required_argument, nullptr, 'o'},
- {"references", no_argument, nullptr, 'r'},
- {"right-side-refs", no_argument, nullptr, 'R'},
- {"format", required_argument, nullptr, FORMAT_OPTION},
- {"sentence-regexp", required_argument, nullptr, 'S'},
- {"traditional", no_argument, nullptr, 'G'},
- {"typeset-mode", no_argument, nullptr, 't'},
- {"width", required_argument, nullptr, 'w'},
- {"word-regexp", required_argument, nullptr, 'W'},
+ {"auto-reference", no_argument, NULL, 'A'},
+ {"break-file", required_argument, NULL, 'b'},
+ {"flag-truncation", required_argument, NULL, 'F'},
+ {"ignore-case", no_argument, NULL, 'f'},
+ {"gap-size", required_argument, NULL, 'g'},
+ {"ignore-file", required_argument, NULL, 'i'},
+ {"macro-name", required_argument, NULL, 'M'},
+ {"only-file", required_argument, NULL, 'o'},
+ {"references", no_argument, NULL, 'r'},
+ {"right-side-refs", no_argument, NULL, 'R'},
+ {"format", required_argument, NULL, FORMAT_OPTION},
+ {"sentence-regexp", required_argument, NULL, 'S'},
+ {"traditional", no_argument, NULL, 'G'},
+ {"typeset-mode", no_argument, NULL, 't'},
+ {"width", required_argument, NULL, 'w'},
+ {"word-regexp", required_argument, NULL, 'W'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0},
+ {NULL, 0, NULL, 0},
};
static char const *const format_args[] =
{
- "roff", "tex", nullptr
+ "roff", "tex", NULL
};
static enum Format const format_vals[] =
atexit (close_stdout);
while (optchar = getopt_long (argc, argv, "AF:GM:ORS:TW:b:i:fg:o:trw:",
- long_options, nullptr),
+ long_options, NULL),
optchar != EOF)
{
switch (optchar)
case 'g':
{
intmax_t tmp;
- if (! (xstrtoimax (optarg, nullptr, 0, &tmp, "") == LONGINT_OK
+ if (! (xstrtoimax (optarg, NULL, 0, &tmp, "") == LONGINT_OK
&& 0 < tmp && tmp <= IDX_MAX))
error (EXIT_FAILURE, 0, _("invalid gap width: %s"),
quote (optarg));
case 'w':
{
intmax_t tmp;
- if (! (xstrtoimax (optarg, nullptr, 0, &tmp, "") == LONGINT_OK
+ if (! (xstrtoimax (optarg, NULL, 0, &tmp, "") == LONGINT_OK
&& 0 < tmp && tmp <= IDX_MAX))
error (EXIT_FAILURE, 0, _("invalid line width: %s"),
quote (optarg));
word_regex.string = optarg;
unescape_string (optarg);
if (!*word_regex.string)
- word_regex.string = nullptr;
+ word_regex.string = NULL;
break;
case FORMAT_OPTION:
file_line_count = xmalloc (sizeof *file_line_count);
text_buffers = xmalloc (sizeof *text_buffers);
number_input_files = 1;
- input_file_name[0] = nullptr;
+ input_file_name[0] = NULL;
}
else if (gnu_extensions)
{
for (file_index = 0; file_index < number_input_files; file_index++)
{
if (!*argv[optind] || streq (argv[optind], "-"))
- input_file_name[file_index] = nullptr;
+ input_file_name[file_index] = NULL;
else
input_file_name[file_index] = argv[optind];
optind++;
file_line_count = xmalloc (sizeof *file_line_count);
text_buffers = xmalloc (sizeof *text_buffers);
if (!*argv[optind] || streq (argv[optind], "-"))
- input_file_name[0] = nullptr;
+ input_file_name[0] = NULL;
else
input_file_name[0] = argv[optind];
optind++;
{
digest_word_file (ignore_file, &ignore_table);
if (ignore_table.length == 0)
- ignore_file = nullptr;
+ ignore_file = NULL;
}
if (only_file)
{
digest_word_file (only_file, &only_table);
if (only_table.length == 0)
- only_file = nullptr;
+ only_file = NULL;
}
/* Prepare to study all the input files. */
static struct option const longopts[] =
{
- {"logical", no_argument, nullptr, 'L'},
- {"physical", no_argument, nullptr, 'P'},
+ {"logical", no_argument, NULL, 'L'},
+ {"physical", no_argument, NULL, 'P'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
idx_t n_free = p->start - p->buf;
if (n_free < 1 + s_len)
{
- /* Call xpalloc with nullptr not p->buf, since with the latter
+ /* Call xpalloc with NULL not p->buf, since with the latter
we'd end up copying the data twice: once via realloc, then again
- to align it with the end of the new buffer. By passing nullptr we
+ to align it with the end of the new buffer. By passing NULL we
copy it only once. */
idx_t n_used = p->n_alloc - n_free;
- char *buf = xpalloc (nullptr, &p->n_alloc, 1 + s_len - n_free, -1, 1);
+ char *buf = xpalloc (NULL, &p->n_alloc, 1 + s_len - n_free, -1, 1);
p->start = memcpy (buf + p->n_alloc - n_free, p->start, n_used);
free (p->buf);
p->buf = buf;
size_t parent_height)
{
DIR *dirp = opendir ("..");
- if (dirp == nullptr)
+ if (dirp == NULL)
error (EXIT_FAILURE, errno, _("cannot open directory %s"),
quote (nth_parent (parent_height)));
struct dirent const *dp;
errno = 0;
- if ((dp = readdir_ignoring_dot_and_dotdot (dirp)) == nullptr)
+ if ((dp = readdir_ignoring_dot_and_dotdot (dirp)) == NULL)
{
if (errno)
{
errno = e;
/* Arrange to give a diagnostic after exiting this loop. */
- dirp = nullptr;
+ dirp = NULL;
}
break;
}
}
}
- if (dirp == nullptr || closedir (dirp) != 0)
+ if (dirp == NULL || closedir (dirp) != 0)
{
/* Note that this diagnostic serves for both readdir
and closedir failures. */
struct dev_ino dev_ino_buf;
struct dev_ino *root_dev_ino = get_root_dev_ino (&dev_ino_buf);
- if (root_dev_ino == nullptr)
+ if (root_dev_ino == NULL)
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
quoteaf ("/"));
/* Return PWD from the environment if it is acceptable for 'pwd -L'
- output, otherwise nullptr. */
+ output, otherwise NULL. */
static char const *
logical_getcwd (void)
{
/* Textual validation first. */
if (!wd || wd[0] != '/')
- return nullptr;
+ return NULL;
char const *p = wd;
while ((p = strstr (p, "/.")))
{
if (!p[2] || p[2] == '/'
|| (p[2] == '.' && (!p[3] || p[3] == '/')))
- return nullptr;
+ return NULL;
p++;
}
struct stat st2;
if (stat (wd, &st1) == 0 && stat (".", &st2) == 0 && psame_inode (&st1, &st2))
return wd;
- return nullptr;
+ return NULL;
}
/* POSIX requires a default of -L, but most scripts expect -P.
Currently shells default to -L, while stand-alone
pwd implementations default to -P. */
- bool logical = (getenv ("POSIXLY_CORRECT") != nullptr);
+ bool logical = (getenv ("POSIXLY_CORRECT") != NULL);
initialize_main (&argc, &argv);
set_program_name (argv[0]);
while (true)
{
- int c = getopt_long (argc, argv, "LP", longopts, nullptr);
+ int c = getopt_long (argc, argv, "LP", longopts, NULL);
if (c == -1)
break;
switch (c)
}
char *wd = xgetcwd ();
- if (wd != nullptr)
+ if (wd != NULL)
{
puts (wd);
free (wd);
static struct option const longopts[] =
{
- {"canonicalize", no_argument, nullptr, 'f'},
- {"canonicalize-existing", no_argument, nullptr, 'e'},
- {"canonicalize-missing", no_argument, nullptr, 'm'},
- {"no-newline", no_argument, nullptr, 'n'},
- {"quiet", no_argument, nullptr, 'q'},
- {"silent", no_argument, nullptr, 's'},
- {"verbose", no_argument, nullptr, 'v'},
- {"zero", no_argument, nullptr, 'z'},
+ {"canonicalize", no_argument, NULL, 'f'},
+ {"canonicalize-existing", no_argument, NULL, 'e'},
+ {"canonicalize-missing", no_argument, NULL, 'm'},
+ {"no-newline", no_argument, NULL, 'n'},
+ {"quiet", no_argument, NULL, 'q'},
+ {"silent", no_argument, NULL, 's'},
+ {"verbose", no_argument, NULL, 'v'},
+ {"zero", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
atexit (close_stdout);
- while ((optc = getopt_long (argc, argv, "efmnqsvz", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "efmnqsvz", longopts, NULL)) != -1)
{
switch (optc)
{
/* POSIX requires a diagnostic message written to standard error and a
non-zero exit status when given a file that is not a symbolic link. */
- if (getenv ("POSIXLY_CORRECT") != nullptr)
+ if (getenv ("POSIXLY_CORRECT") != NULL)
verbose = true;
for (; optind < argc; ++optind)
static struct option const longopts[] =
{
- {"canonicalize", no_argument, nullptr, 'E'},
- {"canonicalize-existing", no_argument, nullptr, 'e'},
- {"canonicalize-missing", no_argument, nullptr, 'm'},
- {"relative-to", required_argument, nullptr, RELATIVE_TO_OPTION},
- {"relative-base", required_argument, nullptr, RELATIVE_BASE_OPTION},
- {"quiet", no_argument, nullptr, 'q'},
- {"strip", no_argument, nullptr, 's'},
- {"no-symlinks", no_argument, nullptr, 's'},
- {"zero", no_argument, nullptr, 'z'},
- {"logical", no_argument, nullptr, 'L'},
- {"physical", no_argument, nullptr, 'P'},
+ {"canonicalize", no_argument, NULL, 'E'},
+ {"canonicalize-existing", no_argument, NULL, 'e'},
+ {"canonicalize-missing", no_argument, NULL, 'm'},
+ {"relative-to", required_argument, NULL, RELATIVE_TO_OPTION},
+ {"relative-base", required_argument, NULL, RELATIVE_BASE_OPTION},
+ {"quiet", no_argument, NULL, 'q'},
+ {"strip", no_argument, NULL, 's'},
+ {"no-symlinks", no_argument, NULL, 's'},
+ {"zero", no_argument, NULL, 'z'},
+ {"logical", no_argument, NULL, 'L'},
+ {"physical", no_argument, NULL, 'P'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
if (!can_relative_to
|| (can_relative_base && !path_prefix (can_relative_base, can_fname))
- || (can_relative_to && !relpath (can_fname, can_relative_to, nullptr, 0)))
+ || (can_relative_to && !relpath (can_fname, can_relative_to, NULL, 0)))
fputs (can_fname, stdout);
putchar (use_nuls ? '\0' : '\n');
{
bool ok = true;
int can_mode = CAN_ALL_BUT_LAST;
- char const *relative_to = nullptr;
- char const *relative_base = nullptr;
+ char const *relative_to = NULL;
+ char const *relative_base = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
while (true)
{
- int c = getopt_long (argc, argv, "EeLmPqsz", longopts, nullptr);
+ int c = getopt_long (argc, argv, "EeLmPqsz", longopts, NULL);
if (c == -1)
break;
switch (c)
{
free (base);
can_relative_base = can_relative_to;
- can_relative_to = nullptr;
+ can_relative_to = NULL;
}
}
if (x->preserve_all_root)
{
bool failed = false;
- char *parent = file_name_concat (ent->fts_accpath, "..", nullptr);
+ char *parent = file_name_concat (ent->fts_accpath, "..", NULL);
struct stat statbuf;
if (!parent || lstat (parent, &statbuf))
if (x->one_file_system)
bit_flags |= FTS_XDEV;
- FTS *fts = xfts_open (file, bit_flags, nullptr);
+ FTS *fts = xfts_open (file, bit_flags, NULL);
while (true)
{
FTSENT *ent;
ent = fts_read (fts);
- if (ent == nullptr)
+ if (ent == NULL)
{
if (errno != 0)
{
static struct option const long_opts[] =
{
- {"force", no_argument, nullptr, 'f'},
- {"interactive", optional_argument, nullptr, INTERACTIVE_OPTION},
+ {"force", no_argument, NULL, 'f'},
+ {"interactive", optional_argument, NULL, INTERACTIVE_OPTION},
- {"one-file-system", no_argument, nullptr, ONE_FILE_SYSTEM},
- {"no-preserve-root", no_argument, nullptr, NO_PRESERVE_ROOT},
- {"preserve-root", optional_argument, nullptr, PRESERVE_ROOT},
+ {"one-file-system", no_argument, NULL, ONE_FILE_SYSTEM},
+ {"no-preserve-root", no_argument, NULL, NO_PRESERVE_ROOT},
+ {"preserve-root", optional_argument, NULL, PRESERVE_ROOT},
/* This is solely for testing. Do not document. */
/* It is relatively difficult to ensure that there is a tty on stdin.
Since rm acts differently depending on that, without this option,
it'd be harder to test the parts of rm that depend on that setting. */
- {"-presume-input-tty", no_argument, nullptr, PRESUME_INPUT_TTY_OPTION},
+ {"-presume-input-tty", no_argument, NULL, PRESUME_INPUT_TTY_OPTION},
- {"recursive", no_argument, nullptr, 'r'},
- {"dir", no_argument, nullptr, 'd'},
- {"verbose", no_argument, nullptr, 'v'},
+ {"recursive", no_argument, NULL, 'r'},
+ {"dir", no_argument, NULL, 'd'},
+ {"verbose", no_argument, NULL, 'v'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
static char const *const interactive_args[] =
{
"never", "no", "none",
"once",
- "always", "yes", nullptr
+ "always", "yes", NULL
};
static enum interactive_type const interactive_types[] =
{
x->one_file_system = false;
x->remove_empty_directories = false;
x->recursive = false;
- x->root_dev_ino = nullptr;
+ x->root_dev_ino = NULL;
x->preserve_all_root = false;
x->stdin_tty = isatty (STDIN_FILENO);
x->verbose = false;
/* Try to disable the ability to unlink a directory. */
priv_set_remove_linkdir ();
- while ((c = getopt_long (argc, argv, "dfirvIR", long_opts, nullptr)) != -1)
+ while ((c = getopt_long (argc, argv, "dfirvIR", long_opts, NULL)) != -1)
{
switch (c)
{
{
static struct dev_ino dev_ino_buf;
x.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
- if (x.root_dev_ino == nullptr)
+ if (x.root_dev_ino == NULL)
error (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
quoteaf ("/"));
}
{
/* Don't name this '--force' because it's not close enough in meaning
to e.g. rm's -f option. */
- {"ignore-fail-on-non-empty", no_argument, nullptr,
+ {"ignore-fail-on-non-empty", no_argument, NULL,
IGNORE_FAIL_ON_NON_EMPTY_OPTION},
- {"path", no_argument, nullptr, 'p'}, /* Deprecated. */
- {"parents", no_argument, nullptr, 'p'},
- {"verbose", no_argument, nullptr, 'v'},
+ {"path", no_argument, NULL, 'p'}, /* Deprecated. */
+ {"parents", no_argument, NULL, 'p'},
+ {"verbose", no_argument, NULL, 'v'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Return true if ERROR_NUMBER is one of the values associated
while (true)
{
char *slash = strrchr (dir, '/');
- if (slash == nullptr)
+ if (slash == NULL)
break;
/* Remove any characters after the slash, skipping any extra
slashes in a row. */
remove_empty_parents = false;
int optc;
- while ((optc = getopt_long (argc, argv, "pv", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "pv", longopts, NULL)) != -1)
{
switch (optc)
{
static struct option const long_options[] =
{
- {"role", required_argument, nullptr, 'r'},
- {"type", required_argument, nullptr, 't'},
- {"user", required_argument, nullptr, 'u'},
- {"range", required_argument, nullptr, 'l'},
- {"compute", no_argument, nullptr, 'c'},
+ {"role", required_argument, NULL, 'r'},
+ {"type", required_argument, NULL, 't'},
+ {"user", required_argument, NULL, 'u'},
+ {"range", required_argument, NULL, 'l'},
+ {"compute", no_argument, NULL, 'c'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
int
main (int argc, char **argv)
{
- char *role = nullptr;
- char *range = nullptr;
- char *user = nullptr;
- char *type = nullptr;
- char *context = nullptr;
- char *cur_context = nullptr;
- char *file_context = nullptr;
- char *new_context = nullptr;
+ char *role = NULL;
+ char *range = NULL;
+ char *user = NULL;
+ char *type = NULL;
+ char *context = NULL;
+ char *cur_context = NULL;
+ char *file_context = NULL;
+ char *new_context = NULL;
bool compute_trans = false;
context_t con;
if (setexeccon (context_str (con)) != 0)
error (EXIT_CANCELED, errno, _("unable to set security context %s"),
quote (context_str (con)));
- if (cur_context != nullptr)
+ if (cur_context != NULL)
freecon (cur_context);
(compute_trans ? execv : execvp) (argv[optind], argv + optind);
static int
computecon_raw (char const *path, mode_t mode, char **con)
{
- char *scon_raw = nullptr;
- char *tcon_raw = nullptr;
+ char *scon_raw = NULL;
+ char *tcon_raw = NULL;
security_class_t tclass;
int rc = -1;
char const *path, mode_t mode)
{
int rc = -1;
- char *scon_raw = nullptr;
- char *tcon_raw = nullptr;
+ char *scon_raw = NULL;
+ char *tcon_raw = NULL;
context_t scontext = NULL, tcontext = NULL;
char const *contype;
char const *constr;
- char *newpath = nullptr;
+ char *newpath = NULL;
if (! IS_ABSOLUTE_FILE_NAME (path))
{
{
int rc = -1;
struct stat sb;
- char *scon_raw = nullptr;
- char *tcon_raw = nullptr;
+ char *scon_raw = NULL;
+ char *tcon_raw = NULL;
context_t scontext = NULL, tcontext = NULL;
char const *contype;
char const *constr;
restorecon (struct selabel_handle *selabel_handle,
char const *path, bool recurse)
{
- char *newpath = nullptr;
+ char *newpath = NULL;
if (! IS_ABSOLUTE_FILE_NAME (path))
{
return ok;
}
- char const *ftspath[2] = { path, nullptr };
- FTS *fts = xfts_open ((char *const *) ftspath, FTS_PHYSICAL, nullptr);
+ char const *ftspath[2] = { path, NULL };
+ FTS *fts = xfts_open ((char *const *) ftspath, FTS_PHYSICAL, NULL);
int err = 0;
for (FTSENT *ent; (ent = fts_read (fts)); )
static struct option const long_options[] =
{
- { "equal-width", no_argument, nullptr, 'w'},
- { "format", required_argument, nullptr, 'f'},
- { "separator", required_argument, nullptr, 's'},
+ { "equal-width", no_argument, NULL, 'w'},
+ { "format", required_argument, NULL, 'f'},
+ { "separator", required_argument, NULL, 's'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- { nullptr, 0, nullptr, 0}
+ { NULL, 0, NULL, 0}
};
void
{
operand ret;
- if (! xstrtold (arg, nullptr, &ret.value, cl_strtold))
+ if (! xstrtold (arg, NULL, &ret.value, cl_strtold))
{
error (0, 0, _("invalid floating point argument: %s"), quote (arg));
usage (EXIT_FAILURE);
e = strchr (arg, 'E');
if (e)
{
- long exponent = MAX (strtol (e + 1, nullptr, 10), -LONG_MAX);
+ long exponent = MAX (strtol (e + 1, NULL, 10), -LONG_MAX);
ret.precision += exponent < 0 ? -exponent
: - MIN (ret.precision, exponent);
/* Don't account for e.... in the width since this is not output. */
xalloc_die ();
x_str[x_strlen - layout.suffix_len] = '\0';
- if (xstrtold (x_str + layout.prefix_len, nullptr,
+ if (xstrtold (x_str + layout.prefix_len, NULL,
&x_val, cl_strtold)
&& x_val == last)
{
- char *x0_str = nullptr;
+ char *x0_str = NULL;
int x0_strlen = asprintf (&x0_str, fmt, x0);
if (x0_strlen < 0)
xalloc_die ();
/* Grow number buffer if needed for the inf case. */
if (p == p0)
{
- char *new_p0 = xpalloc (nullptr, &inc_size, 1, -1, 1);
+ char *new_p0 = xpalloc (NULL, &inc_size, 1, -1, 1);
idx_t saved_p_len = endp - p;
endp = new_p0 + inc_size;
p = memcpy (endp - saved_p_len, p0, saved_p_len);
struct layout layout = { 0, 0 };
/* The printf(3) format used for output. */
- char const *format_str = nullptr;
+ char const *format_str = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
break;
}
- optc = getopt_long (argc, argv, "+f:s:w", long_options, nullptr);
+ optc = getopt_long (argc, argv, "+f:s:w", long_options, NULL);
if (optc == -1)
break;
if (format_str)
format_str = long_double_format (format_str, &layout);
- if (format_str != nullptr && equal_width)
+ if (format_str != NULL && equal_width)
{
error (0, 0, _("format string may not be specified"
" when printing equal width strings"));
bool fast_step_ok = false;
if (n_args != 3
|| (all_digits_p (argv[optind + 1])
- && xstrtold (argv[optind + 1], nullptr, &step.value, cl_strtold)
+ && xstrtold (argv[optind + 1], NULL, &step.value, cl_strtold)
&& 0 < step.value && step.value <= SEQ_FAST_STEP_LIMIT))
fast_step_ok = true;
/* Upon any failure, let the more general code deal with it. */
}
- if (format_str == nullptr)
+ if (format_str == NULL)
format_str = get_default_format (first, step, last);
print_numbers (format_str, layout, first.value, step.value, last.value);
struct field_range_pair *c = frp;
idx_t n = n_frp;
- frp = nullptr;
+ frp = NULL;
n_frp = 0;
n_frp_allocated = 0;
static char const *const remove_args[] =
{
- "unlink", "wipe", "wipesync", nullptr
+ "unlink", "wipe", "wipesync", NULL
};
static enum remove_method const remove_methods[] =
static struct option const long_opts[] =
{
- {"exact", no_argument, nullptr, 'x'},
- {"force", no_argument, nullptr, 'f'},
- {"iterations", required_argument, nullptr, 'n'},
- {"size", required_argument, nullptr, 's'},
- {"random-source", required_argument, nullptr, RANDOM_SOURCE_OPTION},
- {"remove", optional_argument, nullptr, 'u'},
- {"verbose", no_argument, nullptr, 'v'},
- {"zero", no_argument, nullptr, 'z'},
+ {"exact", no_argument, NULL, 'x'},
+ {"force", no_argument, NULL, 'f'},
+ {"iterations", required_argument, NULL, 'n'},
+ {"size", required_argument, NULL, 's'},
+ {"random-source", required_argument, NULL, RANDOM_SOURCE_OPTION},
+ {"remove", optional_argument, NULL, 'u'},
+ {"verbose", no_argument, NULL, 'v'},
+ {"zero", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
char **file;
int n_files;
int c;
- char const *random_source = nullptr;
+ char const *random_source = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
flags.n_iterations = DEFAULT_PASSES;
flags.size = -1;
- while ((c = getopt_long (argc, argv, "fn:s:uvxz", long_opts, nullptr)) != -1)
+ while ((c = getopt_long (argc, argv, "fn:s:uvxz", long_opts, NULL)) != -1)
{
switch (c)
{
break;
case 'u':
- if (optarg == nullptr)
+ if (optarg == NULL)
flags.remove_file = remove_wipesync;
else
flags.remove_file = XARGMATCH ("--remove", optarg,
static struct option const long_opts[] =
{
- {"echo", no_argument, nullptr, 'e'},
- {"input-range", required_argument, nullptr, 'i'},
- {"head-count", required_argument, nullptr, 'n'},
- {"output", required_argument, nullptr, 'o'},
- {"random-source", required_argument, nullptr, RANDOM_SOURCE_OPTION},
- {"repeat", no_argument, nullptr, 'r'},
- {"zero-terminated", no_argument, nullptr, 'z'},
+ {"echo", no_argument, NULL, 'e'},
+ {"input-range", required_argument, NULL, 'i'},
+ {"head-count", required_argument, NULL, 'n'},
+ {"output", required_argument, NULL, 'o'},
+ {"random-source", required_argument, NULL, RANDOM_SOURCE_OPTION},
+ {"repeat", no_argument, NULL, 'r'},
+ {"zero-terminated", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
{NULL, 0, NULL, 0},
{
randint n_lines = 0;
idx_t n_alloc_lines = 0;
- struct linebuffer *line = nullptr;
- struct linebuffer *rsrv = nullptr;
+ struct linebuffer *line = NULL;
+ struct linebuffer *rsrv = NULL;
/* Fill the first K lines, directly into the reservoir. */
for (n_lines = 0; n_lines < k; n_lines++)
}
/* last line wasn't null - so there may be more lines to read. */
- if (line != nullptr)
+ if (line != NULL)
{
struct linebuffer dummy;
initbuffer (&dummy); /* space for lines not put in reservoir. */
randint j = randint_choose (s, n_lines + 1); /* 0 .. n_lines. */
line = (j < k) ? (&rsrv[j]) : (&dummy);
}
- while (readlinebuffer_delim (line, in, eolbyte) != nullptr && n_lines++);
+ while (readlinebuffer_delim (line, in, eolbyte) != NULL && n_lines++);
if (! n_lines)
error (EXIT_FAILURE, EOVERFLOW, _("too many input lines"));
read_input (FILE *in, char eolbyte, char ***pline)
{
char *p;
- char *buf = nullptr;
+ char *buf = NULL;
size_t used;
char *lim;
char **line;
size_t lo_input = SIZE_MAX;
size_t hi_input = 0;
idx_t head_lines = MIN (IDX_MAX, SIZE_MAX);
- char const *outfile = nullptr;
- char *random_source = nullptr;
+ char const *outfile = NULL;
+ char *random_source = NULL;
char eolbyte = '\n';
- char **input_lines = nullptr;
+ char **input_lines = NULL;
bool use_reservoir_sampling = false;
bool repeat = false;
int n_operands;
char **operand;
size_t n_lines;
- char **line = nullptr;
- struct linebuffer *reservoir = nullptr;
+ char **line = NULL;
+ struct linebuffer *reservoir = NULL;
struct randint_source *randint_source;
- size_t *permutation = nullptr;
+ size_t *permutation = NULL;
int i;
initialize_main (&argc, &argv);
atexit (close_stdout);
- while ((optc = getopt_long (argc, argv, "ei:n:o:rz", long_opts, nullptr))
+ while ((optc = getopt_long (argc, argv, "ei:n:o:rz", long_opts, NULL))
!= -1)
switch (optc)
{
uintmax_t u;
char *lo_end;
- strtol_error err = xstrtoumax (optarg, &lo_end, 10, &u, nullptr);
+ strtol_error err = xstrtoumax (optarg, &lo_end, 10, &u, NULL);
if (err == LONGINT_OK)
{
lo_input = u;
err = LONGINT_INVALID;
else
{
- err = xstrtoumax (lo_end + 1, nullptr, 10, &u, "");
+ err = xstrtoumax (lo_end + 1, NULL, 10, &u, "");
if (err == LONGINT_OK)
{
hi_input = u;
case 'n':
{
uintmax_t argval;
- strtol_error e = xstrtoumax (optarg, nullptr, 10, &argval, "");
+ strtol_error e = xstrtoumax (optarg, NULL, 10, &argval, "");
if (e == LONGINT_OK)
head_lines = MIN (head_lines, argval);
if (head_lines == 0)
{
n_lines = 0;
- line = nullptr;
+ line = NULL;
}
else if (echo)
{
else if (input_range)
{
IF_LINT (n_lines = hi_input - lo_input + 1); /* Avoid GCC 10 warning. */
- line = nullptr;
+ line = NULL;
}
else
{
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
Version, true, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
if (argc == 1)
{
{
for (struct tempnode const *node = temphead; node; node = node->next)
unlink (node->name);
- temphead = nullptr;
+ temphead = NULL;
}
/* Handle interrupts and hangups. */
static struct option const long_options[] =
{
- {"ignore-leading-blanks", no_argument, nullptr, 'b'},
- {"check", optional_argument, nullptr, CHECK_OPTION},
- {"compress-program", required_argument, nullptr, COMPRESS_PROGRAM_OPTION},
- {"debug", no_argument, nullptr, DEBUG_PROGRAM_OPTION},
- {"dictionary-order", no_argument, nullptr, 'd'},
- {"ignore-case", no_argument, nullptr, 'f'},
- {"files0-from", required_argument, nullptr, FILES0_FROM_OPTION},
- {"general-numeric-sort", no_argument, nullptr, 'g'},
- {"ignore-nonprinting", no_argument, nullptr, 'i'},
- {"key", required_argument, nullptr, 'k'},
- {"merge", no_argument, nullptr, 'm'},
- {"month-sort", no_argument, nullptr, 'M'},
- {"numeric-sort", no_argument, nullptr, 'n'},
- {"human-numeric-sort", no_argument, nullptr, 'h'},
- {"version-sort", no_argument, nullptr, 'V'},
- {"random-sort", no_argument, nullptr, 'R'},
- {"random-source", required_argument, nullptr, RANDOM_SOURCE_OPTION},
- {"sort", required_argument, nullptr, SORT_OPTION},
- {"output", required_argument, nullptr, 'o'},
- {"reverse", no_argument, nullptr, 'r'},
- {"stable", no_argument, nullptr, 's'},
- {"batch-size", required_argument, nullptr, NMERGE_OPTION},
- {"buffer-size", required_argument, nullptr, 'S'},
- {"field-separator", required_argument, nullptr, 't'},
- {"temporary-directory", required_argument, nullptr, 'T'},
- {"unique", no_argument, nullptr, 'u'},
- {"zero-terminated", no_argument, nullptr, 'z'},
- {"parallel", required_argument, nullptr, PARALLEL_OPTION},
+ {"ignore-leading-blanks", no_argument, NULL, 'b'},
+ {"check", optional_argument, NULL, CHECK_OPTION},
+ {"compress-program", required_argument, NULL, COMPRESS_PROGRAM_OPTION},
+ {"debug", no_argument, NULL, DEBUG_PROGRAM_OPTION},
+ {"dictionary-order", no_argument, NULL, 'd'},
+ {"ignore-case", no_argument, NULL, 'f'},
+ {"files0-from", required_argument, NULL, FILES0_FROM_OPTION},
+ {"general-numeric-sort", no_argument, NULL, 'g'},
+ {"ignore-nonprinting", no_argument, NULL, 'i'},
+ {"key", required_argument, NULL, 'k'},
+ {"merge", no_argument, NULL, 'm'},
+ {"month-sort", no_argument, NULL, 'M'},
+ {"numeric-sort", no_argument, NULL, 'n'},
+ {"human-numeric-sort", no_argument, NULL, 'h'},
+ {"version-sort", no_argument, NULL, 'V'},
+ {"random-sort", no_argument, NULL, 'R'},
+ {"random-source", required_argument, NULL, RANDOM_SOURCE_OPTION},
+ {"sort", required_argument, NULL, SORT_OPTION},
+ {"output", required_argument, NULL, 'o'},
+ {"reverse", no_argument, NULL, 'r'},
+ {"stable", no_argument, NULL, 's'},
+ {"batch-size", required_argument, NULL, NMERGE_OPTION},
+ {"buffer-size", required_argument, NULL, 'S'},
+ {"field-separator", required_argument, NULL, 't'},
+ {"temporary-directory", required_argument, NULL, 'T'},
+ {"unique", no_argument, NULL, 'u'},
+ {"zero-terminated", no_argument, NULL, 'z'},
+ {"parallel", required_argument, NULL, PARALLEL_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0},
+ {NULL, 0, NULL, 0},
};
#define CHECK_TABLE \
static char const *const check_args[] =
{
#define _ct_(_s, _c) _s,
- CHECK_TABLE nullptr
+ CHECK_TABLE NULL
#undef _ct_
};
static char const check_types[] =
static char const *const sort_args[] =
{
#define _st_(_s, _c) _s,
- SORT_TABLE nullptr
+ SORT_TABLE NULL
#undef _st_
};
static char const sort_types[] =
if (status->valid)
{
/* Ignore failure when restoring the signal mask. */
- pthread_sigmask (SIG_SETMASK, &status->sigs, nullptr);
+ pthread_sigmask (SIG_SETMASK, &status->sigs, NULL);
}
}
{
if (! proctab)
{
- proctab = hash_initialize (INIT_PROCTAB_SIZE, nullptr,
+ proctab = hash_initialize (INIT_PROCTAB_SIZE, NULL,
proctab_hasher,
proctab_comparator,
- nullptr);
+ NULL);
if (! proctab)
xalloc_die ();
}
/* Create a new temporary file, returning its newly allocated tempnode.
Store into *PFD the file descriptor open for writing.
- If the creation fails, return nullptr and store -1 into *PFD if the
+ If the creation fails, return NULL and store -1 into *PFD if the
failure is due to file descriptor exhaustion and
SURVIVE_FD_EXHAUSTION; otherwise, die. */
memcpy (file, temp_dir, len);
memcpy (file + len, slashbase, sizeof slashbase);
- node->next = nullptr;
+ node->next = NULL;
if (++temp_dir_index == temp_dir_count)
temp_dir_index = 0;
error (SORT_FAILURE, errno, _("cannot create temporary file in %s"),
quoteaf (temp_dir));
free (node);
- node = nullptr;
+ node = NULL;
}
*pfd = fd;
return node;
}
-/* Return a pointer to stdout status, or nullptr on failure. */
+/* Return a pointer to stdout status, or NULL on failure. */
static struct stat *
get_outstatus (void)
static struct stat outstat;
if (outstat_errno == 0)
outstat_errno = fstat (STDOUT_FILENO, &outstat) == 0 ? -1 : errno;
- return outstat_errno < 0 ? &outstat : nullptr;
+ return outstat_errno < 0 ? &outstat : NULL;
}
/* Return a stream for FILE, opened with mode HOW. If HOW is "w",
truncated unless FILE is null. When opening for input, "-"
means standard input. To avoid confusion, do not return file
descriptors STDIN_FILENO, STDOUT_FILENO, or STDERR_FILENO when
- opening an ordinary FILE. Return nullptr if unsuccessful.
+ opening an ordinary FILE. Return NULL if unsuccessful.
Use fadvise to specify an access pattern for input files.
There are a few hints we could possibly provide,
else
{
int fd = open (file, O_RDONLY | O_CLOEXEC);
- fp = fd < 0 ? nullptr : fdopen (fd, how);
+ fp = fd < 0 ? NULL : fdopen (fd, how);
}
fadvise (fp, FADVISE_SEQUENTIAL);
}
}
/* Look up COMPRESS_PROGRAM in $PATH, and return the resolved program name.
- Upon error, return nullptr with errno set. */
+ Upon error, return NULL with errno set. */
static char const *
get_resolved_compress_program (void)
{
/* Use a cache, to perform the search only once. */
- static char const *resolved_compress_program_cache /* = nullptr */;
+ static char const *resolved_compress_program_cache /* = NULL */;
- if (resolved_compress_program_cache == nullptr)
+ if (resolved_compress_program_cache == NULL)
{
resolved_compress_program_cache =
- find_in_given_path (compress_program, getenv ("PATH"), nullptr, false);
- /* If resolved_compress_program_cache == nullptr, errno is set here. */
+ find_in_given_path (compress_program, getenv ("PATH"), NULL, false);
+ /* If resolved_compress_program_cache == NULL, errno is set here. */
}
return resolved_compress_program_cache;
implementations/emulations of posix_spawn we get only a
generic (fatal) error from the child in that case. */
resolved_compress_program = get_resolved_compress_program ();
- if (resolved_compress_program == nullptr)
+ if (resolved_compress_program == NULL)
return errno;
if ((result = posix_spawnattr_init (&attr)))
char const *const argv[] =
{
resolved_compress_program,
- decompress ? "-d" : nullptr,
- nullptr
+ decompress ? "-d" : NULL,
+ NULL
};
/* At least NMERGE + 1 subprocesses are needed. More could be created, but
if it receives a signal before exec-ing. */
cs_enter (&cs);
saved_temphead = temphead;
- temphead = nullptr;
+ temphead = NULL;
result = posix_spawnp (pid, resolved_compress_program, &actions, &attr,
(char * const *) argv, environ);
/* Create a temporary file and, if asked for, start a compressor
to that file. Set *PFP to the file handle and return
the address of the new temp node. If the creation
- fails, return nullptr if the failure is due to file descriptor
+ fails, return NULL if the failure is due to file descriptor
exhaustion and SURVIVE_FD_EXHAUSTION; otherwise, die. */
static struct tempnode *
int tempfd;
struct tempnode *node = create_temp_file (&tempfd, survive_fd_exhaustion);
if (! node)
- return nullptr;
+ return NULL;
node->state = UNCOMPRESSED;
}
/* Open a compressed temp file and start a decompression process through
- which to filter the input. Return nullptr (setting errno to
+ which to filter the input. Return NULL (setting errno to
EMFILE) if we ran out of file descriptors, and die on any other
kind of failure. */
open_temp (struct tempnode *temp)
{
int tempfd, pipefds[2];
- FILE *fp = nullptr;
+ FILE *fp = NULL;
if (temp->state == UNREAPED)
wait_proc (temp->pid);
tempfd = open (temp->name, O_RDONLY);
if (tempfd < 0)
- return nullptr;
+ return NULL;
pid_t child;
int result = pipe_child (&child, pipefds, tempfd, true,
{
uintmax_t n;
struct rlimit rlimit;
- enum strtol_error e = xstrtoumax (s, nullptr, 10, &n, "");
+ enum strtol_error e = xstrtoumax (s, NULL, 10, &n, "");
/* Try to find out how many file descriptors we'll be able
to open. We need at least nmerge + 3 (STDIN_FILENO,
specify_nthreads (int oi, char c, char const *s)
{
uintmax_t nthreads;
- enum strtol_error e = xstrtoumax (s, nullptr, 10, &nthreads, "");
+ enum strtol_error e = xstrtoumax (s, NULL, 10, &nthreads, "");
if (e == LONGINT_OVERFLOW)
return SIZE_MAX;
if (e != LONGINT_OK)
char stackbuf[4000];
char *buf = stackbuf;
size_t bufsize = sizeof stackbuf;
- void *allocated = nullptr;
+ void *allocated = NULL;
uint32_t dig[2][MD5_DIGEST_SIZE / sizeof (uint32_t)];
struct md5_ctx s[2];
s[0] = s[1] = random_md5_state;
bool a_fits = sizea <= bufsize;
size_t sizeb =
(textb < limb
- ? (xstrxfrm ((a_fits ? buf + sizea : nullptr), textb,
+ ? (xstrxfrm ((a_fits ? buf + sizea : NULL), textb,
(a_fits ? bufsize - sizea : 0))
+ 1)
: 0);
/* Flag global options not copied or specified in any key. */
if (ugkey.ignore && (ugkey.ignore == key->ignore))
- ugkey.ignore = nullptr;
+ ugkey.ignore = NULL;
if (ugkey.translate && (ugkey.translate == key->translate))
- ugkey.translate = nullptr;
+ ugkey.translate = NULL;
ugkey.skipsblanks &= !key->skipsblanks;
ugkey.skipeblanks &= !key->skipeblanks;
ugkey.month &= !key->month;
char enda = ta[tlena];
char endb = tb[tlenb];
- void *allocated = nullptr;
+ void *allocated = NULL;
char stackbuf[4000];
if (ignore || translate)
else if (key->human_numeric)
diff = human_numcompare (ta, tb);
else if (key->month)
- diff = getmonth (ta, nullptr) - getmonth (tb, nullptr);
+ diff = getmonth (ta, NULL) - getmonth (tb, NULL);
else if (key->random)
diff = compare_random (ta, tlena, tb, tlenb);
else if (key->version)
initbuf (&buf, sizeof (struct line),
MAX (merge_buffer_size, sort_size));
- temp.text = nullptr;
+ temp.text = NULL;
while (fillbuf (&buf, fp, file_name))
{
struct buffer *buffer = xnmalloc (nfiles, sizeof *buffer);
/* Input buffers for each file. */
struct line saved; /* Saved line storage for unique check. */
- struct line const *savedline = nullptr;
+ struct line const *savedline = NULL;
/* &saved if there is a saved line. */
size_t savealloc = 0; /* Size allocated for the saved line. */
struct line const **cur = xnmalloc (nfiles, sizeof *cur);
and will be next output. */
size_t t;
struct keyfield const *key = keylist;
- saved.text = nullptr;
+ saved.text = NULL;
/* Read initial lines from each input file. */
for (size_t i = 0; i < nfiles; )
{
if (savedline && compare (savedline, smallest))
{
- savedline = nullptr;
+ savedline = NULL;
write_line (&saved, ofp, output_file);
}
if (!savedline)
struct merge_node *merge_tree = xmalloc (2 * sizeof *merge_tree * nthreads);
struct merge_node *root = merge_tree;
- root->lo = root->hi = root->end_lo = root->end_hi = nullptr;
- root->dest = nullptr;
+ root->lo = root->hi = root->end_lo = root->end_hi = NULL;
+ root->dest = NULL;
root->nlo = root->nhi = nlines;
- root->parent = nullptr;
+ root->parent = NULL;
root->level = MERGE_END;
root->queued = false;
- pthread_mutex_init (&root->lock, nullptr);
+ pthread_mutex_init (&root->lock, NULL);
init_node (root, root + 1, dest, nthreads, nlines, false);
return merge_tree;
node->parent = parent;
node->level = parent->level + 1;
node->queued = false;
- pthread_mutex_init (&node->lock, nullptr);
+ pthread_mutex_init (&node->lock, NULL);
if (nthreads > 1)
{
}
else
{
- node->lo_child = nullptr;
- node->hi_child = nullptr;
+ node->lo_child = NULL;
+ node->hi_child = NULL;
}
return node_pool;
}
time, the heap should accommodate all of them. Counting a null
dummy head for the heap, reserve 2 * NTHREADS nodes. */
queue->priority_queue = heap_alloc (compare_nodes, 2 * nthreads);
- pthread_mutex_init (&queue->mutex, nullptr);
- pthread_cond_init (&queue->cond, nullptr);
+ pthread_mutex_init (&queue->mutex, NULL);
+ pthread_cond_init (&queue->cond, NULL);
}
/* Insert NODE into QUEUE. The caller either holds a lock on NODE, or
sortlines (args->lines, args->nthreads, args->total_lines,
args->node, args->queue, args->tfp,
args->output_temp);
- return nullptr;
+ return NULL;
}
/* Sort lines, possibly in parallel. The arguments are as in struct
node->lo_child, queue, tfp, temp_output};
if (nthreads > 1 && SUBTHREAD_LINES_HEURISTIC <= nlines
- && pthread_create (&thread, nullptr, sortlines_thread, &args) == 0)
+ && pthread_create (&thread, NULL, sortlines_thread, &args) == 0)
{
sortlines (lines - node->nlo, hi_threads, total_lines,
node->hi_child, queue, tfp, temp_output);
- pthread_join (thread, nullptr);
+ pthread_join (thread, NULL);
}
else
{
avoid_trashing_input (struct sortfile *files, size_t ntemps,
size_t nfiles, char const *outfile)
{
- struct tempnode *tempcopy = nullptr;
+ struct tempnode *tempcopy = NULL;
for (size_t i = ntemps; i < nfiles; i++)
{
break;
}
- saved_line.text = nullptr;
+ saved_line.text = NULL;
line = buffer_linelim (&buf);
if (buf.eof && !nfiles && !ntemps && !buf.left)
{
for (p = &keylist; *p; p = &(*p)->next)
continue;
*p = key;
- key->next = nullptr;
+ key->next = NULL;
}
/* Report a bad field specification SPEC, with extra info MSGID. */
/* Parse the leading integer in STRING and store the resulting value
(which must fit into size_t) into *VAL. Return the address of the
suffix after the integer. If the value is too large, silently
- substitute SIZE_MAX. If MSGID is null, return nullptr after
+ substitute SIZE_MAX. If MSGID is null, return NULL after
failure; otherwise, report MSGID and exit on failure. */
static char const *
if (msgid)
error (SORT_FAILURE, 0, _("%s: invalid count at start of %s"),
_(msgid), quote (string));
- return nullptr;
+ return NULL;
}
return suffix;
int c = 0;
char checkonly = 0;
bool mergeonly = false;
- char *random_source = nullptr;
+ char *random_source = NULL;
bool need_random = false;
size_t nthreads = 0;
size_t nfiles = 0;
- bool posixly_correct = (getenv ("POSIXLY_CORRECT") != nullptr);
+ bool posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
int posix_ver = posix2_version ();
bool traditional_usage = ! (200112 <= posix_ver && posix_ver < 200809);
char **files;
- char *files_from = nullptr;
+ char *files_from = NULL;
struct Tokens tok;
- char const *outfile = nullptr;
+ char const *outfile = NULL;
bool locale_ok;
initialize_main (&argc, &argv);
{
if (term_sig[i] == SIGPIPE)
continue; /* Handled below. */
- sigaction (term_sig[i], nullptr, &act);
+ sigaction (term_sig[i], NULL, &act);
if (act.sa_handler != SIG_IGN)
sigaddset (&caught_signals, term_sig[i]);
}
if (term_sig[i] == SIGPIPE)
continue; /* Handled below. */
if (sigismember (&caught_signals, term_sig[i]))
- sigaction (term_sig[i], &act, nullptr);
+ sigaction (term_sig[i], &act, NULL);
}
}
signal (SIGCHLD, SIG_DFL); /* Don't inherit CHLD handling from parent. */
else switch (c)
{
case 1:
- key = nullptr;
+ key = NULL;
if (optarg[0] == '+')
{
bool minus_pos_usage = (optind != argc && argv[optind][0] == '-'
/* Treat +POS1 [-POS2] as a key if possible; but silently
treat an operand as a file if it is not a valid +POS1. */
key = key_init (&key_buf);
- s = parse_field_count (optarg + 1, &key->sword, nullptr);
+ s = parse_field_count (optarg + 1, &key->sword, NULL);
if (s && *s == '.')
- s = parse_field_count (s + 1, &key->schar, nullptr);
+ s = parse_field_count (s + 1, &key->schar, NULL);
if (! (key->sword || key->schar))
key->sword = SIZE_MAX;
if (! s || *set_ordering (s, key, bl_start))
- key = nullptr;
+ key = NULL;
else
{
if (minus_pos_usage)
error (0, 0, "%s", _("failed to set locale"));
if (hard_LC_COLLATE)
error (0, 0, _("text ordering performed using %s sorting rules"),
- quote (setlocale (LC_COLLATE, nullptr)));
+ quote (setlocale (LC_COLLATE, NULL)));
else
error (0, 0, "%s",
_("text ordering performed using simple byte comparison"));
static struct option const longopts[] =
{
- {"bytes", required_argument, nullptr, 'b'},
- {"lines", required_argument, nullptr, 'l'},
- {"line-bytes", required_argument, nullptr, 'C'},
- {"number", required_argument, nullptr, 'n'},
- {"elide-empty-files", no_argument, nullptr, 'e'},
- {"unbuffered", no_argument, nullptr, 'u'},
- {"suffix-length", required_argument, nullptr, 'a'},
- {"additional-suffix", required_argument, nullptr,
+ {"bytes", required_argument, NULL, 'b'},
+ {"lines", required_argument, NULL, 'l'},
+ {"line-bytes", required_argument, NULL, 'C'},
+ {"number", required_argument, NULL, 'n'},
+ {"elide-empty-files", no_argument, NULL, 'e'},
+ {"unbuffered", no_argument, NULL, 'u'},
+ {"suffix-length", required_argument, NULL, 'a'},
+ {"additional-suffix", required_argument, NULL,
ADDITIONAL_SUFFIX_OPTION},
- {"numeric-suffixes", optional_argument, nullptr, 'd'},
- {"hex-suffixes", optional_argument, nullptr, 'x'},
- {"filter", required_argument, nullptr, FILTER_OPTION},
- {"verbose", no_argument, nullptr, VERBOSE_OPTION},
- {"separator", required_argument, nullptr, 't'},
- {"-io-blksize", required_argument, nullptr,
+ {"numeric-suffixes", optional_argument, NULL, 'd'},
+ {"hex-suffixes", optional_argument, NULL, 'x'},
+ {"filter", required_argument, NULL, FILTER_OPTION},
+ {"verbose", no_argument, NULL, VERBOSE_OPTION},
+ {"separator", required_argument, NULL, 't'},
+ {"-io-blksize", required_argument, NULL,
IO_BLKSIZE_OPTION}, /* do not document */
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Return true if the errno value, ERR, is ignorable. */
if (numeric_suffix_start)
{
intmax_t n_start;
- strtol_error e = xstrtoimax (numeric_suffix_start, nullptr, 10,
+ strtol_error e = xstrtoimax (numeric_suffix_start, NULL, 10,
&n_start, "");
if (e == LONGINT_OK && n_start < n_units)
{
copy_to_tmpfile (int fd, char *buf, idx_t bufsize)
{
FILE *tmp;
- if (!temp_stream (&tmp, nullptr))
+ if (!temp_stream (&tmp, NULL))
return -1;
off_t copied = 0;
off_t r;
char const *shell_prog = getenv ("SHELL");
- if (shell_prog == nullptr)
+ if (shell_prog == NULL)
shell_prog = "/bin/sh";
char const *const argv[] = { last_component (shell_prog), "-c",
- filter_command, nullptr };
+ filter_command, NULL };
result = posix_spawn (&child_pid, shell_prog, &actions, &attr,
(char * const *) argv, environ);
static void
closeout (FILE *fp, int fd, pid_t pid, char const *name)
{
- if (fp != nullptr && fclose (fp) != 0 && ! ignorable (errno))
+ if (fp != NULL && fclose (fp) != 0 && ! ignorable (errno))
error (EXIT_FAILURE, errno, "%s", quotef (name));
if (fd >= 0)
{
- if (fp == nullptr && close (fd) < 0)
+ if (fp == NULL && close (fd) < 0)
error (EXIT_FAILURE, errno, "%s", quotef (name));
for (int j = 0; j < n_open_pipes; ++j)
{
{
if (!bp && bytes == 0 && elide_empty_files)
return true;
- closeout (nullptr, output_desc, filter_pid, outfile);
+ closeout (NULL, output_desc, filter_pid, outfile);
next_file_name ();
output_desc = create (outfile);
if (output_desc < 0)
any existing files or notifies any consumers on fifos.
FIXME: Should we do this before EXIT_FAILURE? */
while (opened++ < max_files)
- cwrite (true, nullptr, 0);
+ cwrite (true, NULL, 0);
}
/* Split into pieces of exactly N_LINES lines.
ssize_t n_read;
intmax_t n_out = 0; /* for each split. */
idx_t n_hold = 0;
- char *hold = nullptr; /* for lines > bufsize. */
+ char *hold = NULL; /* for lines > bufsize. */
idx_t hold_size = 0;
bool split_line = false; /* Whether a \n was output in a split. */
while (n_left)
{
idx_t split_rest = 0;
- char *eoc = nullptr;
+ char *eoc = NULL;
char *eol;
/* Determine End Of Chunk and/or End of Line,
if (chunk_end <= n_written)
{
if (! k)
- cwrite (true, nullptr, 0);
+ cwrite (true, NULL, 0);
}
else
next = false;
FIXME: Should we do this before EXIT_FAILURE? */
if (!k)
while (chunk_no++ <= n)
- cwrite (true, nullptr, 0);
+ cwrite (true, NULL, 0);
}
/* -n K/N: Extract Kth of N chunks. */
if (fclose (files[i_reopen].ofile) != 0)
error (EXIT_FAILURE, errno, "%s", quotef (files[i_reopen].of_name));
- files[i_reopen].ofile = nullptr;
+ files[i_reopen].ofile = NULL;
files[i_reopen].ofd = OFD_APPEND;
}
bool wrote = false;
bool file_limit;
idx_t i_file;
- of_t *files IF_LINT (= nullptr);
+ of_t *files IF_LINT (= NULL);
intmax_t line_no;
if (k)
next_file_name ();
files[i_file].of_name = xstrdup (outfile);
files[i_file].ofd = OFD_NEW;
- files[i_file].ofile = nullptr;
+ files[i_file].ofile = NULL;
files[i_file].opid = 0;
}
i_file = 0;
if (fclose (files[i_file].ofile) != 0)
error (EXIT_FAILURE, errno, "%s",
quotef (files[i_file].of_name));
- files[i_file].ofile = nullptr;
+ files[i_file].ofile = NULL;
files[i_file].ofd = OFD_APPEND;
}
if (next && ++i_file == n)
parse_n_units (char const *arg, char const *multipliers, char const *msgid)
{
intmax_t n;
- if (OVERFLOW_OK < xstrtoimax (arg, nullptr, 10, &n, multipliers) || n < 1)
+ if (OVERFLOW_OK < xstrtoimax (arg, NULL, 10, &n, multipliers) || n < 1)
strtoint_die (msgid, arg);
return n;
}
int this_optind = optind ? optind : 1;
c = getopt_long (argc, argv, "0123456789C:a:b:del:n:t:ux",
- longopts, nullptr);
+ longopts, NULL);
if (c == -1)
break;
if (close (STDIN_FILENO) != 0)
error (EXIT_FAILURE, errno, "%s", quotef (infile));
- closeout (nullptr, output_desc, filter_pid, outfile);
+ closeout (NULL, output_desc, filter_pid, outfile);
main_exit (EXIT_SUCCESS);
}
static char const *const cached_args[] =
{
- "default", "never", "always", nullptr
+ "default", "never", "always", NULL
};
static enum cached_mode const cached_modes[] =
static struct option const long_options[] =
{
- {"dereference", no_argument, nullptr, 'L'},
- {"file-system", no_argument, nullptr, 'f'},
- {"format", required_argument, nullptr, 'c'},
- {"printf", required_argument, nullptr, PRINTF_OPTION},
- {"terse", no_argument, nullptr, 't'},
- {"cached", required_argument, nullptr, 0},
+ {"dereference", no_argument, NULL, 'L'},
+ {"file-system", no_argument, NULL, 'f'},
+ {"format", required_argument, NULL, 'c'},
+ {"printf", required_argument, NULL, PRINTF_OPTION},
+ {"terse", no_argument, NULL, 't'},
+ {"cached", required_argument, NULL, 0},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Whether to follow symbolic links; True for --dereference (-L). */
if (c_isdigit (dot[1]))
{
- long int lprec = strtol (dot + 1, nullptr, 10);
+ long int lprec = strtol (dot + 1, NULL, 10);
precision = (lprec <= INT_MAX ? lprec : INT_MAX);
}
else
--p;
while (c_isdigit (p[-1]));
- long int lwidth = strtol (p, nullptr, 10);
+ long int lwidth = strtol (p, NULL, 10);
width = (lwidth <= INT_MAX ? lwidth : INT_MAX);
if (1 < width)
{
{
error (0, errno, _("failed to get security context of %s"),
quoteaf (filename));
- scontext = nullptr;
+ scontext = NULL;
fail = true;
}
strcpy (pformat + prefix_len, "s");
/* Return any bind mounted source for a path.
The caller should not free the returned buffer.
- Return nullptr if no bind mount found. */
+ Return NULL if no bind mount found. */
NODISCARD
static char const *
find_bind_mount (char const * name)
{
- char const * bind_mount = nullptr;
+ char const * bind_mount = NULL;
static struct mount_entry *mount_list;
static bool tried_mount_list = false;
struct stat name_stats;
if (stat (name, &name_stats) != 0)
- return nullptr;
+ return NULL;
for (struct mount_entry *me = mount_list; me; me = me->me_next)
{
const struct stat *statp)
{
- char const *np = "?", *bp = nullptr;
- char *mp = nullptr;
+ char const *np = "?", *bp = NULL;
+ char *mp = NULL;
bool fail = true;
/* Look for bind mounts first. Note we output the immediate alias,
{
int i = ARGMATCH (q_style, quoting_style_args, quoting_style_vals);
if (0 <= i)
- set_quoting_style (nullptr, quoting_style_vals[i]);
+ set_quoting_style (NULL, quoting_style_vals[i]);
else
{
- set_quoting_style (nullptr, shell_escape_always_quoting_style);
+ set_quoting_style (NULL, shell_escape_always_quoting_style);
error (0, 0, _("ignoring invalid value of environment "
"variable QUOTING_STYLE: %s"), quote (q_style));
}
}
else
- set_quoting_style (nullptr, shell_escape_always_quoting_style);
+ set_quoting_style (NULL, shell_escape_always_quoting_style);
}
/* Equivalent to quotearg(), but explicit to avoid syntax checks. */
-#define quoteN(x) quotearg_style (get_quoting_style (nullptr), x)
+#define quoteN(x) quotearg_style (get_quoting_style (NULL), x)
/* Output a single-character \ escape. */
if (S_ISLNK (statbuf->st_mode))
{
char *linkname = areadlink_with_size (filename, statbuf->st_size);
- if (linkname == nullptr)
+ if (linkname == NULL)
{
error (0, errno, _("cannot read symbolic link %s"),
quoteaf (filename));
int c;
bool fs = false;
bool terse = false;
- char *format = nullptr;
+ char *format = NULL;
char *format2;
bool ok = true;
atexit (close_stdout);
- while ((c = getopt_long (argc, argv, "c:fLt", long_options, nullptr)) != -1)
+ while ((c = getopt_long (argc, argv, "c:fLt", long_options, NULL)) != -1)
{
switch (c)
{
static struct option const longopts[] =
{
- {"input", required_argument, nullptr, 'i'},
- {"output", required_argument, nullptr, 'o'},
- {"error", required_argument, nullptr, 'e'},
+ {"input", required_argument, NULL, 'i'},
+ {"output", required_argument, NULL, 'o'},
+ {"error", required_argument, NULL, 'e'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Set size to the value of STR, interpreted as a decimal integer,
parse_size (char const *str, size_t *size)
{
uintmax_t tmp_size;
- enum strtol_error e = xstrtoumax (str, nullptr, 10,
+ enum strtol_error e = xstrtoumax (str, NULL, 10,
&tmp_size, "EGkKMPQRTYZ0");
if (e == LONGINT_OK && SIZE_MAX < tmp_size)
e = LONGINT_OVERFLOW;
else if ((path = getenv ("PATH")))
{
path = xstrdup (path);
- for (char *dir = strtok (path, ":"); dir != nullptr;
- dir = strtok (nullptr, ":"))
+ for (char *dir = strtok (path, ":"); dir != NULL;
+ dir = strtok (NULL, ":"))
{
- char *candidate = file_name_concat (dir, arg, nullptr);
+ char *candidate = file_name_concat (dir, arg, NULL);
if (access (candidate, X_OK) == 0)
{
program_path = dir_name (candidate);
char const *const search_path[] = {
program_path,
PKGLIBEXECDIR,
- nullptr
+ NULL
};
char const *const *path = search_path;
initialize_exit_failure (EXIT_CANCELED);
atexit (close_stdout);
- while ((c = getopt_long (argc, argv, "+i:o:e:", longopts, nullptr)) != -1)
+ while ((c = getopt_long (argc, argv, "+i:o:e:", longopts, NULL)) != -1)
{
int opt_fileno;
{"crt", combination, OMIT, 0, 0},
{"dec", combination, OMIT, 0, 0},
- {nullptr, control, 0, 0, 0}
+ {NULL, control, 0, 0, 0}
};
/* Control character settings. */
/* These must be last because of the display routines. */
{"min", 1, VMIN},
{"time", 0, VTIME},
- {nullptr, 0, 0}
+ {NULL, 0, 0}
};
static char const *visible (cc_t ch);
static struct option const longopts[] =
{
- {"all", no_argument, nullptr, 'a'},
- {"save", no_argument, nullptr, 'g'},
- {"file", required_argument, nullptr, 'F'},
- {"-debug", no_argument, nullptr, DEV_DEBUG_OPTION},
+ {"all", no_argument, NULL, 'a'},
+ {"save", no_argument, NULL, 'g'},
+ {"file", required_argument, NULL, 'F'},
+ {"-debug", no_argument, NULL, DEV_DEBUG_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Print format string MESSAGE and optional args.
tcsetattr_options = reversed ? TCSANOW : TCSADRAIN;
continue;
}
- for (int i = 0; mode_info[i].name != nullptr; ++i)
+ for (int i = 0; mode_info[i].name != NULL; ++i)
{
if (streq (arg, mode_info[i].name))
{
}
if (!match_found)
{
- for (int i = 0; control_info[i].name != nullptr; ++i)
+ for (int i = 0; control_info[i].name != NULL; ++i)
{
if (streq (arg, control_info[i].name))
{
bool verbose_output;
bool recoverable_output;
bool noargs = true;
- char *file_name = nullptr;
+ char *file_name = NULL;
char const *device_name;
initialize_main (&argc, &argv);
short and long options, --, POSIXLY_CORRECT, etc. */
while ((optc = getopt_long (argc - argi, argv + argi, "-agF:",
- longopts, nullptr))
+ longopts, NULL))
!= -1)
{
switch (optc)
/* Clear fully-parsed arguments, so they don't confuse the 2nd pass. */
while (opti < optind)
- argv[argi + opti++] = nullptr;
+ argv[argi + opti++] = NULL;
}
/* Specifying both -a and -g gets an error. */
bitsp = mode_type_flag (info->type, mode);
- if (bitsp == nullptr)
+ if (bitsp == NULL)
{
/* Combination mode. */
if (streq (info->name, "evenp") || streq (info->name, "parity"))
/* Use $COLUMNS if it's in [1..INT_MAX]. */
char *col_string = getenv ("COLUMNS");
long int n_columns;
- if (!(col_string != nullptr
- && xstrtol (col_string, nullptr, 0, &n_columns, "") == LONGINT_OK
+ if (!(col_string != NULL
+ && xstrtol (col_string, NULL, 0, &n_columns, "") == LONGINT_OK
&& 0 < n_columns
&& n_columns <= INT_MAX))
n_columns = 80;
return &mode->c_lflag;
case combination:
- return nullptr;
+ return NULL;
default:
unreachable ();
current_col = 0;
empty_line = true;
- for (int i = 0; mode_info[i].name != nullptr; ++i)
+ for (int i = 0; mode_info[i].name != NULL; ++i)
{
if (mode_info[i].flags & OMIT)
continue;
putchar ('\n');
current_col = 0;
- for (int i = 0; mode_info[i].name != nullptr; ++i)
+ for (int i = 0; mode_info[i].name != NULL; ++i)
{
if (mode_info[i].flags & OMIT)
continue;
mode->c_cc[control_info[i].offset] = control_info[i].saneval;
}
- for (int i = 0; mode_info[i].name != nullptr; ++i)
+ for (int i = 0; mode_info[i].name != NULL; ++i)
{
if (mode_info[i].flags & NO_SETATTR)
continue;
static struct option const long_options[] =
{
- {"data", no_argument, nullptr, 'd'},
- {"file-system", no_argument, nullptr, 'f'},
+ {"data", no_argument, NULL, 'd'},
+ {"file-system", no_argument, NULL, 'f'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
atexit (close_stdout);
int c;
- while ((c = getopt_long (argc, argv, "df", long_options, nullptr))
+ while ((c = getopt_long (argc, argv, "df", long_options, NULL))
!= -1)
{
switch (c)
while (true)
{
struct dirent const *dp = readdir (dirp);
- if (dp == nullptr || ! dot_or_dotdot (dp->d_name))
+ if (dp == NULL || ! dot_or_dotdot (dp->d_name))
return dp;
}
}
return errno;
dirp = fdopendir (fd);
- if (dirp == nullptr)
+ if (dirp == NULL)
{
saved_errno = errno;
close (fd);
};
#define GETOPT_HELP_OPTION_DECL \
- "help", no_argument, nullptr, GETOPT_HELP_CHAR
+ "help", no_argument, NULL, GETOPT_HELP_CHAR
#define GETOPT_VERSION_OPTION_DECL \
- "version", no_argument, nullptr, GETOPT_VERSION_CHAR
+ "version", no_argument, NULL, GETOPT_VERSION_CHAR
#define GETOPT_SELINUX_CONTEXT_OPTION_DECL \
- "context", optional_argument, nullptr, 'Z'
+ "context", optional_argument, NULL, 'Z'
#define case_GETOPT_HELP_CHAR \
case GETOPT_HELP_CHAR: \
#define case_GETOPT_VERSION_CHAR(Program_name, Authors) \
case GETOPT_VERSION_CHAR: \
version_etc (stdout, Program_name, PACKAGE_NAME, Version, Authors, \
- (char *) nullptr); \
+ (char *) NULL); \
exit (EXIT_SUCCESS); \
break;
{ "sha256sum", "sha2 utilities" },
{ "sha384sum", "sha2 utilities" },
{ "sha512sum", "sha2 utilities" },
- { nullptr, nullptr }
+ { NULL, NULL }
};
char const *node = program;
/* Don't output this redundant message for English locales.
Note we still output for 'C' so that it gets included in the man page. */
- char const *lc_messages = setlocale (LC_MESSAGES, nullptr);
+ char const *lc_messages = setlocale (LC_MESSAGES, NULL);
if (lc_messages && STRNCMP_LIT (lc_messages, "en_"))
{
/* TRANSLATORS: Replace LANG_CODE in this URL with your language code
{
char *buf = malloc (BUFFER_SIZE);
- if (buf == nullptr)
+ if (buf == NULL)
{
/* Fall back on the code that relies on a temporary file.
Write all buffers to that file and free them. */
if (!last_byte_is_eol_byte)
{
char *buf = malloc (1);
- if (buf == nullptr)
+ if (buf == NULL)
{
/* FIXME: just like above */
ok = false;
{
for (size_t i = 0; i < x->n_bufs; i++)
free (x->p[i].start);
- obstack_free (OBS, nullptr);
+ obstack_free (OBS, NULL);
}
Line_ptr
static struct option const longopts[] =
{
- {"before", no_argument, nullptr, 'b'},
- {"regex", no_argument, nullptr, 'r'},
- {"separator", required_argument, nullptr, 's'},
+ {"before", no_argument, NULL, 'b'},
+ {"regex", no_argument, NULL, 'r'},
+ {"separator", required_argument, NULL, 's'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
/* Initializer for file_list if no file-arguments
were specified on the command line. */
- static char const *const default_file_list[] = {"-", nullptr};
+ static char const *const default_file_list[] = {"-", NULL};
char const *const *file;
initialize_main (&argc, &argv);
sentinel_length = 1;
separator_ends_record = true;
- while ((optc = getopt_long (argc, argv, "brs:", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "brs:", longopts, NULL)) != -1)
{
switch (optc)
{
if (*separator == 0)
error (EXIT_FAILURE, 0, _("separator cannot be empty"));
- compiled_separator.buffer = nullptr;
+ compiled_separator.buffer = NULL;
compiled_separator.allocated = 0;
compiled_separator.fastmap = compiled_separator_fastmap;
- compiled_separator.translate = nullptr;
+ compiled_separator.translate = NULL;
error_message = re_compile_pattern (separator, strlen (separator),
&compiled_separator);
if (error_message)
}
/* Flush the output buffer. */
- output ((char *) nullptr, (char *) nullptr);
+ output ((char *) NULL, (char *) NULL);
if (have_read_stdin && close (STDIN_FILENO) < 0)
{
static char const *const follow_mode_string[] =
{
- "descriptor", "name", nullptr
+ "descriptor", "name", NULL
};
static enum Follow_mode const follow_mode_map[] =
/* The process IDs of the processes to watch (those writing the followed
files, or perhaps other processes the user cares about). */
static int nbpids = 0;
-static pid_t * pids = nullptr;
+static pid_t * pids = NULL;
static idx_t pids_alloc;
/* Used to determine the buffer size when scanning backwards in a file. */
static struct option const long_options[] =
{
- {"bytes", required_argument, nullptr, 'c'},
- {"debug", no_argument, nullptr, DEBUG_PROGRAM_OPTION},
- {"follow", optional_argument, nullptr, LONG_FOLLOW_OPTION},
- {"lines", required_argument, nullptr, 'n'},
- {"max-unchanged-stats", required_argument, nullptr,
+ {"bytes", required_argument, NULL, 'c'},
+ {"debug", no_argument, NULL, DEBUG_PROGRAM_OPTION},
+ {"follow", optional_argument, NULL, LONG_FOLLOW_OPTION},
+ {"lines", required_argument, NULL, 'n'},
+ {"max-unchanged-stats", required_argument, NULL,
MAX_UNCHANGED_STATS_OPTION},
- {"-disable-inotify", no_argument, nullptr,
+ {"-disable-inotify", no_argument, NULL,
DISABLE_INOTIFY_OPTION}, /* do not document */
- {"pid", required_argument, nullptr, PID_OPTION},
- {"-presume-input-pipe", no_argument, nullptr,
+ {"pid", required_argument, NULL, PID_OPTION},
+ {"-presume-input-pipe", no_argument, NULL,
PRESUME_INPUT_PIPE_OPTION}, /* do not document */
- {"quiet", no_argument, nullptr, 'q'},
- {"retry", no_argument, nullptr, RETRY_OPTION},
- {"silent", no_argument, nullptr, 'q'},
- {"sleep-interval", required_argument, nullptr, 's'},
- {"verbose", no_argument, nullptr, 'v'},
- {"zero-terminated", no_argument, nullptr, 'z'},
+ {"quiet", no_argument, NULL, 'q'},
+ {"retry", no_argument, NULL, RETRY_OPTION},
+ {"silent", no_argument, NULL, 'q'},
+ {"sleep-interval", required_argument, NULL, 's'},
+ {"verbose", no_argument, NULL, 'v'},
+ {"zero-terminated", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
{
char const *nl;
nl = memrchr (buffer, line_end, n);
- if (nl == nullptr)
+ if (nl == NULL)
break;
n = nl - buffer;
if (n_lines-- == 0)
first = last = xmalloc (sizeof (LBUFFER));
first->nbytes = first->nlines = 0;
- first->next = nullptr;
+ first->next = NULL;
tmp = xmalloc (sizeof (LBUFFER));
/* Input is always read into a fresh buffer. */
break;
tmp->nbytes = n_read;
tmp->nlines = 0;
- tmp->next = nullptr;
+ tmp->next = NULL;
/* Count the number of newlines just read. */
{
first = last = xmalloc (sizeof (CBUFFER));
first->nbytes = 0;
- first->next = nullptr;
+ first->next = NULL;
tmp = xmalloc (sizeof (CBUFFER));
/* Input is always read into a fresh buffer. */
break;
read_pos += n_read;
tmp->nbytes = n_read;
- tmp->next = nullptr;
+ tmp->next = NULL;
total_bytes += tmp->nbytes;
/* If there is enough room in the last buffer read, just append the new
char *evbuf;
idx_t evbuf_off = 0;
- wd_to_name = hash_initialize (n_files, nullptr, wd_hasher, wd_comparator,
- nullptr);
+ wd_to_name = hash_initialize (n_files, NULL, wd_hasher, wd_comparator,
+ NULL);
if (! wd_to_name)
xalloc_die ();
*wd_to_namep = wd_to_name;
continue;
}
- if (hash_insert (wd_to_name, &(f[i])) == nullptr)
+ if (hash_insert (wd_to_name, &(f[i])) == NULL)
xalloc_die ();
found_watchable_file = true;
close_fd (prev->fd, prev);
}
- if (hash_insert (wd_to_name, fspec) == nullptr)
+ if (hash_insert (wd_to_name, fspec) == NULL)
xalloc_die ();
}
int c;
while ((c = getopt_long (argc, argv, "c:n:fFqs:vz0123456789",
- long_options, nullptr))
+ long_options, NULL))
!= -1)
{
switch (c)
case 'f':
case LONG_FOLLOW_OPTION:
forever = true;
- if (optarg == nullptr)
+ if (optarg == NULL)
follow_mode = DEFAULT_FOLLOW_MODE;
else
follow_mode = XARGMATCH ("--follow", optarg,
: ("warning: PID ignored;"
" --pid=PID is useful only when following")));
free (pids);
- pids = nullptr;
+ pids = NULL;
}
}
static struct option const long_options[] =
{
- {"append", no_argument, nullptr, 'a'},
- {"ignore-interrupts", no_argument, nullptr, 'i'},
- {"output-error", optional_argument, nullptr, 'p'},
+ {"append", no_argument, NULL, 'a'},
+ {"ignore-interrupts", no_argument, NULL, 'i'},
+ {"output-error", optional_argument, NULL, 'p'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
static char const *const output_error_args[] =
{
- "warn", "warn-nopipe", "exit", "exit-nopipe", nullptr
+ "warn", "warn-nopipe", "exit", "exit-nopipe", NULL
};
static enum output_error const output_error_types[] =
{
ignore_interrupts = false;
int optc;
- while ((optc = getopt_long (argc, argv, "aip", long_options, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "aip", long_options, NULL)) != -1)
{
switch (optc)
{
|| output_error == output_error_exit_nopipe,
w_errno, "%s", quotef (files[i]));
}
- descriptors[i] = nullptr;
+ descriptors[i] = NULL;
return fail;
}
{
size_t n_outputs = 0;
FILE **descriptors;
- bool *out_pollable IF_LINT ( = nullptr);
+ bool *out_pollable IF_LINT ( = NULL);
char buffer[BUFSIZ];
ssize_t bytes_read = 0;
int first_out = 0; /* idx of first non-null output in descriptors */
if (pipe_check)
out_pollable[0] = iopoll_output_ok (fileno (descriptors[0]));
files[0] = bad_cast (_("standard output"));
- setvbuf (stdout, nullptr, _IONBF, 0);
+ setvbuf (stdout, NULL, _IONBF, 0);
n_outputs++;
for (int i = 1; i <= nfiles; i++)
{
/* Do not treat "-" specially - as mandated by POSIX. */
descriptors[i] = fopen (files[i], mode_string);
- if (descriptors[i] == nullptr)
+ if (descriptors[i] == NULL)
{
if (pipe_check)
out_pollable[i] = false;
{
if (pipe_check)
out_pollable[i] = iopoll_output_ok (fileno (descriptors[i]));
- setvbuf (descriptors[i], nullptr, _IONBF, 0);
+ setvbuf (descriptors[i], NULL, _IONBF, 0);
n_outputs++;
}
}
bool
temp_stream (FILE **fp, char **file_name)
{
- static char *tempfile = nullptr;
+ static char *tempfile = NULL;
static FILE *tmp_fp;
- if (tempfile == nullptr)
+ if (tempfile == NULL)
{
- char *tempbuf = nullptr;
+ char *tempbuf = NULL;
size_t tempbuf_len = 128;
while (true)
return false;
}
- if (path_search (tempbuf, tempbuf_len, nullptr, "cutmp", true) == 0)
+ if (path_search (tempbuf, tempbuf_len, NULL, "cutmp", true) == 0)
break;
if (errno != EINVAL || PATH_MAX / 2 < tempbuf_len)
unlink (tempfile);
Reset:
free (tempfile);
- tempfile = nullptr;
+ tempfile = NULL;
return false;
}
unary_advance ();
arg = find_int (argv[pos - 1]);
errno = 0;
- fd = strtol (arg, nullptr, 10);
+ fd = strtol (arg, NULL, 10);
return (errno != ERANGE && 0 <= fd && fd <= INT_MAX && isatty (fd));
}
if (streq (margv[1], "--version"))
{
version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
- (char *) nullptr);
+ (char *) NULL);
test_main_return (EXIT_SUCCESS);
}
}
static struct option const long_options[] =
{
- {"foreground", no_argument, nullptr, 'f'},
- {"kill-after", required_argument, nullptr, 'k'},
- {"preserve-status", no_argument, nullptr, 'p'},
- {"signal", required_argument, nullptr, 's'},
- {"verbose", no_argument, nullptr, 'v'},
+ {"foreground", no_argument, NULL, 'f'},
+ {"kill-after", required_argument, NULL, 'k'},
+ {"preserve-status", no_argument, NULL, 'p'},
+ {"signal", required_argument, NULL, 's'},
+ {"verbose", no_argument, NULL, 'v'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Start the timeout after which we'll receive a SIGALRM.
struct timespec ts = dtotimespec (duration);
struct itimerspec its = {.it_interval = {0}, .it_value = ts};
timer_t timerid;
- if (timer_create (CLOCK_REALTIME, nullptr, &timerid) == 0)
+ if (timer_create (CLOCK_REALTIME, NULL, &timerid) == 0)
{
- if (timer_settime (timerid, 0, &its, nullptr) == 0)
+ if (timer_settime (timerid, 0, &its, NULL) == 0)
return;
else
{
tv.tv_usec--;
}
struct itimerval it = {.it_interval = {0}, .it_value = tv };
- if (setitimer (ITIMER_REAL, &it, nullptr) == 0)
+ if (setitimer (ITIMER_REAL, &it, NULL) == 0)
return;
else
{
sigset_t unblock_set;
sigemptyset (&unblock_set);
sigaddset (&unblock_set, sig);
- if (sigprocmask (SIG_UNBLOCK, &unblock_set, nullptr) != 0)
+ if (sigprocmask (SIG_UNBLOCK, &unblock_set, NULL) != 0)
error (0, errno, _("warning: sigprocmask"));
}
sa.sa_flags = SA_RESTART; /* Restart syscalls if possible, as that's
more likely to work cleanly. */
- sigaction (SIGCHLD, &sa, nullptr);
+ sigaction (SIGCHLD, &sa, NULL);
/* We inherit the signal mask from our parent process,
so ensure SIGCHLD is not blocked. */
set to SIG_IGN by default. I.e., those signals will
not be propagated through background timeout jobs. */
struct sigaction old_sa;
- sigaction (sig, nullptr, &old_sa);
+ sigaction (sig, NULL, &old_sa);
bool ret = old_sa.sa_handler != SIG_IGN;
return ret;
}
for (int i = 0; i < countof (term_sig); i++)
if (sig_needs_handling (term_sig[i], sigterm))
- sigaction (term_sig[i], &sa, nullptr);
+ sigaction (term_sig[i], &sa, NULL);
/* Real Time signals also terminate by default. */
for (int s = SIGRTMIN; s <= SIGRTMAX; s++)
if (sig_needs_handling (s, sigterm))
- sigaction (s, &sa, nullptr);
+ sigaction (s, &sa, NULL);
- sigaction (sigterm, &sa, nullptr); /* user specified termination signal. */
+ sigaction (sigterm, &sa, NULL); /* user specified termination signal. */
}
/* Block all signals which were registered with cleanup() as the signal
initialize_exit_failure (EXIT_CANCELED);
atexit (close_stdout);
- while ((c = getopt_long (argc, argv, "+fk:ps:v", long_options, nullptr))
+ while ((c = getopt_long (argc, argv, "+fk:ps:v", long_options, NULL))
!= -1)
{
switch (c)
return EXIT_CANCELED;
/* Restore signal mask for child. */
- if (sigprocmask (SIG_SETMASK, &orig_set, nullptr) != 0)
+ if (sigprocmask (SIG_SETMASK, &orig_set, NULL) != 0)
{
error (0, errno, _("child failed to reset signal mask"));
return EXIT_CANCELED;
static struct option const longopts[] =
{
- {"time", required_argument, nullptr, TIME_OPTION},
- {"no-create", no_argument, nullptr, 'c'},
- {"date", required_argument, nullptr, 'd'},
- {"reference", required_argument, nullptr, 'r'},
- {"no-dereference", no_argument, nullptr, 'h'},
+ {"time", required_argument, NULL, TIME_OPTION},
+ {"no-create", no_argument, NULL, 'c'},
+ {"date", required_argument, NULL, 'd'},
+ {"reference", required_argument, NULL, 'r'},
+ {"no-dereference", no_argument, NULL, 'h'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Valid arguments to the '--time' option. */
static char const *const time_args[] =
{
- "atime", "access", "use", "mtime", "modify", nullptr
+ "atime", "access", "use", "mtime", "modify", NULL
};
/* The bits in 'change_times' that those arguments set. */
if (amtime_now)
{
- /* Pass nullptr to futimens so it will not fail if we have
+ /* Pass NULL to futimens so it will not fail if we have
write access to the file, but don't own it. */
- t = nullptr;
+ t = NULL;
}
- char const *file_opt = fd == STDOUT_FILENO ? nullptr : file;
+ char const *file_opt = fd == STDOUT_FILENO ? NULL : file;
int atflag = no_dereference ? AT_SYMLINK_NOFOLLOW : 0;
int utime_errno = (fdutimensat (fd, AT_FDCWD, file_opt, t, atflag) == 0
? 0 : errno);
int c;
bool date_set = false;
bool ok = true;
- char const *flex_date = nullptr;
+ char const *flex_date = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
change_times = 0;
no_create = use_ref = false;
- while ((c = getopt_long (argc, argv, "acd:fhmr:t:", longopts, nullptr)) != -1)
+ while ((c = getopt_long (argc, argv, "acd:fhmr:t:", longopts, NULL)) != -1)
{
switch (c)
{
struct tm const *tm = localtime (&newtime[0].tv_sec);
/* Technically, it appears that even a deliberate attempt to cause
- the above localtime to return nullptr will always fail because our
+ the above localtime to return NULL will always fail because our
posixtime implementation rejects all dates for which localtime
would fail. However, skip the warning if it ever fails. */
if (tm)
static struct option const long_options[] =
{
- {"complement", no_argument, nullptr, 'c'},
- {"delete", no_argument, nullptr, 'd'},
- {"squeeze-repeats", no_argument, nullptr, 's'},
- {"truncate-set1", no_argument, nullptr, 't'},
+ {"complement", no_argument, NULL, 'c'},
+ {"delete", no_argument, NULL, 'd'},
+ {"squeeze-repeats", no_argument, NULL, 's'},
+ {"truncate-set1", no_argument, NULL, 't'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
for (size_t i = 0; i < len; i++)
{
char buf[5];
- char const *tmp = nullptr;
+ char const *tmp = NULL;
unsigned char c = s[i];
switch (c)
append_normal_char (struct Spec_list *list, unsigned char c)
{
struct List_element *new = xmalloc (sizeof *new);
- new->next = nullptr;
+ new->next = NULL;
new->type = RE_NORMAL_CHAR;
new->u.normal_char = c;
list->tail->next = new;
return false;
}
struct List_element *new = xmalloc (sizeof *new);
- new->next = nullptr;
+ new->next = NULL;
new->type = RE_RANGE;
new->u.range.first_char = first;
new->u.range.last_char = last;
if (char_class == CC_NO_CLASS)
return false;
struct List_element *new = xmalloc (sizeof *new);
- new->next = nullptr;
+ new->next = NULL;
new->type = RE_CHAR_CLASS;
new->u.char_class = char_class;
list->tail->next = new;
count repeat_count)
{
struct List_element *new = xmalloc (sizeof *new);
- new->next = nullptr;
+ new->next = NULL;
new->type = RE_REPEATED_CHAR;
new->u.repeated_char.the_repeated_char = the_char;
new->u.repeated_char.repeat_count = repeat_count;
return false;
struct List_element *new = xmalloc (sizeof *new);
- new->next = nullptr;
+ new->next = NULL;
new->type = RE_EQUIV_CLASS;
new->u.equiv_code = *equiv_class_str;
list->tail->next = new;
char const *digit_str = &es->s[start_idx + 2];
char *d_end;
if ((xstrtoumax (digit_str, &d_end, *digit_str == '0' ? 8 : 10,
- repeat_count, nullptr)
+ repeat_count, NULL)
!= LONGINT_OK)
|| REPEAT_COUNT_MAXIMUM < *repeat_count
|| digit_str + digit_str_len != d_end)
}
p = s->tail;
- if (p == nullptr)
+ if (p == NULL)
return -1;
switch (p->type)
bool in_set[N_CHARS] = {0};
s->state = BEGIN_STATE;
- while ((c = get_next (s, nullptr)) != -1)
+ while ((c = get_next (s, NULL)) != -1)
{
cardinality -= (!in_set[c]);
in_set[c] = true;
{
struct List_element *new = xmalloc (sizeof *new);
spec_list->head = spec_list->tail = new;
- spec_list->head->next = nullptr;
+ spec_list->head->next = NULL;
}
/* This function makes two passes over the argument string S. The first
s->state = BEGIN_STATE;
- if ((b = get_next (s, nullptr)) == -1)
+ if ((b = get_next (s, NULL)) == -1)
return false;
- while ((c = get_next (s, nullptr)) != -1)
+ while ((c = get_next (s, NULL)) != -1)
if (c != b)
return false;
int c;
s->state = BEGIN_STATE;
- while ((c = get_next (s, nullptr)) != -1)
+ while ((c = get_next (s, NULL)) != -1)
in_set[c] = true;
if (complement_this_set)
for (size_t i = 0; i < N_CHARS; i++)
atexit (close_stdout);
- while ((c = getopt_long (argc, argv, "+AcCdst", long_options, nullptr)) != -1)
+ while ((c = getopt_long (argc, argv, "+AcCdst", long_options, NULL)) != -1)
{
switch (c)
{
main_exit (EXIT_FAILURE);
}
else
- s2 = nullptr;
+ s2 = NULL;
validate (s1, s2);
{
if (!in_s1[i])
{
- int ch = get_next (s2, nullptr);
+ int ch = get_next (s2, NULL);
affirm (ch != -1 || truncate_set1);
if (ch == -1)
{
if (streq (argv[1], "--version"))
version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
- (char *) nullptr);
+ (char *) NULL);
}
return EXIT_STATUS;
static struct option const longopts[] =
{
- {"no-create", no_argument, nullptr, 'c'},
- {"io-blocks", no_argument, nullptr, 'o'},
- {"reference", required_argument, nullptr, 'r'},
- {"size", required_argument, nullptr, 's'},
+ {"no-create", no_argument, NULL, 'c'},
+ {"io-blocks", no_argument, NULL, 'o'},
+ {"reference", required_argument, NULL, 'r'},
+ {"size", required_argument, NULL, 's'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
typedef enum
atexit (close_stdout);
- while ((c = getopt_long (argc, argv, "cor:s:", longopts, nullptr)) != -1)
+ while ((c = getopt_long (argc, argv, "cor:s:", longopts, NULL)) != -1)
{
switch (c)
{
};
/* The head of the sorted list. */
-static struct item *head = nullptr;
+static struct item *head = NULL;
/* The tail of the list of 'zeros', strings that have no predecessors. */
-static struct item *zeros = nullptr;
+static struct item *zeros = NULL;
/* Used for loop detection. */
-static struct item *loop = nullptr;
+static struct item *loop = NULL;
/* The number of strings to sort. */
static size_t n_strings = 0;
/* Make sure the tree is not empty, since that is what the algorithm
below expects. */
- if (root->right == nullptr)
+ if (root->right == NULL)
return (root->right = new_item (str));
/* A1. Initialize. */
else
q = p->right;
- if (q == nullptr)
+ if (q == NULL)
{
/* A5. Insert. */
q = new_item (str);
/* Ignore strings that have already been printed. */
if (k->count == 0 && !k->printed)
{
- if (head == nullptr)
+ if (head == NULL)
head = k;
else
zeros->qlink = k;
/* K does not have to be part of a cycle. It is however part of
a graph that contains a cycle. */
- if (loop == nullptr)
+ if (loop == NULL)
/* Start traversing the graph at K. */
loop = k;
else
/* Tidy things up since we might have to
detect another loop. */
- loop->qlink = nullptr;
+ loop->qlink = NULL;
loop = tmp;
}
{
struct item *tmp = loop->qlink;
- loop->qlink = nullptr;
+ loop->qlink = NULL;
loop = tmp;
}
static bool
recurse_tree (struct item *root, bool (*action) (struct item *))
{
- if (root->left == nullptr && root->right == nullptr)
+ if (root->left == NULL && root->right == NULL)
return (*action) (root);
else
{
- if (root->left != nullptr)
+ if (root->left != NULL)
if (recurse_tree (root->left, action))
return true;
if ((*action) (root))
return true;
- if (root->right != nullptr)
+ if (root->right != NULL)
if (recurse_tree (root->right, action))
return true;
}
tsort (char const *file)
{
bool ok = true;
- struct item *j = nullptr;
- struct item *k = nullptr;
+ struct item *j = NULL;
+ struct item *k = NULL;
token_buffer tokenbuffer;
bool is_stdin = streq (file, "-");
/* Initialize the head of the tree holding the strings we're sorting. */
- struct item *root = new_item (nullptr);
+ struct item *root = new_item (NULL);
if (!is_stdin && ! freopen (file, "r", stdin))
error (EXIT_FAILURE, errno, "%s", quotef (file));
{
/* T3. Record the relation. */
record_relation (j, k);
- k = nullptr;
+ k = NULL;
}
j = k;
}
- if (k != nullptr)
+ if (k != NULL)
error (EXIT_FAILURE, 0, _("%s: input contains an odd number of tokens"),
quotef (file));
{
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
- int c = getopt_long (argc, argv, "w", long_options, nullptr);
+ int c = getopt_long (argc, argv, "w", long_options, NULL);
if (c == -1)
break;
static struct option const longopts[] =
{
- {"silent", no_argument, nullptr, 's'},
- {"quiet", no_argument, nullptr, 's'},
+ {"silent", no_argument, NULL, 's'},
+ {"quiet", no_argument, NULL, 's'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
silent = false;
- while ((optc = getopt_long (argc, argv, "s", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "s", longopts, NULL)) != -1)
{
switch (optc)
{
static struct option const uname_long_options[] =
{
- {"all", no_argument, nullptr, 'a'},
- {"kernel-name", no_argument, nullptr, 's'},
- {"sysname", no_argument, nullptr, 's'}, /* Obsolescent. */
- {"nodename", no_argument, nullptr, 'n'},
- {"kernel-release", no_argument, nullptr, 'r'},
- {"release", no_argument, nullptr, 'r'}, /* Obsolescent. */
- {"kernel-version", no_argument, nullptr, 'v'},
- {"machine", no_argument, nullptr, 'm'},
- {"processor", no_argument, nullptr, 'p'},
- {"hardware-platform", no_argument, nullptr, 'i'},
- {"operating-system", no_argument, nullptr, 'o'},
+ {"all", no_argument, NULL, 'a'},
+ {"kernel-name", no_argument, NULL, 's'},
+ {"sysname", no_argument, NULL, 's'}, /* Obsolescent. */
+ {"nodename", no_argument, NULL, 'n'},
+ {"kernel-release", no_argument, NULL, 'r'},
+ {"release", no_argument, NULL, 'r'}, /* Obsolescent. */
+ {"kernel-version", no_argument, NULL, 'v'},
+ {"machine", no_argument, NULL, 'm'},
+ {"processor", no_argument, NULL, 'p'},
+ {"hardware-platform", no_argument, NULL, 'i'},
+ {"operating-system", no_argument, NULL, 'o'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
static struct option const arch_long_options[] =
{
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
if (uname_mode == UNAME_ARCH)
{
while ((c = getopt_long (argc, argv, "",
- arch_long_options, nullptr))
+ arch_long_options, NULL))
!= -1)
{
switch (c)
else
{
while ((c = getopt_long (argc, argv, "asnrvmpio",
- uname_long_options, nullptr))
+ uname_long_options, NULL))
!= -1)
{
switch (c)
static struct option const longopts[] =
{
- {"tabs", required_argument, nullptr, 't'},
- {"all", no_argument, nullptr, 'a'},
- {"first-only", no_argument, nullptr, CONVERT_FIRST_ONLY_OPTION},
+ {"tabs", required_argument, NULL, 't'},
+ {"all", no_argument, NULL, 'a'},
+ {"first-only", no_argument, NULL, CONVERT_FIRST_ONLY_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
unexpand (void)
{
/* Input stream. */
- FILE *fp = next_file (nullptr);
+ FILE *fp = next_file (NULL);
/* The array of pending blanks. In non-POSIX locales, blanks can
include characters other than spaces, so the blanks must be
atexit (close_stdout);
- while ((c = getopt_long (argc, argv, ",0123456789at:", longopts, nullptr))
+ while ((c = getopt_long (argc, argv, ",0123456789at:", longopts, NULL))
!= -1)
{
switch (c)
finalize_tab_stops ();
- set_file_list ((optind < argc) ? &argv[optind] : nullptr);
+ set_file_list ((optind < argc) ? &argv[optind] : NULL);
unexpand ();
static char const *const delimit_method_string[] =
{
- "none", "prepend", "separate", nullptr
+ "none", "prepend", "separate", NULL
};
static enum delimit_method const delimit_method_map[] =
static char const *const grouping_method_string[] =
{
- "prepend", "append", "separate", "both", nullptr
+ "prepend", "append", "separate", "both", NULL
};
static enum grouping_method const grouping_method_map[] =
static struct option const longopts[] =
{
- {"count", no_argument, nullptr, 'c'},
- {"repeated", no_argument, nullptr, 'd'},
- {"all-repeated", optional_argument, nullptr, 'D'},
- {"group", optional_argument, nullptr, GROUP_OPTION},
- {"ignore-case", no_argument, nullptr, 'i'},
- {"unique", no_argument, nullptr, 'u'},
- {"skip-fields", required_argument, nullptr, 'f'},
- {"skip-chars", required_argument, nullptr, 's'},
- {"check-chars", required_argument, nullptr, 'w'},
- {"zero-terminated", no_argument, nullptr, 'z'},
+ {"count", no_argument, NULL, 'c'},
+ {"repeated", no_argument, NULL, 'd'},
+ {"all-repeated", optional_argument, NULL, 'D'},
+ {"group", optional_argument, NULL, GROUP_OPTION},
+ {"ignore-case", no_argument, NULL, 'i'},
+ {"unique", no_argument, NULL, 'u'},
+ {"skip-fields", required_argument, NULL, 'f'},
+ {"skip-chars", required_argument, NULL, 's'},
+ {"check-chars", required_argument, NULL, 'w'},
+ {"zero-terminated", no_argument, NULL, 'z'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
void
size_opt (char const *opt, char const *msgid)
{
intmax_t size;
- if (LONGINT_OVERFLOW < xstrtoimax (opt, nullptr, 10, &size, "")
+ if (LONGINT_OVERFLOW < xstrtoimax (opt, NULL, 10, &size, "")
|| size < 0)
error (EXIT_FAILURE, 0, "%s: %s", opt, _(msgid));
return MIN (size, IDX_MAX);
*/
if (output_unique && output_first_repeated && !count_occurrences)
{
- char *prevfield = nullptr;
+ char *prevfield = NULL;
idx_t prevlen;
bool first_group_printed = false;
main (int argc, char **argv)
{
int optc = 0;
- bool posixly_correct = (getenv ("POSIXLY_CORRECT") != nullptr);
+ bool posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
enum Skip_field_option_type skip_field_option_type = SFO_NONE;
int nfiles = 0;
char const *file[2];
|| (posixly_correct && nfiles != 0)
|| ((optc = getopt_long (argc, argv,
"-0123456789Dcdf:is:uw:z",
- longopts, nullptr))
+ longopts, NULL))
== -1))
{
if (argc <= optind)
intmax_t size;
if (optarg[0] == '+'
&& ! strict_posix2 ()
- && (xstrtoimax (optarg, nullptr, 10, &size, "")
+ && (xstrtoimax (optarg, NULL, 10, &size, "")
<= LONGINT_OVERFLOW))
skip_chars = MIN (size, IDX_MAX);
else if (nfiles == 2)
case 'D':
output_unique = false;
output_later_repeated = true;
- if (optarg == nullptr)
+ if (optarg == NULL)
delimit_groups = DM_NONE;
else
delimit_groups = XARGMATCH ("--all-repeated", optarg,
break;
case GROUP_OPTION:
- if (optarg == nullptr)
+ if (optarg == NULL)
grouping = GM_SEPARATE;
else
grouping = XARGMATCH ("--group", optarg,
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
Version, true, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
if (argc < optind + 1)
{
status = EXIT_FAILURE;
}
- time_t time_now = time (nullptr);
- struct tm *tmn = time_now == (time_t) -1 ? nullptr : localtime (&time_now);
+ time_t time_now = time (NULL);
+ struct tm *tmn = time_now == (time_t) -1 ? NULL : localtime (&time_now);
/* procps' version of uptime also prints the seconds field, but
previous versions of coreutils don't. */
if (tmn)
{
error (0, errno, "%s", quotef (filename));
n_users = 0;
- utmp_buf = nullptr;
+ utmp_buf = NULL;
}
int print_uptime_status = print_uptime (n_users, utmp_buf);
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
Version, true, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
switch (argc - optind)
{
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
Version, true, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
switch (argc - optind)
{
static struct option const longopts[] =
{
- {"bytes", no_argument, nullptr, 'c'},
- {"chars", no_argument, nullptr, 'm'},
- {"lines", no_argument, nullptr, 'l'},
- {"words", no_argument, nullptr, 'w'},
- {"debug", no_argument, nullptr, DEBUG_PROGRAM_OPTION},
- {"files0-from", required_argument, nullptr, FILES0_FROM_OPTION},
- {"max-line-length", no_argument, nullptr, 'L'},
- {"total", required_argument, nullptr, TOTAL_OPTION},
+ {"bytes", no_argument, NULL, 'c'},
+ {"chars", no_argument, NULL, 'm'},
+ {"lines", no_argument, NULL, 'l'},
+ {"words", no_argument, NULL, 'w'},
+ {"debug", no_argument, NULL, DEBUG_PROGRAM_OPTION},
+ {"files0-from", required_argument, NULL, FILES0_FROM_OPTION},
+ {"max-line-length", no_argument, NULL, 'L'},
+ {"total", required_argument, NULL, TOTAL_OPTION},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
enum total_type
};
static char const *const total_args[] =
{
- "auto", "always", "only", "never", nullptr
+ "auto", "always", "only", "never", NULL
};
static enum total_type const total_types[] =
{
int optc;
idx_t nfiles;
char **files;
- char *files_from = nullptr;
+ char *files_from = NULL;
struct fstatus *fstatus;
struct Tokens tok;
page_size = getpagesize ();
/* Line buffer stdout to ensure lines are written atomically and immediately
so that processes running in parallel do not intersperse their output. */
- setvbuf (stdout, nullptr, _IOLBF, 0);
+ setvbuf (stdout, NULL, _IOLBF, 0);
- posixly_correct = (getenv ("POSIXLY_CORRECT") != nullptr);
+ posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
print_lines = print_words = print_chars = print_bytes = false;
print_linelength = false;
total_lines = total_words = total_chars = total_bytes = max_line_length = 0;
- while ((optc = getopt_long (argc, argv, "clLmw", longopts, nullptr)) != -1)
+ while ((optc = getopt_long (argc, argv, "clLmw", longopts, NULL)) != -1)
switch (optc)
{
case 'c':
else
{
stream = fopen (files_from, "r");
- if (stream == nullptr)
+ if (stream == NULL)
error (EXIT_FAILURE, errno, _("cannot open %s for reading"),
quoteaf (files_from));
}
}
else
{
- files = nullptr;
+ files = NULL;
nfiles = 0;
ai = argv_iter_init_stream (stream);
}
}
else
{
- static char *stdin_only[] = { nullptr };
+ static char *stdin_only[] = { NULL };
files = (optind < argc ? argv + optind : stdin_only);
nfiles = (optind < argc ? argc - optind : 1);
ai = argv_iter_init_argv (files);
among many, knowing the record number may help.
FIXME: currently print the record number only with
--files0-from=FILE. Maybe do it for argv, too? */
- if (files_from == nullptr)
+ if (files_from == NULL)
error (0, 0, "%s", _("invalid zero-length file name"));
else
{
However, no arguments on the --files0-from input stream is an error
means don't read anything. */
if (ok && !files_from && argv_iter_n_args (ai) == 0)
- ok &= wc_file (nullptr, &fstatus[0]);
+ ok &= wc_file (NULL, &fstatus[0]);
if (read_tokens)
readtokens0_free (&tok);
write_counts (total_lines, total_words, total_chars, total_bytes,
max_line_length,
- total_mode != total_only ? _("total") : nullptr);
+ total_mode != total_only ? _("total") : NULL);
}
argv_iter_free (ai);
static struct option const longopts[] =
{
- {"all", no_argument, nullptr, 'a'},
- {"boot", no_argument, nullptr, 'b'},
- {"count", no_argument, nullptr, 'q'},
- {"dead", no_argument, nullptr, 'd'},
- {"heading", no_argument, nullptr, 'H'},
- {"login", no_argument, nullptr, 'l'},
- {"lookup", no_argument, nullptr, LOOKUP_OPTION},
- {"message", no_argument, nullptr, 'T'},
- {"mesg", no_argument, nullptr, 'T'},
- {"process", no_argument, nullptr, 'p'},
- {"runlevel", no_argument, nullptr, 'r'},
- {"short", no_argument, nullptr, 's'},
- {"time", no_argument, nullptr, 't'},
- {"users", no_argument, nullptr, 'u'},
- {"writable", no_argument, nullptr, 'T'},
+ {"all", no_argument, NULL, 'a'},
+ {"boot", no_argument, NULL, 'b'},
+ {"count", no_argument, NULL, 'q'},
+ {"dead", no_argument, NULL, 'd'},
+ {"heading", no_argument, NULL, 'H'},
+ {"login", no_argument, NULL, 'l'},
+ {"lookup", no_argument, NULL, LOOKUP_OPTION},
+ {"message", no_argument, NULL, 'T'},
+ {"mesg", no_argument, NULL, 'T'},
+ {"process", no_argument, NULL, 'p'},
+ {"runlevel", no_argument, NULL, 'r'},
+ {"short", no_argument, NULL, 's'},
+ {"time", no_argument, NULL, 't'},
+ {"users", no_argument, NULL, 'u'},
+ {"writable", no_argument, NULL, 'T'},
{GETOPT_HELP_OPTION_DECL},
{GETOPT_VERSION_OPTION_DECL},
- {nullptr, 0, nullptr, 0}
+ {NULL, 0, NULL, 0}
};
/* Return a string representing the time between WHEN and now.
#if HAVE_STRUCT_XTMP_UT_HOST
if (utmp_ent->ut_host[0])
{
- char *host = nullptr;
- char *display = nullptr;
+ char *host = NULL;
+ char *display = NULL;
char *ut_host = utmp_ent->ut_host;
/* Look for an X display. */
if (hostlen < needed)
{
free (hoststr);
- hoststr = xpalloc (nullptr, &hostlen, needed - hostlen, -1, 1);
+ hoststr = xpalloc (NULL, &hostlen, needed - hostlen, -1, 1);
}
char *p = hoststr;
*p++ = '(';
if (hostlen < needed)
{
free (hoststr);
- hoststr = xpalloc (nullptr, &hostlen, needed - hostlen, -1, 1);
+ hoststr = xpalloc (NULL, &hostlen, needed - hostlen, -1, 1);
}
char *p = hoststr;
*p++ = '(';
static void
scan_entries (idx_t n, STRUCT_UTMP const *utmp_buf)
{
- char *ttyname_b IF_LINT ( = nullptr);
+ char *ttyname_b IF_LINT ( = NULL);
time_t boottime = TYPE_MINIMUM (time_t);
if (include_heading)
atexit (close_stdout);
- while ((optc = getopt_long (argc, argv, "abdlmpqrstuwHT", longopts, nullptr))
+ while ((optc = getopt_long (argc, argv, "abdlmpqrstuwHT", longopts, NULL))
!= -1)
{
switch (optc)
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
Version, true, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
if (optind != argc)
{
errno = 0;
uid_t uid = geteuid ();
- struct passwd *pw = uid == NO_UID && errno ? nullptr : getpwuid (uid);
+ struct passwd *pw = uid == NO_UID && errno ? NULL : getpwuid (uid);
if (!pw)
error (EXIT_FAILURE, errno, _("cannot find name for user ID %ju"),
(uintmax_t) uid);
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
Version, true, usage, AUTHORS,
- (char const *) nullptr);
+ (char const *) NULL);
char **operands = argv + optind;
char **operand_lim = argv + argc;
|| skip_ "getmntent is not used on this system"
# Simulate "mtab" failure.
-# Replace gnulib streq and C23 nullptr as that are not available here.
-sed 's/streq/0==str''cmp/; s/nullptr/NU''LL/' > k.c <<EOF || framework_failure_
+# Replace gnulib streq as that is not available here.
+sed 's/streq/0==str''cmp/' > k.c <<EOF || framework_failure_
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
{
fprintf (stderr, "Failed to find fopen()\n");
errno = ESRCH;
- return nullptr;
+ return NULL;
}
}
if (streq (path, "/proc/self/mountinfo"))
{
errno = ENOENT;
- return nullptr;
+ return NULL;
}
return fopen_func(path, mode);
}
/* Now simulate the failure. */
errno = ENOENT;
- return nullptr;
+ return NULL;
}
EOF
|| skip_ "getmntent is not used on this system"
# Simulate an mtab file to test various cases.
-# Replace gnulib streq and C23 nullptr as that are not available here.
-sed 's/streq/0==str''cmp/; s/nullptr/NU''LL/' > k.c <<EOF || framework_failure_
+# Replace gnulib streq as that is not available here.
+sed 's/streq/0==str''cmp/' > k.c <<EOF || framework_failure_
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
{
fprintf (stderr, "Failed to find fopen()\n");
errno = ESRCH;
- return nullptr;
+ return NULL;
}
}
if (streq (path, "/proc/self/mountinfo"))
{
errno = ENOENT;
- return nullptr;
+ return NULL;
}
return fopen_func(path, mode);