mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-10-24 02:08:57 +03:00
maint: prefer C23-style nullptr
* bootstrap.conf (gnulib_modules): Add nullptr. In code, prefer nullptr to NULL where either will do.
This commit is contained in:
@@ -188,6 +188,7 @@ gnulib_modules="
|
||||
mkostemp
|
||||
mkstemp
|
||||
mktime
|
||||
nullptr
|
||||
modechange
|
||||
mountlist
|
||||
mpsort
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
Parse the initial prefix of NPTR as a floating-point number in the
|
||||
current locale or in the C locale (preferring the locale that
|
||||
yields the longer parse, or the current locale if there is a tie).
|
||||
If ENDPTR is not NULL, set *ENDPTR to the first unused byte, or to
|
||||
If ENDPTR is non-null, set *ENDPTR to the first unused byte, or to
|
||||
NPTR if the prefix cannot be parsed.
|
||||
|
||||
If successful, return a number without changing errno.
|
||||
|
||||
@@ -50,7 +50,7 @@ heap_alloc (int (*compare) (void const *, void const *), size_t n_reserve)
|
||||
|
||||
heap->array = xnmalloc (n_reserve, sizeof *(heap->array));
|
||||
|
||||
heap->array[0] = NULL;
|
||||
heap->array[0] = nullptr;
|
||||
heap->capacity = n_reserve;
|
||||
heap->count = 0;
|
||||
heap->compare = compare ? compare : heap_default_compare;
|
||||
@@ -96,7 +96,7 @@ heap_remove_top (struct heap *heap)
|
||||
void *top;
|
||||
|
||||
if (heap->count == 0)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
top = heap->array[1];
|
||||
heap->array[1] = heap->array[heap->count--];
|
||||
|
||||
@@ -111,8 +111,8 @@ mbsalign (char const *src, char *dest, size_t dest_size,
|
||||
{
|
||||
size_t ret = SIZE_MAX;
|
||||
size_t src_size = strlen (src) + 1;
|
||||
char *newstr = NULL;
|
||||
wchar_t *str_wc = NULL;
|
||||
char *newstr = nullptr;
|
||||
wchar_t *str_wc = nullptr;
|
||||
char const *str_to_print = src;
|
||||
size_t n_cols = src_size - 1;
|
||||
size_t n_used_bytes = n_cols; /* Not including NUL */
|
||||
@@ -125,7 +125,7 @@ mbsalign (char const *src, char *dest, size_t dest_size,
|
||||
of screen columns used. */
|
||||
if (!(flags & MBA_UNIBYTE_ONLY) && MB_CUR_MAX > 1)
|
||||
{
|
||||
size_t src_chars = mbstowcs (NULL, src, 0);
|
||||
size_t src_chars = mbstowcs (nullptr, src, 0);
|
||||
if (src_chars == SIZE_MAX)
|
||||
{
|
||||
if (flags & MBA_UNIBYTE_FALLBACK)
|
||||
@@ -135,7 +135,7 @@ mbsalign (char const *src, char *dest, size_t dest_size,
|
||||
}
|
||||
src_chars += 1; /* make space for NUL */
|
||||
str_wc = malloc (src_chars * sizeof (wchar_t));
|
||||
if (str_wc == NULL)
|
||||
if (str_wc == nullptr)
|
||||
{
|
||||
if (flags & MBA_UNIBYTE_FALLBACK)
|
||||
goto mbsalign_unibyte;
|
||||
@@ -159,10 +159,10 @@ mbsalign (char const *src, char *dest, size_t dest_size,
|
||||
{
|
||||
/* May have increased the size by converting
|
||||
\t to \uFFFD for example. */
|
||||
src_size = wcstombs (NULL, str_wc, 0) + 1;
|
||||
src_size = wcstombs (nullptr, str_wc, 0) + 1;
|
||||
}
|
||||
newstr = malloc (src_size);
|
||||
if (newstr == NULL)
|
||||
if (newstr == nullptr)
|
||||
{
|
||||
if (flags & MBA_UNIBYTE_FALLBACK)
|
||||
goto mbsalign_unibyte;
|
||||
@@ -239,7 +239,7 @@ mbsalign_cleanup:
|
||||
|
||||
/* A wrapper around mbsalign() to dynamically allocate the
|
||||
minimum amount of memory to store the result.
|
||||
Return NULL on failure. */
|
||||
Return nullptr on failure. */
|
||||
|
||||
char *
|
||||
ambsalign (char const *src, size_t *width, mbs_align_t align, int flags)
|
||||
@@ -247,17 +247,17 @@ ambsalign (char const *src, size_t *width, mbs_align_t align, int flags)
|
||||
size_t orig_width = *width;
|
||||
size_t size = *width; /* Start with enough for unibyte mode. */
|
||||
size_t req = size;
|
||||
char *buf = NULL;
|
||||
char *buf = nullptr;
|
||||
|
||||
while (req >= size)
|
||||
{
|
||||
char *nbuf;
|
||||
size = req + 1; /* Space for NUL. */
|
||||
nbuf = realloc (buf, size);
|
||||
if (nbuf == NULL)
|
||||
if (nbuf == nullptr)
|
||||
{
|
||||
free (buf);
|
||||
buf = NULL;
|
||||
buf = nullptr;
|
||||
break;
|
||||
}
|
||||
buf = nbuf;
|
||||
@@ -266,7 +266,7 @@ ambsalign (char const *src, size_t *width, mbs_align_t align, int flags)
|
||||
if (req == SIZE_MAX)
|
||||
{
|
||||
free (buf);
|
||||
buf = NULL;
|
||||
buf = nullptr;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
randint i;
|
||||
randint n = strtoumax (argv[1], NULL, 10);
|
||||
randint choices = strtoumax (argv[2], NULL, 10);
|
||||
randint n = strtoumax (argv[1], nullptr, 10);
|
||||
randint choices = strtoumax (argv[2], nullptr, 10);
|
||||
char const *name = argv[3];
|
||||
struct randint_source *ints = randint_all_new (name, SIZE_MAX);
|
||||
|
||||
@@ -77,14 +77,14 @@ randint_new (struct randread_source *source)
|
||||
}
|
||||
|
||||
/* Create a new randint_source by creating a randread_source from
|
||||
NAME and ESTIMATED_BYTES. Return NULL (setting errno) if
|
||||
NAME and ESTIMATED_BYTES. Return nullptr (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) : NULL);
|
||||
return (source ? randint_new (source) : nullptr);
|
||||
}
|
||||
|
||||
/* Return the random data source of *S. */
|
||||
|
||||
@@ -109,7 +109,7 @@ typedef Hash_table sparse_map;
|
||||
static sparse_map *
|
||||
sparse_new (size_t size_hint)
|
||||
{
|
||||
return hash_initialize (size_hint, NULL, sparse_hash_, sparse_cmp_, free);
|
||||
return hash_initialize (size_hint, nullptr, sparse_hash_, sparse_cmp_, free);
|
||||
}
|
||||
|
||||
/* Swap the values for I and J. If a value is not already present
|
||||
@@ -154,7 +154,7 @@ sparse_free (sparse_map *sv)
|
||||
|
||||
/* 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 NULL if H is zero. */
|
||||
Return nullptr if H is zero. */
|
||||
|
||||
size_t *
|
||||
randperm_new (struct randint_source *r, size_t h, size_t n)
|
||||
@@ -164,7 +164,7 @@ randperm_new (struct randint_source *r, size_t h, size_t n)
|
||||
switch (h)
|
||||
{
|
||||
case 0:
|
||||
v = NULL;
|
||||
v = nullptr;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@@ -209,13 +209,13 @@ randperm_new (struct randint_source *r, size_t h, size_t n)
|
||||
if (sparse)
|
||||
{
|
||||
sv = sparse_new (h * 2);
|
||||
if (sv == NULL)
|
||||
if (sv == nullptr)
|
||||
xalloc_die ();
|
||||
v = xnmalloc (h, sizeof *v);
|
||||
}
|
||||
else
|
||||
{
|
||||
sv = NULL; /* To placate GCC's -Wuninitialized. */
|
||||
sv = nullptr; /* To placate GCC's -Wuninitialized. */
|
||||
v = xnmalloc (n, sizeof *v);
|
||||
for (i = 0; i < n; i++)
|
||||
v[i] = i;
|
||||
|
||||
@@ -161,21 +161,21 @@ randread_free_body (struct randread_source *s)
|
||||
default handler. Unless a non-default handler is used, NAME's
|
||||
lifetime should be at least that of the returned value.
|
||||
|
||||
Return NULL (setting errno) on failure. */
|
||||
Return nullptr (setting errno) on failure. */
|
||||
|
||||
struct randread_source *
|
||||
randread_new (char const *name, size_t bytes_bound)
|
||||
{
|
||||
if (bytes_bound == 0)
|
||||
return simple_new (NULL, NULL);
|
||||
return simple_new (nullptr, nullptr);
|
||||
else
|
||||
{
|
||||
FILE *source = NULL;
|
||||
FILE *source = nullptr;
|
||||
struct randread_source *s;
|
||||
|
||||
if (name)
|
||||
if (! (source = fopen_safer (name, "rb")))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
s = simple_new (source, name);
|
||||
|
||||
@@ -190,7 +190,7 @@ randread_new (char const *name, size_t bytes_bound)
|
||||
int e = errno;
|
||||
randread_free_body (s);
|
||||
errno = e;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
isaac_seed (&s->buf.isaac.state);
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Call lstat to get the device and inode numbers for '/'.
|
||||
Upon failure, return NULL. Otherwise, set the members of
|
||||
Upon failure, return nullptr. 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 NULL;
|
||||
return nullptr;
|
||||
root_d_i->st_ino = statbuf.st_ino;
|
||||
root_d_i->st_dev = statbuf.st_dev;
|
||||
return root_d_i;
|
||||
|
||||
@@ -37,7 +37,7 @@ static inline bool
|
||||
is_smack_enabled (void)
|
||||
{
|
||||
#ifdef HAVE_SMACK
|
||||
return smack_smackfs_path () != NULL;
|
||||
return smack_smackfs_path () != nullptr;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
|
||||
@@ -40,7 +40,7 @@ __xnumtoint (char const *n_str, int base, __xdectoint_t min, __xdectoint_t max,
|
||||
strtol_error s_err;
|
||||
|
||||
__xdectoint_t tnum;
|
||||
s_err = __xstrtol (n_str, NULL, base, &tnum, suffixes);
|
||||
s_err = __xstrtol (n_str, nullptr, base, &tnum, suffixes);
|
||||
|
||||
if (s_err == LONGINT_OK)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,7 @@ xfts_open (char * const *argv, int options,
|
||||
int (*compar) (const FTSENT **, const FTSENT **))
|
||||
{
|
||||
FTS *fts = fts_open (argv, options | FTS_CWDFD, compar);
|
||||
if (fts == NULL)
|
||||
if (fts == nullptr)
|
||||
{
|
||||
/* This can fail in two ways: out of memory or with errno==EINVAL,
|
||||
which indicates it was called with invalid bit_flags. */
|
||||
|
||||
@@ -36,7 +36,7 @@ main (void)
|
||||
fdadvise (fileno (stdin), 0, 0, FADVISE_RANDOM);
|
||||
|
||||
/* Ignored. */
|
||||
fadvise (NULL, FADVISE_RANDOM);
|
||||
fadvise (nullptr, FADVISE_RANDOM);
|
||||
|
||||
/* Invalid. */
|
||||
fdadvise (42, 0, 0, FADVISE_RANDOM);
|
||||
|
||||
@@ -581,7 +581,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* 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], NULL, 10);
|
||||
for (iterations = argc <= 1 ? 0 : strtol (argv[1], nullptr, 10);
|
||||
iterations != 0;
|
||||
iterations += (iterations < 0 ? 1 : -1))
|
||||
if (0 <= iterations)
|
||||
|
||||
@@ -30,12 +30,12 @@
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"multiple", no_argument, NULL, 'a'},
|
||||
{"suffix", required_argument, NULL, 's'},
|
||||
{"zero", no_argument, NULL, 'z'},
|
||||
{"multiple", no_argument, nullptr, 'a'},
|
||||
{"suffix", required_argument, nullptr, 's'},
|
||||
{"zero", no_argument, nullptr, 'z'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -97,7 +97,7 @@ remove_suffix (char *name, char const *suffix)
|
||||
*np = '\0';
|
||||
}
|
||||
|
||||
/* Perform the basename operation on STRING. If SUFFIX is non-NULL, remove
|
||||
/* Perform the basename operation on STRING. If SUFFIX is non-null, remove
|
||||
the trailing SUFFIX. Finally, output the result string. */
|
||||
|
||||
static void
|
||||
@@ -125,7 +125,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
bool multiple_names = false;
|
||||
bool use_nuls = false;
|
||||
char const *suffix = NULL;
|
||||
char const *suffix = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -137,7 +137,7 @@ main (int argc, char **argv)
|
||||
|
||||
while (true)
|
||||
{
|
||||
int c = getopt_long (argc, argv, "+as:z", longopts, NULL);
|
||||
int c = getopt_long (argc, argv, "+as:z", longopts, nullptr);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
@@ -184,7 +184,8 @@ main (int argc, char **argv)
|
||||
}
|
||||
else
|
||||
perform_basename (argv[optind],
|
||||
optind + 2 == argc ? argv[optind + 1] : NULL, use_nuls);
|
||||
optind + 2 == argc ? argv[optind + 1] : nullptr,
|
||||
use_nuls);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
12
src/basenc.c
12
src/basenc.c
@@ -89,7 +89,7 @@ static struct option const long_options[] =
|
||||
#endif
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -588,7 +588,7 @@ z85_length (int len)
|
||||
static bool
|
||||
isz85 (char ch)
|
||||
{
|
||||
return c_isalnum (ch) || (strchr (".-:+=^!/*?&<>()[]{}@%$#", ch) != NULL);
|
||||
return c_isalnum (ch) || strchr (".-:+=^!/*?&<>()[]{}@%$#", ch) != nullptr;
|
||||
}
|
||||
|
||||
static char const z85_encoding[85] =
|
||||
@@ -1018,7 +1018,7 @@ do_decode (FILE *in, char const *infile, FILE *out, bool ignore_garbage)
|
||||
outbuf = xmalloc (DEC_BLOCKSIZE);
|
||||
|
||||
#if BASE_TYPE == 42
|
||||
ctx.inbuf = NULL;
|
||||
ctx.inbuf = nullptr;
|
||||
#endif
|
||||
base_decode_ctx_init (&ctx);
|
||||
|
||||
@@ -1099,7 +1099,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((opt = getopt_long (argc, argv, "diw:", long_options, NULL)) != -1)
|
||||
while ((opt = getopt_long (argc, argv, "diw:", long_options, nullptr)) != -1)
|
||||
switch (opt)
|
||||
{
|
||||
case 'd':
|
||||
@@ -1109,7 +1109,7 @@ main (int argc, char **argv)
|
||||
case 'w':
|
||||
{
|
||||
intmax_t w;
|
||||
strtol_error s_err = xstrtoimax (optarg, NULL, 10, &w, "");
|
||||
strtol_error s_err = xstrtoimax (optarg, nullptr, 10, &w, "");
|
||||
if (LONGINT_OVERFLOW < s_err || w < 0)
|
||||
die (EXIT_FAILURE, 0, "%s: %s",
|
||||
_("invalid wrap size"), quote (optarg));
|
||||
@@ -1235,7 +1235,7 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
input_fh = fopen (infile, "rb");
|
||||
if (input_fh == NULL)
|
||||
if (input_fh == nullptr)
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (infile));
|
||||
}
|
||||
|
||||
|
||||
@@ -269,12 +269,12 @@ int main( int argc, char **argv )
|
||||
while( 1 )
|
||||
{
|
||||
int option_index = 0;
|
||||
char *end = NULL;
|
||||
char *end = nullptr;
|
||||
unsigned long outbits;
|
||||
static struct option long_options[] = {
|
||||
{ "help", no_argument, 0, 0 },
|
||||
{ "tag", no_argument, 0, 0 },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
{ nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
||||
c = getopt_long( argc, argv, "a:l:", long_options, &option_index );
|
||||
@@ -351,7 +351,7 @@ int main( int argc, char **argv )
|
||||
|
||||
for( i = optind; i < argc; ++i )
|
||||
{
|
||||
FILE *f = NULL;
|
||||
FILE *f = nullptr;
|
||||
if( argv[i][0] == '-' && argv[i][1] == '\0' )
|
||||
f = stdin;
|
||||
else
|
||||
|
||||
22
src/cat.c
22
src/cat.c
@@ -518,7 +518,7 @@ copy_cat (void)
|
||||
unsupported or the input file seems empty. */
|
||||
|
||||
for (bool some_copied = false; ; some_copied = true)
|
||||
switch (copy_file_range (input_desc, NULL, STDOUT_FILENO, NULL,
|
||||
switch (copy_file_range (input_desc, nullptr, STDOUT_FILENO, nullptr,
|
||||
copy_max, 0))
|
||||
{
|
||||
case 0:
|
||||
@@ -554,16 +554,16 @@ main (int argc, char **argv)
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
@@ -581,7 +581,7 @@ main (int argc, char **argv)
|
||||
/* Parse command line options. */
|
||||
|
||||
int c;
|
||||
while ((c = getopt_long (argc, argv, "benstuvAET", long_options, NULL))
|
||||
while ((c = getopt_long (argc, argv, "benstuvAET", long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -731,7 +731,7 @@ main (int argc, char **argv)
|
||||
out_isreg && S_ISREG (stat_buf.st_mode) ? copy_cat () : 0;
|
||||
if (copy_cat_status != 0)
|
||||
{
|
||||
inbuf = NULL;
|
||||
inbuf = nullptr;
|
||||
ok &= 0 < copy_cat_status;
|
||||
}
|
||||
else
|
||||
|
||||
55
src/chcon.c
55
src/chcon.c
@@ -48,7 +48,7 @@ static bool recurse;
|
||||
static bool verbose;
|
||||
|
||||
/* Pointer to the device and inode numbers of '/', when --recursive.
|
||||
Otherwise NULL. */
|
||||
Otherwise nullptr. */
|
||||
static struct dev_ino *root_dev_ino;
|
||||
|
||||
/* The name of the context file is being given. */
|
||||
@@ -72,20 +72,20 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Given a security context, CONTEXT, derive a context_t (*RET),
|
||||
@@ -141,12 +141,12 @@ compute_context_from_mask (char const *context, context_t *ret)
|
||||
static int
|
||||
change_file_context (int fd, char const *file)
|
||||
{
|
||||
char *file_context = NULL;
|
||||
char *file_context = nullptr;
|
||||
context_t context IF_LINT (= 0);
|
||||
char const * context_string;
|
||||
int errors = 0;
|
||||
|
||||
if (specified_context == NULL)
|
||||
if (specified_context == nullptr)
|
||||
{
|
||||
int status = (affect_symlink_referent
|
||||
? getfileconat (fd, file, &file_context)
|
||||
@@ -162,7 +162,7 @@ change_file_context (int fd, char const *file)
|
||||
/* 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 == NULL)
|
||||
if (file_context == nullptr)
|
||||
{
|
||||
error (0, 0, _("can't apply partial context to unlabeled file %s"),
|
||||
quoteaf (file));
|
||||
@@ -179,7 +179,7 @@ change_file_context (int fd, char const *file)
|
||||
context_string = specified_context;
|
||||
}
|
||||
|
||||
if (file_context == NULL || ! STREQ (context_string, file_context))
|
||||
if (file_context == nullptr || ! STREQ (context_string, file_context))
|
||||
{
|
||||
int fail = (affect_symlink_referent
|
||||
? setfileconat (fd, file, context_string)
|
||||
@@ -193,7 +193,7 @@ change_file_context (int fd, char const *file)
|
||||
}
|
||||
}
|
||||
|
||||
if (specified_context == NULL)
|
||||
if (specified_context == nullptr)
|
||||
{
|
||||
context_free (context);
|
||||
freecon (file_context);
|
||||
@@ -305,7 +305,7 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
}
|
||||
|
||||
/* Recursively operate on the specified FILES (the last entry
|
||||
of which is NULL). BIT_FLAGS controls how fts works.
|
||||
of which is null). BIT_FLAGS controls how fts works.
|
||||
Return true if successful. */
|
||||
|
||||
static bool
|
||||
@@ -313,14 +313,14 @@ process_files (char **files, int bit_flags)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
FTS *fts = xfts_open (files, bit_flags, NULL);
|
||||
FTS *fts = xfts_open (files, bit_flags, nullptr);
|
||||
|
||||
while (true)
|
||||
{
|
||||
FTSENT *ent;
|
||||
|
||||
ent = fts_read (fts);
|
||||
if (ent == NULL)
|
||||
if (ent == nullptr)
|
||||
{
|
||||
if (errno != 0)
|
||||
{
|
||||
@@ -421,7 +421,7 @@ main (int argc, char **argv)
|
||||
bool ok;
|
||||
bool preserve_root = false;
|
||||
bool component_specified = false;
|
||||
char *reference_file = NULL;
|
||||
char *reference_file = nullptr;
|
||||
int optc;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
@@ -432,7 +432,8 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "HLPRhvu:r:t:l:", long_options, NULL))
|
||||
while ((optc = getopt_long (argc, argv, "HLPRhvu:r:t:l:",
|
||||
long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
@@ -542,7 +543,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (reference_file)
|
||||
{
|
||||
char *ref_context = NULL;
|
||||
char *ref_context = nullptr;
|
||||
|
||||
if (getfilecon (reference_file, &ref_context) < 0)
|
||||
die (EXIT_FAILURE, errno, _("failed to get security context of %s"),
|
||||
@@ -553,7 +554,7 @@ main (int argc, char **argv)
|
||||
else if (component_specified)
|
||||
{
|
||||
/* FIXME: it's already null, so this is a no-op. */
|
||||
specified_context = NULL;
|
||||
specified_context = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -574,13 +575,13 @@ main (int argc, char **argv)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (root_dev_ino == NULL)
|
||||
if (root_dev_ino == nullptr)
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
else
|
||||
{
|
||||
root_dev_ino = NULL;
|
||||
root_dev_ino = nullptr;
|
||||
}
|
||||
|
||||
ok = process_files (argv + optind, bit_flags | FTS_NOSTAT);
|
||||
|
||||
30
src/chgrp.c
30
src/chgrp.c
@@ -58,19 +58,19 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"recursive", no_argument, NULL, 'R'},
|
||||
{"changes", no_argument, NULL, 'c'},
|
||||
{"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},
|
||||
{"quiet", no_argument, NULL, 'f'},
|
||||
{"silent", no_argument, NULL, 'f'},
|
||||
{"reference", required_argument, NULL, REFERENCE_FILE_OPTION},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"recursive", no_argument, nullptr, 'R'},
|
||||
{"changes", no_argument, nullptr, 'c'},
|
||||
{"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},
|
||||
{"quiet", no_argument, nullptr, 'f'},
|
||||
{"silent", no_argument, nullptr, 'f'},
|
||||
{"reference", required_argument, nullptr, REFERENCE_FILE_OPTION},
|
||||
{"verbose", no_argument, nullptr, 'v'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Return the group ID of NAME, or -1 if no name was specified. */
|
||||
@@ -88,7 +88,7 @@ parse_group (char const *name)
|
||||
else
|
||||
{
|
||||
uintmax_t tmp;
|
||||
if (! (xstrtoumax (name, NULL, 10, &tmp, "") == LONGINT_OK
|
||||
if (! (xstrtoumax (name, nullptr, 10, &tmp, "") == LONGINT_OK
|
||||
&& tmp <= GID_T_MAX))
|
||||
die (EXIT_FAILURE, 0, _("invalid group: %s"),
|
||||
quote (name));
|
||||
@@ -196,7 +196,7 @@ main (int argc, char **argv)
|
||||
|
||||
chopt_init (&chopt);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, NULL))
|
||||
while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
@@ -295,7 +295,7 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
char *group_name = argv[optind++];
|
||||
chopt.group_name = (*group_name ? xstrdup (group_name) : NULL);
|
||||
chopt.group_name = (*group_name ? xstrdup (group_name) : nullptr);
|
||||
gid = parse_group (group_name);
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (chopt.root_dev_ino == NULL)
|
||||
if (chopt.root_dev_ino == nullptr)
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
|
||||
41
src/chmod.c
41
src/chmod.c
@@ -87,7 +87,7 @@ static bool diagnose_surprises;
|
||||
static enum Verbosity verbosity = V_off;
|
||||
|
||||
/* Pointer to the device and inode numbers of '/', when --recursive.
|
||||
Otherwise NULL. */
|
||||
Otherwise nullptr. */
|
||||
static struct dev_ino *root_dev_ino;
|
||||
|
||||
/* For long options that have no equivalent short option, use a
|
||||
@@ -101,17 +101,17 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"changes", no_argument, NULL, 'c'},
|
||||
{"recursive", no_argument, NULL, 'R'},
|
||||
{"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'},
|
||||
{"changes", no_argument, nullptr, 'c'},
|
||||
{"recursive", no_argument, nullptr, 'R'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Return true if the chmodable permission bits of FILE changed.
|
||||
@@ -277,7 +277,7 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
{
|
||||
ch.old_mode = file_stats->st_mode;
|
||||
ch.new_mode = mode_adjust (ch.old_mode, S_ISDIR (ch.old_mode) != 0,
|
||||
umask_value, change, NULL);
|
||||
umask_value, change, nullptr);
|
||||
if (chmodat (fts->fts_cwd_fd, file, ch.new_mode) == 0)
|
||||
ch.status = CH_SUCCEEDED;
|
||||
else
|
||||
@@ -303,7 +303,8 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
if (CH_NO_CHANGE_REQUESTED <= ch.status && diagnose_surprises)
|
||||
{
|
||||
mode_t naively_expected_mode =
|
||||
mode_adjust (ch.old_mode, S_ISDIR (ch.old_mode) != 0, 0, change, NULL);
|
||||
mode_adjust (ch.old_mode, S_ISDIR (ch.old_mode) != 0,
|
||||
0, change, nullptr);
|
||||
if (ch.new_mode & ~naively_expected_mode)
|
||||
{
|
||||
char new_perms[12];
|
||||
@@ -326,7 +327,7 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
}
|
||||
|
||||
/* Recursively change the modes of the specified FILES (the last entry
|
||||
of which is NULL). BIT_FLAGS controls how fts works.
|
||||
of which is null). BIT_FLAGS controls how fts works.
|
||||
Return true if successful. */
|
||||
|
||||
static bool
|
||||
@@ -334,14 +335,14 @@ process_files (char **files, int bit_flags)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
FTS *fts = xfts_open (files, bit_flags, NULL);
|
||||
FTS *fts = xfts_open (files, bit_flags, nullptr);
|
||||
|
||||
while (true)
|
||||
{
|
||||
FTSENT *ent;
|
||||
|
||||
ent = fts_read (fts);
|
||||
if (ent == NULL)
|
||||
if (ent == nullptr)
|
||||
{
|
||||
if (errno != 0)
|
||||
{
|
||||
@@ -416,12 +417,12 @@ Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.\n\
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char *mode = NULL;
|
||||
char *mode = nullptr;
|
||||
idx_t mode_len = 0;
|
||||
idx_t mode_alloc = 0;
|
||||
bool ok;
|
||||
bool preserve_root = false;
|
||||
char const *reference_file = NULL;
|
||||
char const *reference_file = nullptr;
|
||||
int c;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
@@ -437,7 +438,7 @@ main (int argc, char **argv)
|
||||
while ((c = getopt_long (argc, argv,
|
||||
("Rcfvr::w::x::X::s::t::u::g::o::a::,::+::=::"
|
||||
"0::1::2::3::4::5::6::7::"),
|
||||
long_options, NULL))
|
||||
long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -555,13 +556,13 @@ main (int argc, char **argv)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (root_dev_ino == NULL)
|
||||
if (root_dev_ino == nullptr)
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
else
|
||||
{
|
||||
root_dev_ino = NULL;
|
||||
root_dev_ino = nullptr;
|
||||
}
|
||||
|
||||
ok = process_files (argv + optind,
|
||||
|
||||
@@ -58,12 +58,12 @@ extern void
|
||||
chopt_init (struct Chown_option *chopt)
|
||||
{
|
||||
chopt->verbosity = V_off;
|
||||
chopt->root_dev_ino = NULL;
|
||||
chopt->root_dev_ino = nullptr;
|
||||
chopt->affect_symlink_referent = true;
|
||||
chopt->recurse = false;
|
||||
chopt->force_silent = false;
|
||||
chopt->user_name = NULL;
|
||||
chopt->group_name = NULL;
|
||||
chopt->user_name = nullptr;
|
||||
chopt->group_name = nullptr;
|
||||
}
|
||||
|
||||
extern void
|
||||
@@ -122,7 +122,7 @@ uid_to_name (uid_t uid)
|
||||
static char *
|
||||
user_group_str (char const *user, char const *group)
|
||||
{
|
||||
char *spec = NULL;
|
||||
char *spec = nullptr;
|
||||
|
||||
if (user)
|
||||
{
|
||||
@@ -145,7 +145,7 @@ user_group_str (char const *user, char const *group)
|
||||
}
|
||||
|
||||
/* Tell the user how/if the user and group of FILE have been changed.
|
||||
If USER is NULL, give the group-oriented messages.
|
||||
If USER is null, give the group-oriented messages.
|
||||
CHANGED describes what (if anything) has happened. */
|
||||
|
||||
static void
|
||||
@@ -165,7 +165,8 @@ describe_change (char const *file, enum Change_status changed,
|
||||
}
|
||||
|
||||
spec = user_group_str (user, group);
|
||||
old_spec = user_group_str (user ? old_user : NULL, group ? old_group : NULL);
|
||||
old_spec = user_group_str (user ? old_user : nullptr,
|
||||
group ? old_group : nullptr);
|
||||
|
||||
switch (changed)
|
||||
{
|
||||
@@ -188,7 +189,7 @@ describe_change (char const *file, enum Change_status changed,
|
||||
: _("failed to change ownership of %s\n"));
|
||||
free (old_spec);
|
||||
old_spec = spec;
|
||||
spec = NULL;
|
||||
spec = nullptr;
|
||||
}
|
||||
break;
|
||||
case CH_NO_CHANGE_REQUESTED:
|
||||
@@ -370,7 +371,7 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
if (!ok)
|
||||
{
|
||||
do_chown = false;
|
||||
file_stats = NULL;
|
||||
file_stats = nullptr;
|
||||
}
|
||||
else if (required_uid == (uid_t) -1 && required_gid == (gid_t) -1
|
||||
&& chopt->verbosity == V_off
|
||||
@@ -498,14 +499,16 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
: !symlink_changed ? CH_NOT_APPLIED
|
||||
: !changed ? CH_NO_CHANGE_REQUESTED
|
||||
: CH_SUCCEEDED);
|
||||
char *old_usr = file_stats ? uid_to_name (file_stats->st_uid) : NULL;
|
||||
char *old_grp = file_stats ? gid_to_name (file_stats->st_gid) : NULL;
|
||||
char *old_usr = (file_stats
|
||||
? uid_to_name (file_stats->st_uid) : nullptr);
|
||||
char *old_grp = (file_stats
|
||||
? gid_to_name (file_stats->st_gid) : nullptr);
|
||||
char *new_usr = chopt->user_name
|
||||
? chopt->user_name : uid != -1
|
||||
? uid_to_str (uid) : NULL;
|
||||
? uid_to_str (uid) : nullptr;
|
||||
char *new_grp = chopt->group_name
|
||||
? chopt->group_name : gid != -1
|
||||
? gid_to_str (gid) : NULL;
|
||||
? gid_to_str (gid) : nullptr;
|
||||
describe_change (file_full_name, ch_status,
|
||||
old_usr, old_grp,
|
||||
new_usr, new_grp);
|
||||
@@ -548,14 +551,14 @@ chown_files (char **files, int bit_flags,
|
||||
? 0
|
||||
: FTS_NOSTAT);
|
||||
|
||||
FTS *fts = xfts_open (files, bit_flags | stat_flags, NULL);
|
||||
FTS *fts = xfts_open (files, bit_flags | stat_flags, nullptr);
|
||||
|
||||
while (true)
|
||||
{
|
||||
FTSENT *ent;
|
||||
|
||||
ent = fts_read (fts);
|
||||
if (ent == NULL)
|
||||
if (ent == nullptr)
|
||||
{
|
||||
if (errno != 0)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ struct Chown_option
|
||||
bool recurse;
|
||||
|
||||
/* Pointer to the device and inode numbers of '/', when --recursive.
|
||||
Need not be freed. Otherwise NULL. */
|
||||
Need not be freed. Otherwise nullptr. */
|
||||
struct dev_ino *root_dev_ino;
|
||||
|
||||
/* This corresponds to the --dereference (opposite of -h) option. */
|
||||
|
||||
30
src/chown.c
30
src/chown.c
@@ -54,20 +54,20 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -187,7 +187,7 @@ main (int argc, char **argv)
|
||||
|
||||
chopt_init (&chopt);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, NULL))
|
||||
while ((optc = getopt_long (argc, argv, "HLPRcfhv", long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
@@ -230,7 +230,7 @@ main (int argc, char **argv)
|
||||
bool warn;
|
||||
char const *e = parse_user_spec_warn (optarg,
|
||||
&required_uid, &required_gid,
|
||||
NULL, NULL, &warn);
|
||||
nullptr, nullptr, &warn);
|
||||
if (e)
|
||||
error (warn ? 0 : EXIT_FAILURE, 0, "%s: %s", e, quote (optarg));
|
||||
break;
|
||||
@@ -318,7 +318,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (chopt.root_dev_ino == NULL)
|
||||
if (chopt.root_dev_ino == nullptr)
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
|
||||
42
src/chroot.c
42
src/chroot.c
@@ -56,12 +56,12 @@ enum
|
||||
|
||||
static struct option const long_opts[] =
|
||||
{
|
||||
{"groups", required_argument, NULL, GROUPS},
|
||||
{"userspec", required_argument, NULL, USERSPEC},
|
||||
{"skip-chdir", no_argument, NULL, SKIP_CHDIR},
|
||||
{"groups", required_argument, nullptr, GROUPS},
|
||||
{"userspec", required_argument, nullptr, USERSPEC},
|
||||
{"skip-chdir", no_argument, nullptr, SKIP_CHDIR},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
#if ! HAVE_SETGROUPS
|
||||
@@ -96,19 +96,19 @@ static int
|
||||
parse_additional_groups (char const *groups, GETGROUPS_T **pgids,
|
||||
size_t *pn_gids, bool show_errors)
|
||||
{
|
||||
GETGROUPS_T *gids = NULL;
|
||||
GETGROUPS_T *gids = nullptr;
|
||||
size_t n_gids_allocated = 0;
|
||||
size_t n_gids = 0;
|
||||
char *buffer = xstrdup (groups);
|
||||
char const *tmp;
|
||||
int ret = 0;
|
||||
|
||||
for (tmp = strtok (buffer, ","); tmp; tmp = strtok (NULL, ","))
|
||||
for (tmp = strtok (buffer, ","); tmp; tmp = strtok (nullptr, ","))
|
||||
{
|
||||
struct group *g;
|
||||
uintmax_t value;
|
||||
|
||||
if (xstrtoumax (tmp, NULL, 10, &value, "") == LONGINT_OK
|
||||
if (xstrtoumax (tmp, nullptr, 10, &value, "") == LONGINT_OK
|
||||
&& value <= MAXGID)
|
||||
{
|
||||
while (isspace (to_uchar (*tmp)))
|
||||
@@ -117,20 +117,20 @@ parse_additional_groups (char const *groups, GETGROUPS_T **pgids,
|
||||
{
|
||||
/* Handle the case where the name is numeric. */
|
||||
g = getgrnam (tmp);
|
||||
if (g != NULL)
|
||||
if (g != nullptr)
|
||||
value = g->gr_gid;
|
||||
}
|
||||
/* Flag that we've got a group from the number. */
|
||||
g = (struct group *) (intptr_t) ! NULL;
|
||||
g = (struct group *) (intptr_t) ! nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
g = getgrnam (tmp);
|
||||
if (g != NULL)
|
||||
if (g != nullptr)
|
||||
value = g->gr_gid;
|
||||
}
|
||||
|
||||
if (g == NULL)
|
||||
if (g == nullptr)
|
||||
{
|
||||
ret = -1;
|
||||
|
||||
@@ -222,15 +222,15 @@ main (int argc, char **argv)
|
||||
int c;
|
||||
|
||||
/* Input user and groups spec. */
|
||||
char *userspec = NULL;
|
||||
char const *username = NULL;
|
||||
char const *groups = NULL;
|
||||
char *userspec = nullptr;
|
||||
char const *username = nullptr;
|
||||
char const *groups = nullptr;
|
||||
bool skip_chdir = false;
|
||||
|
||||
/* Parsed user and group IDs. */
|
||||
uid_t uid = -1;
|
||||
gid_t gid = -1;
|
||||
GETGROUPS_T *out_gids = NULL;
|
||||
GETGROUPS_T *out_gids = nullptr;
|
||||
size_t n_gids = 0;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
@@ -242,7 +242,7 @@ main (int argc, char **argv)
|
||||
initialize_exit_failure (EXIT_CANCELED);
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "+", long_opts, NULL)) != -1)
|
||||
while ((c = getopt_long (argc, argv, "+", long_opts, nullptr)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
@@ -300,7 +300,7 @@ main (int argc, char **argv)
|
||||
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, NULL, NULL));
|
||||
ignore_value (parse_user_spec (userspec, &uid, &gid, nullptr, nullptr));
|
||||
|
||||
/* If no gid is supplied or looked up, do so now.
|
||||
Also lookup the username for use with getgroups. */
|
||||
@@ -339,11 +339,11 @@ main (int argc, char **argv)
|
||||
{
|
||||
/* No command. Run an interactive shell. */
|
||||
char *shell = getenv ("SHELL");
|
||||
if (shell == NULL)
|
||||
if (shell == nullptr)
|
||||
shell = bad_cast ("/bin/sh");
|
||||
argv[0] = shell;
|
||||
argv[1] = bad_cast ("-i");
|
||||
argv[2] = NULL;
|
||||
argv[2] = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -357,7 +357,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
bool warn;
|
||||
char const *err = parse_user_spec_warn (userspec, &uid, &gid,
|
||||
NULL, NULL, &warn);
|
||||
nullptr, nullptr, &warn);
|
||||
if (err)
|
||||
error (warn ? 0 : EXIT_CANCELED, 0, "%s", (err));
|
||||
}
|
||||
@@ -381,7 +381,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
GETGROUPS_T *gids = out_gids;
|
||||
GETGROUPS_T *in_gids = NULL;
|
||||
GETGROUPS_T *in_gids = nullptr;
|
||||
if (groups && *groups)
|
||||
{
|
||||
if (parse_additional_groups (groups, &in_gids, &n_gids, !n_gids) != 0)
|
||||
|
||||
16
src/comm.c
16
src/comm.c
@@ -91,14 +91,14 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
|
||||
@@ -258,7 +258,7 @@ compare_files (char **infiles)
|
||||
struct linebuffer lba[2][4];
|
||||
|
||||
/* thisline[i] points to the linebuffer holding the next available line
|
||||
in file i, or is NULL if there are no lines left in that file. */
|
||||
in file i, or is null if there are no lines left in that file. */
|
||||
struct linebuffer *thisline[2];
|
||||
|
||||
/* all_line[i][alt[i][0]] also points to the linebuffer holding the
|
||||
@@ -443,7 +443,7 @@ main (int argc, char **argv)
|
||||
check_input_order = CHECK_ORDER_DEFAULT;
|
||||
total_option = false;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "123z", long_options, NULL)) != -1)
|
||||
while ((c = getopt_long (argc, argv, "123z", long_options, nullptr)) != -1)
|
||||
switch (c)
|
||||
{
|
||||
case '1':
|
||||
|
||||
52
src/copy.c
52
src/copy.c
@@ -339,7 +339,7 @@ sparse_copy (int src_fd, int dest_fd, char **abuf, size_t buf_size,
|
||||
(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, NULL, dest_fd, NULL,
|
||||
ssize_t n_copied = copy_file_range (src_fd, nullptr, dest_fd, nullptr,
|
||||
MIN (max_n_read, copy_max), 0);
|
||||
if (n_copied == 0)
|
||||
{
|
||||
@@ -513,11 +513,11 @@ write_zeros (int fd, off_t n_bytes)
|
||||
/* Attempt to use a relatively large calloc'd source buffer for
|
||||
efficiency, but if that allocation fails, resort to a smaller
|
||||
statically allocated one. */
|
||||
if (zeros == NULL)
|
||||
if (zeros == nullptr)
|
||||
{
|
||||
static char fallback[1024];
|
||||
zeros = calloc (nz, 1);
|
||||
if (zeros == NULL)
|
||||
if (zeros == nullptr)
|
||||
{
|
||||
zeros = fallback;
|
||||
nz = sizeof fallback;
|
||||
@@ -770,7 +770,7 @@ copy_attr (char const *src_path, int src_fd,
|
||||
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 : NULL);
|
||||
? check_selinux_attr : nullptr);
|
||||
|
||||
# if 4 < __GNUC__ + (8 <= __GNUC_MINOR__)
|
||||
/* Pacify gcc -Wsuggest-attribute=format through at least GCC 11.2.1. */
|
||||
@@ -784,7 +784,7 @@ copy_attr (char const *src_path, int src_fd,
|
||||
.quote = copy_attr_quote,
|
||||
.quote_free = copy_attr_free
|
||||
})
|
||||
: NULL);
|
||||
: nullptr);
|
||||
# if 4 < __GNUC__ + (8 <= __GNUC_MINOR__)
|
||||
# pragma GCC diagnostic pop
|
||||
# endif
|
||||
@@ -833,7 +833,7 @@ copy_dir (char const *src_name_in, char const *dst_name_in,
|
||||
bool ok = true;
|
||||
|
||||
name_space = savedir (src_name_in, SAVEDIR_SORT_FASTREAD);
|
||||
if (name_space == NULL)
|
||||
if (name_space == nullptr)
|
||||
{
|
||||
/* This diagnostic is a bit vague because savedir can fail in
|
||||
several different ways. */
|
||||
@@ -851,8 +851,8 @@ copy_dir (char const *src_name_in, char const *dst_name_in,
|
||||
while (*namep != '\0')
|
||||
{
|
||||
bool local_copy_into_self;
|
||||
char *src_name = file_name_concat (src_name_in, namep, NULL);
|
||||
char *dst_name = file_name_concat (dst_name_in, namep, NULL);
|
||||
char *src_name = file_name_concat (src_name_in, namep, nullptr);
|
||||
char *dst_name = file_name_concat (dst_name_in, namep, nullptr);
|
||||
bool first_dir_created = *first_dir_created_per_command_line_arg;
|
||||
bool rename_succeeded;
|
||||
|
||||
@@ -982,7 +982,7 @@ set_author (char const *dst_name, int dest_desc, const struct stat *src_sb)
|
||||
file_t file = (dest_desc < 0
|
||||
? file_name_lookup (dst_name, 0, 0)
|
||||
: getdport (dest_desc));
|
||||
if (file == MACH_PORT_NULL)
|
||||
if (file == MACH_PORT_nullptr)
|
||||
error (0, errno, _("failed to lookup file %s"), quoteaf (dst_name));
|
||||
else
|
||||
{
|
||||
@@ -1237,7 +1237,7 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
mode_t dst_mode, mode_t omitted_permissions, bool *new_dst,
|
||||
struct stat const *src_sb)
|
||||
{
|
||||
char *buf = NULL;
|
||||
char *buf = nullptr;
|
||||
int dest_desc;
|
||||
int dest_errno;
|
||||
int source_desc;
|
||||
@@ -2018,7 +2018,7 @@ dest_info_init (struct cp_options *x)
|
||||
{
|
||||
x->dest_info
|
||||
= hash_initialize (DEST_INFO_INITIAL_CAPACITY,
|
||||
NULL,
|
||||
nullptr,
|
||||
triple_hash,
|
||||
triple_compare,
|
||||
triple_free);
|
||||
@@ -2042,7 +2042,7 @@ src_info_init (struct cp_options *x)
|
||||
*/
|
||||
x->src_info
|
||||
= hash_initialize (DEST_INFO_INITIAL_CAPACITY,
|
||||
NULL,
|
||||
nullptr,
|
||||
triple_hash_no_name,
|
||||
triple_compare,
|
||||
triple_free);
|
||||
@@ -2075,7 +2075,7 @@ abandon_move (const struct cp_options *x,
|
||||
}
|
||||
|
||||
/* Print --verbose output on standard output, e.g. 'new' -> 'old'.
|
||||
If BACKUP_DST_NAME is non-NULL, then also indicate that it is
|
||||
If BACKUP_DST_NAME is non-null, then also indicate that it is
|
||||
the name of a backup file. */
|
||||
static void
|
||||
emit_verbose (char const *src, char const *dst, char const *backup_dst_name)
|
||||
@@ -2086,11 +2086,11 @@ emit_verbose (char const *src, char const *dst, char const *backup_dst_name)
|
||||
putchar ('\n');
|
||||
}
|
||||
|
||||
/* A wrapper around "setfscreatecon (NULL)" that exits upon failure. */
|
||||
/* A wrapper around "setfscreatecon (nullptr)" that exits upon failure. */
|
||||
static void
|
||||
restore_default_fscreatecon_or_die (void)
|
||||
{
|
||||
if (setfscreatecon (NULL) != 0)
|
||||
if (setfscreatecon (nullptr) != 0)
|
||||
die (EXIT_FAILURE, errno,
|
||||
_("failed to restore the default file creation context"));
|
||||
}
|
||||
@@ -2128,7 +2128,7 @@ create_hard_link (char const *src_name, int src_dirfd, char const *src_relname,
|
||||
if (0 < err)
|
||||
{
|
||||
|
||||
char *a_src_name = NULL;
|
||||
char *a_src_name = nullptr;
|
||||
if (!src_name)
|
||||
src_name = a_src_name = subst_suffix (dst_name, dst_relname,
|
||||
src_relname);
|
||||
@@ -2211,8 +2211,8 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
mode_t dst_mode_bits;
|
||||
mode_t omitted_permissions;
|
||||
bool restore_dst_mode = false;
|
||||
char *earlier_file = NULL;
|
||||
char *dst_backup = NULL;
|
||||
char *earlier_file = nullptr;
|
||||
char *dst_backup = nullptr;
|
||||
char const *drelname = *dst_relname ? dst_relname : ".";
|
||||
bool delayed_ok;
|
||||
bool copied_as_regular = false;
|
||||
@@ -2275,7 +2275,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
/* Detect the case in which the same source file appears more than
|
||||
once on the command line and no backup option has been selected.
|
||||
If so, simply warn and don't copy it the second time.
|
||||
This check is enabled only if x->src_info is non-NULL. */
|
||||
This check is enabled only if x->src_info is non-null. */
|
||||
if (command_line_arg && x->src_info)
|
||||
{
|
||||
if ( ! S_ISDIR (src_mode)
|
||||
@@ -2382,7 +2382,7 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
{
|
||||
/* Note we currently replace DST_NAME unconditionally,
|
||||
even if it was a newer separate file. */
|
||||
if (! create_hard_link (NULL, dst_dirfd, earlier_file,
|
||||
if (! create_hard_link (nullptr, dst_dirfd, earlier_file,
|
||||
dst_name, dst_dirfd, dst_relname,
|
||||
true,
|
||||
x->verbose, dereference))
|
||||
@@ -2659,7 +2659,7 @@ skip:
|
||||
We'll use that info to detect this problem: cp -R dir dir. */
|
||||
|
||||
if (rename_errno == 0)
|
||||
earlier_file = NULL;
|
||||
earlier_file = nullptr;
|
||||
else if (x->recursive && S_ISDIR (src_mode))
|
||||
{
|
||||
if (command_line_arg)
|
||||
@@ -2742,7 +2742,7 @@ skip:
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! create_hard_link (NULL, dst_dirfd, earlier_file,
|
||||
if (! create_hard_link (nullptr, dst_dirfd, earlier_file,
|
||||
dst_name, dst_dirfd, dst_relname,
|
||||
true, x->verbose, dereference))
|
||||
goto un_backup;
|
||||
@@ -2970,7 +2970,7 @@ skip:
|
||||
if (x->move_mode)
|
||||
printf (_("created directory %s\n"), quoteaf (dst_name));
|
||||
else
|
||||
emit_verbose (src_name, dst_name, NULL);
|
||||
emit_verbose (src_name, dst_name, nullptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3118,7 +3118,7 @@ skip:
|
||||
{
|
||||
char *src_link_val = areadlink_with_size (src_name, src_sb.st_size);
|
||||
dest_is_symlink = true;
|
||||
if (src_link_val == NULL)
|
||||
if (src_link_val == nullptr)
|
||||
{
|
||||
error (0, errno, _("cannot read symbolic link %s"),
|
||||
quoteaf (src_name));
|
||||
@@ -3340,7 +3340,7 @@ un_backup:
|
||||
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 == NULL)
|
||||
if (earlier_file == nullptr)
|
||||
forget_created (src_sb.st_ino, src_sb.st_dev);
|
||||
|
||||
if (dst_backup)
|
||||
@@ -3403,7 +3403,7 @@ copy (char const *src_name, char const *dst_name,
|
||||
|
||||
bool first_dir_created_per_command_line_arg = false;
|
||||
return copy_internal (src_name, dst_name, dst_dirfd, dst_relname,
|
||||
nonexistent_dst, NULL, NULL,
|
||||
nonexistent_dst, nullptr, nullptr,
|
||||
options, true,
|
||||
&first_dir_created_per_command_line_arg,
|
||||
copy_into_self, rename_succeeded);
|
||||
|
||||
@@ -286,7 +286,7 @@ struct cp_options
|
||||
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 NULL to disable
|
||||
Use dest_info_init to initialize it, or set it to nullptr to disable
|
||||
this feature. */
|
||||
Hash_table *dest_info;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ static struct option const long_options[] =
|
||||
{
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ Use: '%s --coreutils-prog=PROGRAM_NAME --help' for individual program help.\n"),
|
||||
static void
|
||||
launch_program (char const *prog_name, int prog_argc, char **prog_argv)
|
||||
{
|
||||
int (*prog_main) (int, char **) = NULL;
|
||||
int (*prog_main) (int, char **) = nullptr;
|
||||
|
||||
/* Ensure that at least one parameter was passed. */
|
||||
if (!prog_argc || !prog_argv || !prog_argv[0] || !prog_name)
|
||||
@@ -153,7 +153,7 @@ main (int argc, char **argv)
|
||||
if (argc >= 2)
|
||||
{
|
||||
size_t nskip = 0;
|
||||
char *arg_name = NULL;
|
||||
char *arg_name = nullptr;
|
||||
|
||||
/* If calling coreutils directly, the "script" name isn't passed.
|
||||
Distinguish the two cases with a -shebang suffix. */
|
||||
@@ -190,7 +190,7 @@ main (int argc, char **argv)
|
||||
textdomain (PACKAGE);
|
||||
atexit (close_stdout);
|
||||
|
||||
if ((optc = getopt_long (argc, argv, "", long_options, NULL)) != -1)
|
||||
if ((optc = getopt_long (argc, argv, "", long_options, nullptr)) != -1)
|
||||
switch (optc)
|
||||
{
|
||||
case_GETOPT_HELP_CHAR;
|
||||
|
||||
@@ -86,7 +86,7 @@ forget_created (ino_t ino, dev_t dev)
|
||||
|
||||
probe.st_ino = ino;
|
||||
probe.st_dev = dev;
|
||||
probe.name = NULL;
|
||||
probe.name = nullptr;
|
||||
|
||||
ent = hash_remove (src_to_dest, &probe);
|
||||
if (ent)
|
||||
@@ -94,7 +94,7 @@ forget_created (ino_t ino, dev_t dev)
|
||||
}
|
||||
|
||||
/* If INO/DEV correspond to an already-copied source file, return the
|
||||
name of the corresponding destination file. Otherwise, return NULL. */
|
||||
name of the corresponding destination file. Otherwise, return nullptr. */
|
||||
|
||||
extern char *
|
||||
src_to_dest_lookup (ino_t ino, dev_t dev)
|
||||
@@ -104,12 +104,12 @@ 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 : NULL;
|
||||
return e ? e->name : nullptr;
|
||||
}
|
||||
|
||||
/* Add file NAME, copied from inode number INO and device number DEV,
|
||||
to the list of files we have copied.
|
||||
Return NULL if inserted, otherwise non-NULL. */
|
||||
Return nullptr if inserted, otherwise a non-null pointer. */
|
||||
|
||||
extern char *
|
||||
remember_copied (char const *name, ino_t ino, dev_t dev)
|
||||
@@ -123,7 +123,7 @@ 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 == NULL)
|
||||
if (ent_from_table == nullptr)
|
||||
{
|
||||
/* Insertion failed due to lack of memory. */
|
||||
xalloc_die ();
|
||||
@@ -139,17 +139,17 @@ remember_copied (char const *name, ino_t ino, dev_t dev)
|
||||
}
|
||||
|
||||
/* New key; insertion succeeded. */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Initialize the hash table. */
|
||||
extern void
|
||||
hash_init (void)
|
||||
{
|
||||
src_to_dest = hash_initialize (INITIAL_TABLE_SIZE, NULL,
|
||||
src_to_dest = hash_initialize (INITIAL_TABLE_SIZE, nullptr,
|
||||
src_to_dest_hash,
|
||||
src_to_dest_compare,
|
||||
src_to_dest_free);
|
||||
if (src_to_dest == NULL)
|
||||
if (src_to_dest == nullptr)
|
||||
xalloc_die ();
|
||||
}
|
||||
|
||||
103
src/cp.c
103
src/cp.c
@@ -84,7 +84,7 @@ static bool remove_trailing_slashes;
|
||||
|
||||
static char const *const sparse_type_string[] =
|
||||
{
|
||||
"never", "auto", "always", NULL
|
||||
"never", "auto", "always", nullptr
|
||||
};
|
||||
static enum Sparse_type const sparse_type[] =
|
||||
{
|
||||
@@ -94,7 +94,7 @@ ARGMATCH_VERIFY (sparse_type_string, sparse_type);
|
||||
|
||||
static char const *const reflink_type_string[] =
|
||||
{
|
||||
"auto", "always", "never", NULL
|
||||
"auto", "always", "never", nullptr
|
||||
};
|
||||
static enum Reflink_type const reflink_type[] =
|
||||
{
|
||||
@@ -104,7 +104,7 @@ ARGMATCH_VERIFY (reflink_type_string, reflink_type);
|
||||
|
||||
static char const *const update_type_string[] =
|
||||
{
|
||||
"all", "none", "older", NULL
|
||||
"all", "none", "older", nullptr
|
||||
};
|
||||
static enum Update_type const update_type[] =
|
||||
{
|
||||
@@ -114,37 +114,38 @@ ARGMATCH_VERIFY (update_type_string, update_type);
|
||||
|
||||
static struct option const long_opts[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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, NULL, 'S'},
|
||||
{"symbolic-link", no_argument, NULL, 's'},
|
||||
{"target-directory", required_argument, NULL, 't'},
|
||||
{"update", optional_argument, NULL, 'u'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"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'},
|
||||
{"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,
|
||||
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'},
|
||||
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -408,7 +409,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
|
||||
char *dst_dir; /* Leading directory of DIR. */
|
||||
idx_t dirlen = dir_len (const_dir);
|
||||
|
||||
*attr_list = NULL;
|
||||
*attr_list = nullptr;
|
||||
|
||||
/* Succeed immediately if the parent of CONST_DIR must already exist,
|
||||
as the target directory has already been checked. */
|
||||
@@ -517,7 +518,7 @@ make_dir_parents_private (char const *const_dir, size_t src_offset,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (verbose_fmt_string != NULL)
|
||||
if (verbose_fmt_string != nullptr)
|
||||
printf (verbose_fmt_string, src, dir);
|
||||
}
|
||||
|
||||
@@ -726,7 +727,7 @@ do_copy (int n_files, char **file, char const *target_directory,
|
||||
parent_exists =
|
||||
(make_dir_parents_private
|
||||
(dst_name, arg_in_concat - dst_name, target_dirfd,
|
||||
(x->verbose ? "%s -> %s\n" : NULL),
|
||||
(x->verbose ? "%s -> %s\n" : nullptr),
|
||||
&attr_list, &new_dst, x));
|
||||
}
|
||||
else
|
||||
@@ -755,7 +756,7 @@ do_copy (int n_files, char **file, char const *target_directory,
|
||||
|
||||
bool copy_into_self;
|
||||
ok &= copy (arg, dst_name, target_dirfd, dst_relname,
|
||||
new_dst, x, ©_into_self, NULL);
|
||||
new_dst, x, ©_into_self, nullptr);
|
||||
|
||||
if (parents_option)
|
||||
ok &= re_protect (dst_name, arg_in_concat, target_dirfd,
|
||||
@@ -813,7 +814,7 @@ do_copy (int n_files, char **file, char const *target_directory,
|
||||
x = &x_tmp;
|
||||
}
|
||||
|
||||
ok = copy (source, dest, AT_FDCWD, dest, -new_dst, x, &unused, NULL);
|
||||
ok = copy (source, dest, AT_FDCWD, dest, -new_dst, x, &unused, nullptr);
|
||||
}
|
||||
|
||||
return ok;
|
||||
@@ -841,7 +842,7 @@ cp_option_init (struct cp_options *x)
|
||||
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 = NULL; /* -Z, set sys default context. */
|
||||
x->set_security_context = nullptr; /* -Z, set sys default context. */
|
||||
x->preserve_xattr = false;
|
||||
x->reduce_diagnostics = false;
|
||||
x->require_preserve_xattr = false;
|
||||
@@ -864,10 +865,10 @@ cp_option_init (struct cp_options *x)
|
||||
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") != NULL;
|
||||
x->open_dangling_dest_symlink = getenv ("POSIXLY_CORRECT") != nullptr;
|
||||
|
||||
x->dest_info = NULL;
|
||||
x->src_info = NULL;
|
||||
x->dest_info = nullptr;
|
||||
x->src_info = nullptr;
|
||||
}
|
||||
|
||||
/* Given a string, ARG, containing a comma-separated list of arguments
|
||||
@@ -895,7 +896,7 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off)
|
||||
static char const *const preserve_args[] =
|
||||
{
|
||||
"mode", "timestamps",
|
||||
"ownership", "links", "context", "xattr", "all", NULL
|
||||
"ownership", "links", "context", "xattr", "all", nullptr
|
||||
};
|
||||
ARGMATCH_VERIFY (preserve_args, preserve_vals);
|
||||
|
||||
@@ -970,13 +971,13 @@ main (int argc, char **argv)
|
||||
int c;
|
||||
bool ok;
|
||||
bool make_backups = false;
|
||||
char const *backup_suffix = NULL;
|
||||
char *version_control_string = NULL;
|
||||
char const *backup_suffix = nullptr;
|
||||
char *version_control_string = nullptr;
|
||||
struct cp_options x;
|
||||
bool copy_contents = false;
|
||||
char *target_directory = NULL;
|
||||
char *target_directory = nullptr;
|
||||
bool no_target_directory = false;
|
||||
char const *scontext = NULL;
|
||||
char const *scontext = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -990,7 +991,7 @@ main (int argc, char **argv)
|
||||
cp_option_init (&x);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "abdfHilLnprst:uvxPRS:TZ",
|
||||
long_opts, NULL))
|
||||
long_opts, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -1001,7 +1002,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case REFLINK_OPTION:
|
||||
if (optarg == NULL)
|
||||
if (optarg == nullptr)
|
||||
x.reflink_mode = REFLINK_ALWAYS;
|
||||
else
|
||||
x.reflink_mode = XARGMATCH ("--reflink", optarg,
|
||||
@@ -1079,7 +1080,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case PRESERVE_ATTRIBUTES_OPTION:
|
||||
if (optarg == NULL)
|
||||
if (optarg == nullptr)
|
||||
{
|
||||
/* Fall through to the case for 'p' below. */
|
||||
}
|
||||
@@ -1131,7 +1132,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
if (optarg == NULL)
|
||||
if (optarg == nullptr)
|
||||
x.update = true;
|
||||
else if (x.interactive != I_ALWAYS_NO) /* -n takes precedence. */
|
||||
{
|
||||
@@ -1174,7 +1175,7 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
x.set_security_context = selabel_open (SELABEL_CTX_FILE,
|
||||
NULL, 0);
|
||||
nullptr, 0);
|
||||
if (! x.set_security_context)
|
||||
error (0, errno, _("warning: ignoring --context"));
|
||||
}
|
||||
@@ -1258,7 +1259,7 @@ main (int argc, char **argv)
|
||||
/* 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 (NULL, dst_path, 0))
|
||||
if (scontext && !restorecon (nullptr, dst_path, 0))
|
||||
error (...);
|
||||
*/
|
||||
if (scontext && setfscreatecon (scontext) < 0)
|
||||
|
||||
129
src/csplit.c
129
src/csplit.c
@@ -113,10 +113,10 @@ static void delete_all_files (bool);
|
||||
static void save_line_to_file (const struct cstring *line);
|
||||
|
||||
/* Start of buffer list. */
|
||||
static struct buffer_record *head = NULL;
|
||||
static struct buffer_record *head = nullptr;
|
||||
|
||||
/* Partially read line. */
|
||||
static char *hold_area = NULL;
|
||||
static char *hold_area = nullptr;
|
||||
|
||||
/* Number of bytes in 'hold_area'. */
|
||||
static idx_t hold_count = 0;
|
||||
@@ -131,13 +131,13 @@ static intmax_t current_line = 0;
|
||||
static bool have_read_eof = false;
|
||||
|
||||
/* Name of output files. */
|
||||
static char *volatile filename_space = NULL;
|
||||
static char *volatile filename_space = nullptr;
|
||||
|
||||
/* Prefix part of output file names. */
|
||||
static char const *volatile prefix = NULL;
|
||||
static char const *volatile prefix = nullptr;
|
||||
|
||||
/* Suffix part of output file names. */
|
||||
static char *volatile suffix = NULL;
|
||||
static char *volatile suffix = nullptr;
|
||||
|
||||
/* Number of digits to use in output file names. */
|
||||
static int volatile digits = 2;
|
||||
@@ -149,10 +149,10 @@ static int volatile files_created = 0;
|
||||
static intmax_t bytes_written;
|
||||
|
||||
/* Output file pointer. */
|
||||
static FILE *output_stream = NULL;
|
||||
static FILE *output_stream = nullptr;
|
||||
|
||||
/* Output file name. */
|
||||
static char *output_filename = NULL;
|
||||
static char *output_filename = nullptr;
|
||||
|
||||
/* Perhaps it would be cleaner to pass arg values instead of indexes. */
|
||||
static char **global_argv;
|
||||
@@ -188,17 +188,17 @@ enum
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"digits", required_argument, NULL, 'n'},
|
||||
{"quiet", no_argument, NULL, 'q'},
|
||||
{"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},
|
||||
{"digits", required_argument, nullptr, 'n'},
|
||||
{"quiet", no_argument, nullptr, 'q'},
|
||||
{"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},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Optionally remove files created so far; then exit.
|
||||
@@ -213,7 +213,7 @@ cleanup (void)
|
||||
|
||||
sigprocmask (SIG_BLOCK, &caught_signals, &oldset);
|
||||
delete_all_files (false);
|
||||
sigprocmask (SIG_SETMASK, &oldset, NULL);
|
||||
sigprocmask (SIG_SETMASK, &oldset, nullptr);
|
||||
}
|
||||
|
||||
static _Noreturn void
|
||||
@@ -294,7 +294,7 @@ new_line_control (void)
|
||||
{
|
||||
struct line *p = xmalloc (sizeof *p);
|
||||
|
||||
p->next = NULL;
|
||||
p->next = nullptr;
|
||||
clear_line_control (p);
|
||||
|
||||
return p;
|
||||
@@ -309,7 +309,7 @@ keep_new_line (struct buffer_record *b, char *line_start, idx_t line_len)
|
||||
struct line *l;
|
||||
|
||||
/* If there is no existing area to keep line info, get some. */
|
||||
if (b->line_start == NULL)
|
||||
if (b->line_start == nullptr)
|
||||
b->line_start = b->curr_line = new_line_control ();
|
||||
|
||||
/* If existing area for lines is full, get more. */
|
||||
@@ -410,13 +410,13 @@ get_new_buffer (idx_t min_size)
|
||||
{
|
||||
struct buffer_record *new_buffer = xmalloc (sizeof *new_buffer);
|
||||
new_buffer->bytes_alloc = 0;
|
||||
new_buffer->buffer = xpalloc (NULL, &new_buffer->bytes_alloc, min_size,
|
||||
new_buffer->buffer = xpalloc (nullptr, &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 = NULL;
|
||||
new_buffer->next = NULL;
|
||||
new_buffer->line_start = new_buffer->curr_line = nullptr;
|
||||
new_buffer->next = nullptr;
|
||||
|
||||
return new_buffer;
|
||||
}
|
||||
@@ -429,10 +429,10 @@ save_buffer (struct buffer_record *buf)
|
||||
{
|
||||
struct buffer_record *p;
|
||||
|
||||
buf->next = NULL;
|
||||
buf->next = nullptr;
|
||||
buf->curr_line = buf->line_start;
|
||||
|
||||
if (head == NULL)
|
||||
if (head == nullptr)
|
||||
head = buf;
|
||||
else
|
||||
{
|
||||
@@ -503,7 +503,7 @@ load_buffer (void)
|
||||
static intmax_t
|
||||
get_first_line_in_buffer (void)
|
||||
{
|
||||
if (head == NULL && !load_buffer ())
|
||||
if (head == nullptr && !load_buffer ())
|
||||
die (EXIT_FAILURE, errno, _("input disappeared"));
|
||||
|
||||
return head->first_available;
|
||||
@@ -511,15 +511,15 @@ get_first_line_in_buffer (void)
|
||||
|
||||
/* Return a pointer to the logical first line in the buffer and make the
|
||||
next line the logical first line.
|
||||
Return NULL if there is no more input. */
|
||||
Return nullptr if there is no more input. */
|
||||
|
||||
static struct cstring *
|
||||
remove_line (void)
|
||||
{
|
||||
/* If non-NULL, this is the buffer for which the previous call
|
||||
/* 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 = NULL;
|
||||
static struct buffer_record *prev_buf = nullptr;
|
||||
|
||||
struct cstring *line; /* Return value. */
|
||||
struct line *l; /* For convenience. */
|
||||
@@ -527,11 +527,11 @@ remove_line (void)
|
||||
if (prev_buf)
|
||||
{
|
||||
free_buffer (prev_buf);
|
||||
prev_buf = NULL;
|
||||
prev_buf = nullptr;
|
||||
}
|
||||
|
||||
if (head == NULL && !load_buffer ())
|
||||
return NULL;
|
||||
if (head == nullptr && !load_buffer ())
|
||||
return nullptr;
|
||||
|
||||
if (current_line < head->first_available)
|
||||
current_line = head->first_available;
|
||||
@@ -547,7 +547,7 @@ remove_line (void)
|
||||
{
|
||||
/* Go on to the next line record. */
|
||||
head->curr_line = l->next;
|
||||
if (head->curr_line == NULL || head->curr_line->used == 0)
|
||||
if (head->curr_line == nullptr || head->curr_line->used == 0)
|
||||
{
|
||||
/* Go on to the next data block.
|
||||
but first record the current one so we can free it
|
||||
@@ -561,18 +561,18 @@ remove_line (void)
|
||||
}
|
||||
|
||||
/* Search the buffers for line LINENUM, reading more input if necessary.
|
||||
Return a pointer to the line, or NULL if it is not found in the file. */
|
||||
Return a pointer to the line, or nullptr if it is not found in the file. */
|
||||
|
||||
static struct cstring *
|
||||
find_line (intmax_t linenum)
|
||||
{
|
||||
struct buffer_record *b;
|
||||
|
||||
if (head == NULL && !load_buffer ())
|
||||
return NULL;
|
||||
if (head == nullptr && !load_buffer ())
|
||||
return nullptr;
|
||||
|
||||
if (linenum < head->start_line)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
for (b = head;;)
|
||||
{
|
||||
@@ -593,8 +593,8 @@ find_line (intmax_t linenum)
|
||||
}
|
||||
return &l->starts[offset];
|
||||
}
|
||||
if (b->next == NULL && !load_buffer ())
|
||||
return NULL;
|
||||
if (b->next == nullptr && !load_buffer ())
|
||||
return nullptr;
|
||||
b = b->next; /* Try the next data block. */
|
||||
}
|
||||
}
|
||||
@@ -604,7 +604,7 @@ find_line (intmax_t linenum)
|
||||
static bool
|
||||
no_more_lines (void)
|
||||
{
|
||||
return find_line (current_line + 1) == NULL;
|
||||
return find_line (current_line + 1) == nullptr;
|
||||
}
|
||||
|
||||
/* Open NAME as standard input. */
|
||||
@@ -644,7 +644,7 @@ write_to_file (intmax_t last_line, bool ignore, int argnum)
|
||||
for (i = 0; i < lines; i++)
|
||||
{
|
||||
line = remove_line ();
|
||||
if (line == NULL)
|
||||
if (line == nullptr)
|
||||
{
|
||||
error (0, 0, _("%s: line number out of range"),
|
||||
quote (global_argv[argnum]));
|
||||
@@ -662,7 +662,7 @@ dump_rest_of_file (void)
|
||||
{
|
||||
struct cstring *line;
|
||||
|
||||
while ((line = remove_line ()) != NULL)
|
||||
while ((line = remove_line ()) != nullptr)
|
||||
save_line_to_file (line);
|
||||
}
|
||||
|
||||
@@ -707,7 +707,7 @@ process_line_count (const struct control *p, intmax_t repetition)
|
||||
while (linenum++ < last_line_to_save)
|
||||
{
|
||||
struct cstring *line = remove_line ();
|
||||
if (line == NULL)
|
||||
if (line == nullptr)
|
||||
handle_line_error (p, repetition);
|
||||
save_line_to_file (line);
|
||||
}
|
||||
@@ -769,7 +769,7 @@ process_regexp (struct control *p, intmax_t repetition)
|
||||
while (true)
|
||||
{
|
||||
line = find_line (++current_line);
|
||||
if (line == NULL)
|
||||
if (line == nullptr)
|
||||
{
|
||||
if (p->repeat_forever)
|
||||
{
|
||||
@@ -787,7 +787,7 @@ process_regexp (struct control *p, intmax_t repetition)
|
||||
if (line->str[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
ret = re_search (&p->re_compiled, line->str, line_len,
|
||||
0, line_len, NULL);
|
||||
0, line_len, nullptr);
|
||||
if (ret == -2)
|
||||
{
|
||||
error (0, 0, _("error in regular expression search"));
|
||||
@@ -809,7 +809,7 @@ process_regexp (struct control *p, intmax_t repetition)
|
||||
while (true)
|
||||
{
|
||||
line = find_line (++current_line);
|
||||
if (line == NULL)
|
||||
if (line == nullptr)
|
||||
{
|
||||
if (p->repeat_forever)
|
||||
{
|
||||
@@ -827,7 +827,7 @@ process_regexp (struct control *p, intmax_t repetition)
|
||||
if (line->str[line_len - 1] == '\n')
|
||||
line_len--;
|
||||
ret = re_search (&p->re_compiled, line->str, line_len,
|
||||
0, line_len, NULL);
|
||||
0, line_len, nullptr);
|
||||
if (ret == -2)
|
||||
{
|
||||
error (0, 0, _("error in regular expression search"));
|
||||
@@ -920,10 +920,10 @@ create_output_file (void)
|
||||
sigset_t oldset;
|
||||
sigprocmask (SIG_BLOCK, &caught_signals, &oldset);
|
||||
output_stream = fopen (output_filename, "w");
|
||||
fopen_ok = (output_stream != NULL);
|
||||
fopen_ok = (output_stream != nullptr);
|
||||
fopen_errno = errno;
|
||||
files_created = nfiles + fopen_ok;
|
||||
sigprocmask (SIG_SETMASK, &oldset, NULL);
|
||||
sigprocmask (SIG_SETMASK, &oldset, nullptr);
|
||||
}
|
||||
|
||||
if (! fopen_ok)
|
||||
@@ -964,13 +964,13 @@ close_output_file (void)
|
||||
if (ferror (output_stream))
|
||||
{
|
||||
error (0, 0, _("write error for %s"), quoteaf (output_filename));
|
||||
output_stream = NULL;
|
||||
output_stream = nullptr;
|
||||
cleanup_fatal ();
|
||||
}
|
||||
if (fclose (output_stream) != 0)
|
||||
{
|
||||
error (0, errno, "%s", quotef (output_filename));
|
||||
output_stream = NULL;
|
||||
output_stream = nullptr;
|
||||
cleanup_fatal ();
|
||||
}
|
||||
if (bytes_written == 0 && elide_empty_files)
|
||||
@@ -984,7 +984,7 @@ close_output_file (void)
|
||||
unlink_ok = (unlink (output_filename) == 0);
|
||||
unlink_errno = errno;
|
||||
files_created--;
|
||||
sigprocmask (SIG_SETMASK, &oldset, NULL);
|
||||
sigprocmask (SIG_SETMASK, &oldset, nullptr);
|
||||
|
||||
if (! unlink_ok && unlink_errno != ENOENT)
|
||||
error (0, unlink_errno, "%s", quotef (output_filename));
|
||||
@@ -997,7 +997,7 @@ close_output_file (void)
|
||||
fprintf (stdout, "%s\n", imaxtostr (bytes_written, buf));
|
||||
}
|
||||
}
|
||||
output_stream = NULL;
|
||||
output_stream = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1011,7 +1011,7 @@ save_line_to_file (const struct cstring *line)
|
||||
if (l != line->len)
|
||||
{
|
||||
error (0, errno, _("write error for %s"), quoteaf (output_filename));
|
||||
output_stream = NULL;
|
||||
output_stream = nullptr;
|
||||
cleanup_fatal ();
|
||||
}
|
||||
bytes_written += line->len;
|
||||
@@ -1044,7 +1044,7 @@ new_control_record (void)
|
||||
static void
|
||||
check_for_offset (struct control *p, char const *str, char const *num)
|
||||
{
|
||||
if (xstrtoimax (num, NULL, 10, &p->offset, "") != LONGINT_OK)
|
||||
if (xstrtoimax (num, nullptr, 10, &p->offset, "") != LONGINT_OK)
|
||||
die (EXIT_FAILURE, 0, _("%s: integer expected after delimiter"),
|
||||
quote (str));
|
||||
}
|
||||
@@ -1070,7 +1070,7 @@ parse_repeat_count (int argnum, struct control *p, char *str)
|
||||
else
|
||||
{
|
||||
uintmax_t val;
|
||||
if (xstrtoumax (str + 1, NULL, 10, &val, "") != LONGINT_OK
|
||||
if (xstrtoumax (str + 1, nullptr, 10, &val, "") != LONGINT_OK
|
||||
|| INTMAX_MAX < val)
|
||||
{
|
||||
die (EXIT_FAILURE, 0,
|
||||
@@ -1099,7 +1099,7 @@ extract_regexp (int argnum, bool ignore, char const *str)
|
||||
char const *err;
|
||||
|
||||
closing_delim = strrchr (str + 1, delim);
|
||||
if (closing_delim == NULL)
|
||||
if (closing_delim == nullptr)
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("%s: closing delimiter '%c' missing"), str, delim);
|
||||
|
||||
@@ -1109,10 +1109,10 @@ extract_regexp (int argnum, bool ignore, char const *str)
|
||||
p->ignore = ignore;
|
||||
|
||||
p->regexpr = true;
|
||||
p->re_compiled.buffer = NULL;
|
||||
p->re_compiled.buffer = nullptr;
|
||||
p->re_compiled.allocated = 0;
|
||||
p->re_compiled.fastmap = xmalloc (UCHAR_MAX + 1);
|
||||
p->re_compiled.translate = NULL;
|
||||
p->re_compiled.translate = nullptr;
|
||||
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);
|
||||
@@ -1149,7 +1149,7 @@ parse_patterns (int argc, int start, char **argv)
|
||||
p->argnum = i;
|
||||
|
||||
uintmax_t val;
|
||||
if (xstrtoumax (argv[i], NULL, 10, &val, "") != LONGINT_OK
|
||||
if (xstrtoumax (argv[i], nullptr, 10, &val, "") != LONGINT_OK
|
||||
|| INTMAX_MAX < val)
|
||||
die (EXIT_FAILURE, 0, _("%s: invalid pattern"), quote (argv[i]));
|
||||
if (val == 0)
|
||||
@@ -1289,7 +1289,7 @@ max_out (char *format)
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("missing %% conversion specification in suffix"));
|
||||
|
||||
int maxlen = snprintf (NULL, 0, format, INT_MAX);
|
||||
int maxlen = snprintf (nullptr, 0, format, INT_MAX);
|
||||
if (maxlen < 0)
|
||||
xalloc_die ();
|
||||
return maxlen;
|
||||
@@ -1309,14 +1309,15 @@ main (int argc, char **argv)
|
||||
atexit (close_stdout);
|
||||
|
||||
global_argv = argv;
|
||||
controls = NULL;
|
||||
controls = nullptr;
|
||||
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, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "f:b:kn:sqz", longopts, nullptr))
|
||||
!= -1)
|
||||
switch (optc)
|
||||
{
|
||||
case 'f':
|
||||
@@ -1409,7 +1410,7 @@ main (int argc, char **argv)
|
||||
sigemptyset (&caught_signals);
|
||||
for (i = 0; i < nsigs; i++)
|
||||
{
|
||||
sigaction (sig[i], NULL, &act);
|
||||
sigaction (sig[i], nullptr, &act);
|
||||
if (act.sa_handler != SIG_IGN)
|
||||
sigaddset (&caught_signals, sig[i]);
|
||||
}
|
||||
@@ -1420,7 +1421,7 @@ main (int argc, char **argv)
|
||||
|
||||
for (i = 0; i < nsigs; i++)
|
||||
if (sigismember (&caught_signals, sig[i]))
|
||||
sigaction (sig[i], &act, NULL);
|
||||
sigaction (sig[i], &act, nullptr);
|
||||
}
|
||||
|
||||
split_file ();
|
||||
|
||||
29
src/cut.c
29
src/cut.c
@@ -109,17 +109,17 @@ enum
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -304,7 +304,7 @@ cut_fields (FILE *stream)
|
||||
if (len < 0)
|
||||
{
|
||||
free (field_1_buffer);
|
||||
field_1_buffer = NULL;
|
||||
field_1_buffer = nullptr;
|
||||
if (ferror (stream) || feof (stream))
|
||||
break;
|
||||
xalloc_die ();
|
||||
@@ -426,7 +426,7 @@ cut_file (char const *file, void (*cut_stream) (FILE *))
|
||||
else
|
||||
{
|
||||
stream = fopen (file, "r");
|
||||
if (stream == NULL)
|
||||
if (stream == nullptr)
|
||||
{
|
||||
error (0, errno, "%s", quotef (file));
|
||||
return false;
|
||||
@@ -461,7 +461,7 @@ main (int argc, char **argv)
|
||||
bool ok;
|
||||
bool delim_specified = false;
|
||||
bool byte_mode = false;
|
||||
char *spec_list_string = NULL;
|
||||
char *spec_list_string = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -477,7 +477,8 @@ main (int argc, char **argv)
|
||||
delim = '\0';
|
||||
have_read_stdin = false;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "b:c:d:f:nsz", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "b:c:d:f:nsz", longopts, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
@@ -555,7 +556,7 @@ main (int argc, char **argv)
|
||||
if (!delim_specified)
|
||||
delim = '\t';
|
||||
|
||||
if (output_delimiter_string == NULL)
|
||||
if (output_delimiter_string == nullptr)
|
||||
{
|
||||
output_delimiter_default[0] = delim;
|
||||
output_delimiter_string = output_delimiter_default;
|
||||
|
||||
62
src/date.c
62
src/date.c
@@ -63,7 +63,7 @@ static char const *const time_spec_string[] =
|
||||
/* Put "hours" and "minutes" first, since they aren't valid for
|
||||
--rfc-3339. */
|
||||
"hours", "minutes",
|
||||
"date", "seconds", "ns", NULL
|
||||
"date", "seconds", "ns", nullptr
|
||||
};
|
||||
static enum Time_spec const time_spec[] =
|
||||
{
|
||||
@@ -88,23 +88,23 @@ static char const short_options[] = "d:f:I::r:Rs:u";
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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'},
|
||||
{"rfc-2822", no_argument, NULL, 'R'},
|
||||
{"rfc-3339", required_argument, NULL, RFC_3339_OPTION},
|
||||
{"set", required_argument, NULL, 's'},
|
||||
{"uct", no_argument, NULL, 'u'},
|
||||
{"utc", no_argument, NULL, 'u'},
|
||||
{"universal", no_argument, NULL, 'u'},
|
||||
{"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'},
|
||||
{"rfc-2822", no_argument, nullptr, 'R'},
|
||||
{"rfc-3339", required_argument, nullptr, RFC_3339_OPTION},
|
||||
{"set", required_argument, nullptr, 's'},
|
||||
{"uct", no_argument, nullptr, 'u'},
|
||||
{"utc", no_argument, nullptr, 'u'},
|
||||
{"universal", no_argument, nullptr, 'u'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* flags for parse_datetime2 */
|
||||
@@ -307,12 +307,12 @@ res_width (long int res)
|
||||
|
||||
/* 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 NULL. */
|
||||
the current platform. If no "%-N" appears, return nullptr. */
|
||||
|
||||
static char *
|
||||
adjust_resolution (char const *format)
|
||||
{
|
||||
char *copy = NULL;
|
||||
char *copy = nullptr;
|
||||
|
||||
for (char const *f = format; *f; f++)
|
||||
if (f[0] == '%')
|
||||
@@ -354,13 +354,13 @@ batch_convert (char const *input_filename, char const *format,
|
||||
else
|
||||
{
|
||||
in_stream = fopen (input_filename, "r");
|
||||
if (in_stream == NULL)
|
||||
if (in_stream == nullptr)
|
||||
{
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (input_filename));
|
||||
}
|
||||
}
|
||||
|
||||
line = NULL;
|
||||
line = nullptr;
|
||||
buflen = 0;
|
||||
ok = true;
|
||||
while (true)
|
||||
@@ -374,7 +374,7 @@ batch_convert (char const *input_filename, char const *format,
|
||||
break;
|
||||
}
|
||||
|
||||
if (! parse_datetime2 (&when, line, NULL,
|
||||
if (! parse_datetime2 (&when, line, nullptr,
|
||||
parse_datetime_flags, tz, tzstring))
|
||||
{
|
||||
if (line[line_length - 1] == '\n')
|
||||
@@ -400,14 +400,14 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int optc;
|
||||
char const *datestr = NULL;
|
||||
char const *set_datestr = NULL;
|
||||
char const *datestr = nullptr;
|
||||
char const *set_datestr = nullptr;
|
||||
struct timespec when;
|
||||
bool set_date = false;
|
||||
char const *format = NULL;
|
||||
char const *format = nullptr;
|
||||
bool get_resolution = false;
|
||||
char *batch_file = NULL;
|
||||
char *reference = NULL;
|
||||
char *batch_file = nullptr;
|
||||
char *reference = nullptr;
|
||||
struct stat refstats;
|
||||
bool ok;
|
||||
bool discarded_datestr = false;
|
||||
@@ -421,10 +421,10 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, short_options, long_options, NULL))
|
||||
while ((optc = getopt_long (argc, argv, short_options, long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
char const *new_format = NULL;
|
||||
char const *new_format = nullptr;
|
||||
|
||||
switch (optc)
|
||||
{
|
||||
@@ -580,7 +580,7 @@ main (int argc, char **argv)
|
||||
char const *tzstring = getenv ("TZ");
|
||||
timezone_t tz = tzalloc (tzstring);
|
||||
|
||||
if (batch_file != NULL)
|
||||
if (batch_file != nullptr)
|
||||
ok = batch_convert (batch_file, format_res, tz, tzstring);
|
||||
else
|
||||
{
|
||||
@@ -610,7 +610,7 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
/* (option_specified_date || set_date) */
|
||||
if (reference != NULL)
|
||||
if (reference != nullptr)
|
||||
{
|
||||
if (stat (reference, &refstats) != 0)
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (reference));
|
||||
@@ -626,7 +626,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
if (set_datestr)
|
||||
datestr = set_datestr;
|
||||
valid_date = parse_datetime2 (&when, datestr, NULL,
|
||||
valid_date = parse_datetime2 (&when, datestr, nullptr,
|
||||
parse_datetime_flags,
|
||||
tz, tzstring);
|
||||
}
|
||||
|
||||
27
src/dd.c
27
src/dd.c
@@ -126,11 +126,11 @@ enum
|
||||
STATUS_PROGRESS = 4
|
||||
};
|
||||
|
||||
/* The name of the input file, or NULL for the standard input. */
|
||||
static char const *input_file = NULL;
|
||||
/* The name of the input file, or nullptr for the standard input. */
|
||||
static char const *input_file = nullptr;
|
||||
|
||||
/* The name of the output file, or NULL for the standard output. */
|
||||
static char const *output_file = NULL;
|
||||
/* The name of the output file, or nullptr for the standard output. */
|
||||
static char const *output_file = nullptr;
|
||||
|
||||
/* The page size on this host. */
|
||||
static idx_t page_size;
|
||||
@@ -875,7 +875,7 @@ install_signal_handlers (void)
|
||||
sigemptyset (&caught_signals);
|
||||
if (catch_siginfo)
|
||||
sigaddset (&caught_signals, SIGINFO);
|
||||
sigaction (SIGINT, NULL, &act);
|
||||
sigaction (SIGINT, nullptr, &act);
|
||||
if (act.sa_handler != SIG_IGN)
|
||||
sigaddset (&caught_signals, SIGINT);
|
||||
act.sa_mask = caught_signals;
|
||||
@@ -887,14 +887,14 @@ install_signal_handlers (void)
|
||||
handle EINTR explicitly in iftruncate etc.
|
||||
to avoid blocking on noncommitted read/write calls. */
|
||||
act.sa_flags = 0;
|
||||
sigaction (SIGINFO, &act, NULL);
|
||||
sigaction (SIGINFO, &act, nullptr);
|
||||
}
|
||||
|
||||
if (sigismember (&caught_signals, SIGINT))
|
||||
{
|
||||
act.sa_handler = interrupt_handler;
|
||||
act.sa_flags = SA_NODEFER | SA_RESETHAND;
|
||||
sigaction (SIGINT, &act, NULL);
|
||||
sigaction (SIGINT, &act, nullptr);
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -975,7 +975,7 @@ process_signals (void)
|
||||
if (infos)
|
||||
info_signal_count = infos - 1;
|
||||
|
||||
sigprocmask (SIG_SETMASK, &oldset, NULL);
|
||||
sigprocmask (SIG_SETMASK, &oldset, nullptr);
|
||||
|
||||
if (interrupt)
|
||||
cleanup ();
|
||||
@@ -1495,7 +1495,7 @@ scanargs (int argc, char *const *argv)
|
||||
char const *name = argv[i];
|
||||
char const *val = strchr (name, '=');
|
||||
|
||||
if (val == NULL)
|
||||
if (val == nullptr)
|
||||
{
|
||||
diagnose (0, _("unrecognized operand %s"), quoteaf (name));
|
||||
usage (EXIT_FAILURE);
|
||||
@@ -1525,7 +1525,7 @@ scanargs (int argc, char *const *argv)
|
||||
bool has_B = !!strchr (val, 'B');
|
||||
intmax_t n_min = 0;
|
||||
intmax_t n_max = INTMAX_MAX;
|
||||
idx_t *converted_idx = NULL;
|
||||
idx_t *converted_idx = nullptr;
|
||||
|
||||
/* Maximum blocksize. Keep it smaller than IDX_MAX, so that
|
||||
it fits into blocksize vars even if 1 is added for conv=swab.
|
||||
@@ -2432,7 +2432,8 @@ main (int argc, char **argv)
|
||||
page_size = getpagesize ();
|
||||
|
||||
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE, Version,
|
||||
true, usage, AUTHORS, (char const *) NULL);
|
||||
true, usage, AUTHORS,
|
||||
(char const *) nullptr);
|
||||
close_stdout_required = false;
|
||||
|
||||
/* Initialize translation table to identity translation. */
|
||||
@@ -2444,7 +2445,7 @@ main (int argc, char **argv)
|
||||
|
||||
apply_translations ();
|
||||
|
||||
if (input_file == NULL)
|
||||
if (input_file == nullptr)
|
||||
{
|
||||
input_file = _("standard input");
|
||||
set_fd_flags (STDIN_FILENO, input_flags, input_file);
|
||||
@@ -2461,7 +2462,7 @@ main (int argc, char **argv)
|
||||
input_offset = MAX (0, offset);
|
||||
input_seek_errno = errno;
|
||||
|
||||
if (output_file == NULL)
|
||||
if (output_file == nullptr)
|
||||
{
|
||||
output_file = _("standard output");
|
||||
set_fd_flags (STDOUT_FILENO, output_flags, output_file);
|
||||
|
||||
189
src/df.c
189
src/df.c
@@ -99,7 +99,7 @@ struct fs_type_list
|
||||
};
|
||||
|
||||
/* Linked list of file system types to display.
|
||||
If 'fs_select_list' is NULL, list all types.
|
||||
If 'fs_select_list' is null, list all types.
|
||||
This table is generated dynamically from command-line options,
|
||||
rather than hardcoding into the program what it thinks are the
|
||||
valid file system types; let the user specify any file system type
|
||||
@@ -171,7 +171,7 @@ struct field_data_t
|
||||
display_field_t field;
|
||||
char const *arg;
|
||||
field_type_t field_type;
|
||||
char const *caption;/* NULL means to use the default header of this field. */
|
||||
char const *caption;/* nullptr means use default header of this field. */
|
||||
size_t width; /* Auto adjusted (up) widths used to align columns. */
|
||||
mbs_align_t align; /* Alignment for this field. */
|
||||
bool used;
|
||||
@@ -257,23 +257,23 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Stat FILE and put the results into *ST. Return 0 if successful, an
|
||||
@@ -418,7 +418,7 @@ alloc_field (int f, char const *c)
|
||||
ncolumns++;
|
||||
columns = xnrealloc (columns, ncolumns, sizeof (struct field_data_t *));
|
||||
columns[ncolumns - 1] = &field_data[f];
|
||||
if (c != NULL)
|
||||
if (c != nullptr)
|
||||
columns[ncolumns - 1]->caption = c;
|
||||
|
||||
if (field_data[f].used)
|
||||
@@ -481,7 +481,7 @@ decode_output_arg (char const *arg)
|
||||
case IPCENT_FIELD:
|
||||
case TARGET_FIELD:
|
||||
case FILE_FIELD:
|
||||
alloc_field (field, NULL);
|
||||
alloc_field (field, nullptr);
|
||||
break;
|
||||
|
||||
case SIZE_FIELD:
|
||||
@@ -509,48 +509,48 @@ get_field_list (void)
|
||||
switch (header_mode)
|
||||
{
|
||||
case DEFAULT_MODE:
|
||||
alloc_field (SOURCE_FIELD, NULL);
|
||||
alloc_field (SOURCE_FIELD, nullptr);
|
||||
if (print_type)
|
||||
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);
|
||||
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);
|
||||
break;
|
||||
|
||||
case HUMAN_MODE:
|
||||
alloc_field (SOURCE_FIELD, NULL);
|
||||
alloc_field (SOURCE_FIELD, nullptr);
|
||||
if (print_type)
|
||||
alloc_field (FSTYPE_FIELD, NULL);
|
||||
alloc_field (FSTYPE_FIELD, nullptr);
|
||||
|
||||
alloc_field (SIZE_FIELD, N_("Size"));
|
||||
alloc_field (USED_FIELD, NULL);
|
||||
alloc_field (USED_FIELD, nullptr);
|
||||
alloc_field (AVAIL_FIELD, N_("Avail"));
|
||||
alloc_field (PCENT_FIELD, NULL);
|
||||
alloc_field (TARGET_FIELD, NULL);
|
||||
alloc_field (PCENT_FIELD, nullptr);
|
||||
alloc_field (TARGET_FIELD, nullptr);
|
||||
break;
|
||||
|
||||
case INODES_MODE:
|
||||
alloc_field (SOURCE_FIELD, NULL);
|
||||
alloc_field (SOURCE_FIELD, nullptr);
|
||||
if (print_type)
|
||||
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);
|
||||
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);
|
||||
break;
|
||||
|
||||
case POSIX_MODE:
|
||||
alloc_field (SOURCE_FIELD, NULL);
|
||||
alloc_field (SOURCE_FIELD, nullptr);
|
||||
if (print_type)
|
||||
alloc_field (FSTYPE_FIELD, NULL);
|
||||
alloc_field (SIZE_FIELD, NULL);
|
||||
alloc_field (USED_FIELD, NULL);
|
||||
alloc_field (AVAIL_FIELD, NULL);
|
||||
alloc_field (FSTYPE_FIELD, nullptr);
|
||||
alloc_field (SIZE_FIELD, nullptr);
|
||||
alloc_field (USED_FIELD, nullptr);
|
||||
alloc_field (AVAIL_FIELD, nullptr);
|
||||
alloc_field (PCENT_FIELD, N_("Capacity"));
|
||||
alloc_field (TARGET_FIELD, NULL);
|
||||
alloc_field (TARGET_FIELD, nullptr);
|
||||
break;
|
||||
|
||||
case OUTPUT_MODE:
|
||||
@@ -577,7 +577,7 @@ get_header (void)
|
||||
|
||||
for (col = 0; col < ncolumns; col++)
|
||||
{
|
||||
char *cell = NULL;
|
||||
char *cell = nullptr;
|
||||
char const *header = _(columns[col]->caption);
|
||||
|
||||
if (columns[col]->field == SIZE_FIELD
|
||||
@@ -621,7 +621,7 @@ get_header (void)
|
||||
|
||||
/* TRANSLATORS: this is the "1K-blocks" header in "df" output. */
|
||||
if (asprintf (&cell, _("%s-%s"), num, header) == -1)
|
||||
cell = NULL;
|
||||
cell = nullptr;
|
||||
}
|
||||
else if (header_mode == POSIX_MODE && columns[col]->field == SIZE_FIELD)
|
||||
{
|
||||
@@ -630,7 +630,7 @@ get_header (void)
|
||||
|
||||
/* TRANSLATORS: this is the "1024-blocks" header in "df -P". */
|
||||
if (asprintf (&cell, _("%s-%s"), num, header) == -1)
|
||||
cell = NULL;
|
||||
cell = nullptr;
|
||||
}
|
||||
else
|
||||
cell = strdup (header);
|
||||
@@ -655,7 +655,7 @@ selected_fstype (char const *fstype)
|
||||
{
|
||||
const struct fs_type_list *fsp;
|
||||
|
||||
if (fs_select_list == NULL || fstype == NULL)
|
||||
if (fs_select_list == nullptr || fstype == nullptr)
|
||||
return true;
|
||||
for (fsp = fs_select_list; fsp; fsp = fsp->fs_next)
|
||||
if (STREQ (fstype, fsp->fs_name))
|
||||
@@ -671,7 +671,7 @@ excluded_fstype (char const *fstype)
|
||||
{
|
||||
const struct fs_type_list *fsp;
|
||||
|
||||
if (fs_exclude_list == NULL || fstype == NULL)
|
||||
if (fs_exclude_list == nullptr || fstype == nullptr)
|
||||
return false;
|
||||
for (fsp = fs_exclude_list; fsp; fsp = fsp->fs_next)
|
||||
if (STREQ (fstype, fsp->fs_name))
|
||||
@@ -697,14 +697,14 @@ devlist_compare (void const *x, void const *y)
|
||||
static struct devlist *
|
||||
devlist_for_dev (dev_t dev)
|
||||
{
|
||||
if (devlist_table == NULL)
|
||||
return NULL;
|
||||
if (devlist_table == nullptr)
|
||||
return nullptr;
|
||||
struct devlist dev_entry;
|
||||
dev_entry.dev_num = dev;
|
||||
|
||||
struct devlist *found = hash_lookup (devlist_table, &dev_entry);
|
||||
if (found == NULL)
|
||||
return NULL;
|
||||
if (found == nullptr)
|
||||
return nullptr;
|
||||
|
||||
/* Return the last devlist entry we have seen with this dev_num */
|
||||
return found->seen_last;
|
||||
@@ -723,22 +723,22 @@ filter_mount_list (bool devices_only)
|
||||
struct mount_entry *me;
|
||||
|
||||
/* Temporary list to keep entries ordered. */
|
||||
struct devlist *device_list = NULL;
|
||||
struct devlist *device_list = nullptr;
|
||||
int mount_list_size = 0;
|
||||
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
mount_list_size++;
|
||||
|
||||
devlist_table = hash_initialize (mount_list_size, NULL,
|
||||
devlist_hash, devlist_compare, NULL);
|
||||
if (devlist_table == NULL)
|
||||
devlist_table = hash_initialize (mount_list_size, nullptr,
|
||||
devlist_hash, devlist_compare, nullptr);
|
||||
if (devlist_table == nullptr)
|
||||
xalloc_die ();
|
||||
|
||||
/* Sort all 'wanted' entries into the list device_list. */
|
||||
for (me = mount_list; me;)
|
||||
{
|
||||
struct stat buf;
|
||||
struct mount_entry *discard_me = NULL;
|
||||
struct mount_entry *discard_me = nullptr;
|
||||
|
||||
/* Avoid stating remote file systems as that may hang.
|
||||
On Linux we probably have me_dev populated from /proc/self/mountinfo,
|
||||
@@ -763,8 +763,8 @@ filter_mount_list (bool devices_only)
|
||||
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 != NULL
|
||||
&& me->me_mntroot != NULL
|
||||
bool source_below_root = seen_dev->me->me_mntroot != nullptr
|
||||
&& me->me_mntroot != nullptr
|
||||
&& (strlen (seen_dev->me->me_mntroot)
|
||||
< strlen (me->me_mntroot));
|
||||
if (! print_grand_total
|
||||
@@ -819,7 +819,7 @@ filter_mount_list (bool devices_only)
|
||||
device_list = devlist;
|
||||
|
||||
struct devlist *hash_entry = hash_insert (devlist_table, devlist);
|
||||
if (hash_entry == NULL)
|
||||
if (hash_entry == nullptr)
|
||||
xalloc_die ();
|
||||
/* Ensure lookups use this latest devlist. */
|
||||
hash_entry->seen_last = devlist;
|
||||
@@ -830,7 +830,7 @@ filter_mount_list (bool devices_only)
|
||||
|
||||
/* Finally rebuild the mount_list from the devlist. */
|
||||
if (! devices_only) {
|
||||
mount_list = NULL;
|
||||
mount_list = nullptr;
|
||||
while (device_list)
|
||||
{
|
||||
/* Add the mount entry. */
|
||||
@@ -843,13 +843,13 @@ filter_mount_list (bool devices_only)
|
||||
}
|
||||
|
||||
hash_free (devlist_table);
|
||||
devlist_table = NULL;
|
||||
devlist_table = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Search a mount entry list for device id DEV.
|
||||
Return the corresponding mount entry if found or NULL if not. */
|
||||
Return the corresponding mount entry if found or nullptr if not. */
|
||||
|
||||
ATTRIBUTE_PURE
|
||||
static struct mount_entry const *
|
||||
@@ -859,7 +859,7 @@ me_for_dev (dev_t dev)
|
||||
if (dl)
|
||||
return dl->me;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Return true if N is a known integer value. On many file systems,
|
||||
@@ -999,15 +999,15 @@ add_to_grand_total (struct field_values_t *bv, struct field_values_t *iv)
|
||||
}
|
||||
|
||||
/* Obtain a space listing for the device with absolute file name DEVICE.
|
||||
If MOUNT_POINT is non-NULL, it is the name of the root of the
|
||||
If MOUNT_POINT is non-null, it is the name of the root of the
|
||||
file system on DEVICE.
|
||||
If STAT_FILE is non-null, it is the name of a file within the file
|
||||
system that the user originally asked for; this provides better
|
||||
diagnostics, and sometimes it provides better results on networked
|
||||
file systems that give different free-space results depending on
|
||||
where in the file system you probe.
|
||||
If FSTYPE is non-NULL, it is the type of the file system on DEVICE.
|
||||
If MOUNT_POINT is non-NULL, then DEVICE may be NULL -- certain systems may
|
||||
If FSTYPE is non-null, it is the type of the file system on DEVICE.
|
||||
If MOUNT_POINT is non-null, then DEVICE may be null -- certain systems may
|
||||
not be able to produce statistics in this case.
|
||||
ME_DUMMY and ME_REMOTE are the mount entry flags.
|
||||
Caller must set PROCESS_ALL to true when iterating over all entries, as
|
||||
@@ -1034,7 +1034,7 @@ get_dev (char const *device, char const *mount_point, char const *file,
|
||||
if (!force_fsu && mount_point && ! IS_ABSOLUTE_FILE_NAME (mount_point))
|
||||
return;
|
||||
|
||||
/* If MOUNT_POINT is NULL, then the file system is not mounted, and this
|
||||
/* If MOUNT_POINT is null, then the file system is not mounted, and this
|
||||
program reports on the file system that the special file is on.
|
||||
It would be better to report on the unmounted file system,
|
||||
but statfs doesn't do that on most systems. */
|
||||
@@ -1145,10 +1145,10 @@ get_dev (char const *device, char const *mount_point, char const *file,
|
||||
v = &inode_values;
|
||||
break;
|
||||
case OTHER_FLD:
|
||||
v = NULL;
|
||||
v = nullptr;
|
||||
break;
|
||||
default:
|
||||
v = NULL; /* Avoid warnings where assert() is not __noreturn__. */
|
||||
v = nullptr; /* Avoid warnings where assert() is not __noreturn__. */
|
||||
assert (!"bad field_type");
|
||||
}
|
||||
|
||||
@@ -1222,7 +1222,7 @@ get_dev (char const *device, char const *mount_point, char const *file,
|
||||
if (0 <= pct)
|
||||
{
|
||||
if (asprintf (&cell, "%.0f%%", pct) == -1)
|
||||
cell = NULL;
|
||||
cell = nullptr;
|
||||
}
|
||||
else
|
||||
cell = strdup ("-");
|
||||
@@ -1266,12 +1266,12 @@ get_dev (char const *device, char const *mount_point, char const *file,
|
||||
}
|
||||
|
||||
/* Scan the mount list returning the _last_ device found for MOUNT.
|
||||
NULL is returned if MOUNT not found. The result is malloced. */
|
||||
nullptr is returned if MOUNT not found. The result is malloced. */
|
||||
static char *
|
||||
last_device_for_mount (char const *mount)
|
||||
{
|
||||
struct mount_entry const *me;
|
||||
struct mount_entry const *le = NULL;
|
||||
struct mount_entry const *le = nullptr;
|
||||
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
{
|
||||
@@ -1289,7 +1289,7 @@ last_device_for_mount (char const *mount)
|
||||
return xstrdup (le->me_devname);
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* If DEVICE corresponds to a mount point, show its usage
|
||||
@@ -1298,7 +1298,7 @@ static bool
|
||||
get_device (char const *device)
|
||||
{
|
||||
struct mount_entry const *me;
|
||||
struct mount_entry const *best_match = NULL;
|
||||
struct mount_entry const *best_match = nullptr;
|
||||
bool best_match_accessible = false;
|
||||
bool eclipsed_device = false;
|
||||
char const *file = device;
|
||||
@@ -1356,9 +1356,9 @@ get_device (char const *device)
|
||||
|
||||
if (best_match)
|
||||
{
|
||||
get_dev (best_match->me_devname, best_match->me_mountdir, file, NULL,
|
||||
get_dev (best_match->me_devname, best_match->me_mountdir, file, nullptr,
|
||||
best_match->me_type, best_match->me_dummy,
|
||||
best_match->me_remote, NULL, false);
|
||||
best_match->me_remote, nullptr, false);
|
||||
return true;
|
||||
}
|
||||
else if (eclipsed_device)
|
||||
@@ -1380,7 +1380,7 @@ get_point (char const *point, const struct stat *statp)
|
||||
{
|
||||
struct stat device_stats;
|
||||
struct mount_entry *me;
|
||||
struct mount_entry const *best_match = NULL;
|
||||
struct mount_entry const *best_match = nullptr;
|
||||
|
||||
/* Calculate the real absolute file name for POINT, and use that to find
|
||||
the mount point. This avoids statting unavailable mount points,
|
||||
@@ -1412,7 +1412,7 @@ get_point (char const *point, const struct stat *statp)
|
||||
if (best_match
|
||||
&& (stat (best_match->me_mountdir, &device_stats) != 0
|
||||
|| device_stats.st_dev != statp->st_dev))
|
||||
best_match = NULL;
|
||||
best_match = nullptr;
|
||||
|
||||
if (! best_match)
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
@@ -1453,7 +1453,7 @@ get_point (char const *point, const struct stat *statp)
|
||||
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,
|
||||
NULL, false);
|
||||
nullptr, false);
|
||||
else
|
||||
{
|
||||
/* We couldn't find the mount entry corresponding to POINT. Go ahead and
|
||||
@@ -1464,7 +1464,8 @@ get_point (char const *point, const struct stat *statp)
|
||||
char *mp = find_mount_point (point, statp);
|
||||
if (mp)
|
||||
{
|
||||
get_dev (NULL, mp, point, NULL, NULL, false, false, NULL, false);
|
||||
get_dev (nullptr, mp, point, nullptr, nullptr,
|
||||
false, false, nullptr, false);
|
||||
free (mp);
|
||||
}
|
||||
}
|
||||
@@ -1494,8 +1495,8 @@ get_all_entries (void)
|
||||
filter_mount_list (show_all_fs);
|
||||
|
||||
for (me = mount_list; me; me = me->me_next)
|
||||
get_dev (me->me_devname, me->me_mountdir, NULL, NULL, me->me_type,
|
||||
me->me_dummy, me->me_remote, NULL, true);
|
||||
get_dev (me->me_devname, me->me_mountdir, nullptr, nullptr, me->me_type,
|
||||
me->me_dummy, me->me_remote, nullptr, true);
|
||||
}
|
||||
|
||||
/* Add FSTYPE to the list of file system types to display. */
|
||||
@@ -1589,7 +1590,7 @@ field names are: 'source', 'fstype', 'itotal', 'iused', 'iavail', 'ipcent',\n\
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
struct stat *stats = NULL;
|
||||
struct stat *stats = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -1599,8 +1600,8 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
fs_select_list = NULL;
|
||||
fs_exclude_list = NULL;
|
||||
fs_select_list = nullptr;
|
||||
fs_exclude_list = nullptr;
|
||||
show_all_fs = false;
|
||||
show_listed_fs = false;
|
||||
human_output_opts = -1;
|
||||
@@ -1789,19 +1790,19 @@ main (int argc, char **argv)
|
||||
{
|
||||
error (0, err, "%s", quotef (argv[i]));
|
||||
exit_status = EXIT_FAILURE;
|
||||
argv[i] = NULL;
|
||||
argv[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mount_list =
|
||||
read_file_system_list ((fs_select_list != NULL
|
||||
|| fs_exclude_list != NULL
|
||||
read_file_system_list ((fs_select_list != nullptr
|
||||
|| fs_exclude_list != nullptr
|
||||
|| print_type
|
||||
|| field_data[FSTYPE_FIELD].used
|
||||
|| show_local_fs));
|
||||
|
||||
if (mount_list == NULL)
|
||||
if (mount_list == nullptr)
|
||||
{
|
||||
/* Couldn't read the table of mounted file systems.
|
||||
Fail if df was invoked with no file name arguments,
|
||||
@@ -1811,8 +1812,8 @@ main (int argc, char **argv)
|
||||
if ( ! (optind < argc)
|
||||
|| (show_all_fs
|
||||
|| show_local_fs
|
||||
|| fs_select_list != NULL
|
||||
|| fs_exclude_list != NULL))
|
||||
|| fs_select_list != nullptr
|
||||
|| fs_exclude_list != nullptr))
|
||||
{
|
||||
status = EXIT_FAILURE;
|
||||
}
|
||||
@@ -1844,7 +1845,7 @@ main (int argc, char **argv)
|
||||
if (print_grand_total)
|
||||
get_dev ("total",
|
||||
(field_data[SOURCE_FIELD].used ? "-" : "total"),
|
||||
NULL, NULL, NULL, false, false, &grand_fsu, false);
|
||||
nullptr, nullptr, nullptr, false, false, &grand_fsu, false);
|
||||
|
||||
print_table ();
|
||||
}
|
||||
|
||||
65
src/digest.c
65
src/digest.c
@@ -300,7 +300,7 @@ enum Algorithm
|
||||
static char const *const algorithm_args[] =
|
||||
{
|
||||
"bsd", "sysv", "crc", "md5", "sha1", "sha224",
|
||||
"sha256", "sha384", "sha512", "blake2b", "sm3", NULL
|
||||
"sha256", "sha384", "sha512", "blake2b", "sm3", nullptr
|
||||
};
|
||||
static enum Algorithm const algorithm_types[] =
|
||||
{
|
||||
@@ -312,7 +312,7 @@ ARGMATCH_VERIFY (algorithm_args, algorithm_types);
|
||||
static char const *const algorithm_tags[] =
|
||||
{
|
||||
"BSD", "SYSV", "CRC", "MD5", "SHA1", "SHA224",
|
||||
"SHA256", "SHA384", "SHA512", "BLAKE2b", "SM3", NULL
|
||||
"SHA256", "SHA384", "SHA512", "BLAKE2b", "SM3", nullptr
|
||||
};
|
||||
static int const algorithm_bits[] =
|
||||
{
|
||||
@@ -374,37 +374,37 @@ enum
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
#if HASH_ALGO_BLAKE2 || HASH_ALGO_CKSUM
|
||||
{ "length", required_argument, NULL, 'l'},
|
||||
{ "length", required_argument, nullptr, 'l'},
|
||||
#endif
|
||||
|
||||
#if !HASH_ALGO_SUM
|
||||
{ "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' },
|
||||
{ "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' },
|
||||
|
||||
# if HASH_ALGO_CKSUM
|
||||
{ "algorithm", required_argument, NULL, 'a'},
|
||||
{ "base64", no_argument, NULL, 'b' },
|
||||
{ "debug", no_argument, NULL, DEBUG_PROGRAM_OPTION},
|
||||
{ "raw", no_argument, NULL, RAW_OPTION},
|
||||
{ "untagged", no_argument, NULL, UNTAG_OPTION },
|
||||
{ "algorithm", required_argument, nullptr, 'a'},
|
||||
{ "base64", no_argument, nullptr, 'b' },
|
||||
{ "debug", no_argument, nullptr, DEBUG_PROGRAM_OPTION},
|
||||
{ "raw", no_argument, nullptr, RAW_OPTION},
|
||||
{ "untagged", no_argument, nullptr, UNTAG_OPTION },
|
||||
# else
|
||||
{ "binary", no_argument, NULL, 'b' },
|
||||
{ "text", no_argument, NULL, 't' },
|
||||
{ "binary", no_argument, nullptr, 'b' },
|
||||
{ "text", no_argument, nullptr, 't' },
|
||||
# endif
|
||||
|
||||
#else
|
||||
{"sysv", no_argument, NULL, 's'},
|
||||
{"sysv", no_argument, nullptr, 's'},
|
||||
#endif
|
||||
|
||||
{ GETOPT_HELP_OPTION_DECL },
|
||||
{ GETOPT_VERSION_OPTION_DECL },
|
||||
{ NULL, 0, NULL, 0 }
|
||||
{ nullptr, 0, nullptr, 0 }
|
||||
};
|
||||
|
||||
void
|
||||
@@ -571,7 +571,7 @@ or equivalent standalone program.\
|
||||
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 NULL. */
|
||||
than "n" or another backslash, return nullptr. */
|
||||
|
||||
static char *
|
||||
filename_unescape (char *s, size_t s_len)
|
||||
@@ -586,7 +586,7 @@ filename_unescape (char *s, size_t s_len)
|
||||
if (i == s_len - 1)
|
||||
{
|
||||
/* File name ends with an unescaped backslash: invalid. */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
++i;
|
||||
switch (s[i])
|
||||
@@ -602,13 +602,13 @@ filename_unescape (char *s, size_t s_len)
|
||||
break;
|
||||
default:
|
||||
/* Only '\', 'n' or 'r' may follow a backslash. */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
break;
|
||||
|
||||
case '\0':
|
||||
/* The file name may not contain a NUL. */
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
default:
|
||||
*dst++ = s[i];
|
||||
@@ -684,7 +684,7 @@ bsd_split_3 (char *s, size_t s_len,
|
||||
|
||||
*file_name = s;
|
||||
|
||||
if (escaped_filename && filename_unescape (s, i) == NULL)
|
||||
if (escaped_filename && filename_unescape (s, i) == nullptr)
|
||||
return false;
|
||||
|
||||
s[i++] = '\0';
|
||||
@@ -808,7 +808,7 @@ split_3 (char *s, size_t s_len,
|
||||
{
|
||||
uintmax_t length;
|
||||
char *siend;
|
||||
if (! (xstrtoumax (s + i, &siend, 0, &length, NULL) == LONGINT_OK
|
||||
if (! (xstrtoumax (s + i, &siend, 0, &length, nullptr) == LONGINT_OK
|
||||
&& 0 < length && length <= digest_length
|
||||
&& length % 8 == 0))
|
||||
return false;
|
||||
@@ -896,7 +896,7 @@ split_3 (char *s, size_t s_len,
|
||||
*file_name = &s[i];
|
||||
|
||||
if (escaped_filename)
|
||||
return filename_unescape (&s[i], s_len - i) != NULL;
|
||||
return filename_unescape (&s[i], s_len - i) != nullptr;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -975,7 +975,7 @@ digest_file (char const *filename, int *binary, unsigned char *bin_result,
|
||||
else
|
||||
{
|
||||
fp = fopen (filename, (O_BINARY && *binary ? "rb" : "r"));
|
||||
if (fp == NULL)
|
||||
if (fp == nullptr)
|
||||
{
|
||||
if (ignore_missing && errno == ENOENT)
|
||||
{
|
||||
@@ -1155,7 +1155,7 @@ digest_check (char const *checkfile_name)
|
||||
else
|
||||
{
|
||||
checkfile_stream = fopen (checkfile_name, "r");
|
||||
if (checkfile_stream == NULL)
|
||||
if (checkfile_stream == nullptr)
|
||||
{
|
||||
error (0, errno, "%s", quotef (checkfile_name));
|
||||
return false;
|
||||
@@ -1163,7 +1163,7 @@ digest_check (char const *checkfile_name)
|
||||
}
|
||||
|
||||
line_number = 0;
|
||||
line = NULL;
|
||||
line = nullptr;
|
||||
line_chars_allocated = 0;
|
||||
do
|
||||
{
|
||||
@@ -1365,7 +1365,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* Line buffer stdout to ensure lines are written atomically and immediately
|
||||
so that processes running in parallel do not intersperse their output. */
|
||||
setvbuf (stdout, NULL, _IOLBF, 0);
|
||||
setvbuf (stdout, nullptr, _IOLBF, 0);
|
||||
|
||||
#if HASH_ALGO_SUM
|
||||
char const *short_opts = "rs";
|
||||
@@ -1379,7 +1379,8 @@ main (int argc, char **argv)
|
||||
char const *short_opts = "bctwz";
|
||||
#endif
|
||||
|
||||
while ((opt = getopt_long (argc, argv, short_opts, long_options, NULL)) != -1)
|
||||
while ((opt = getopt_long (argc, argv, short_opts, long_options, nullptr))
|
||||
!= -1)
|
||||
switch (opt)
|
||||
{
|
||||
#if HASH_ALGO_CKSUM
|
||||
|
||||
@@ -58,14 +58,15 @@ static char const *const slack_codes[] =
|
||||
"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", NULL
|
||||
"MULTIHARDLINK", "CLRTOEOL", nullptr
|
||||
};
|
||||
|
||||
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", NULL
|
||||
"su", "su", "sg", "sg", "st", "ow", "ow", "tw", "tw", "ca", "mh", "cl",
|
||||
nullptr
|
||||
};
|
||||
static_assert (ARRAY_CARDINALITY (slack_codes) == ARRAY_CARDINALITY (ls_codes));
|
||||
|
||||
@@ -81,15 +82,15 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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},
|
||||
{"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},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -132,7 +133,7 @@ guess_shell_syntax (void)
|
||||
char *shell;
|
||||
|
||||
shell = getenv ("SHELL");
|
||||
if (shell == NULL || *shell == '\0')
|
||||
if (shell == nullptr || *shell == '\0')
|
||||
return SHELL_SYNTAX_UNKNOWN;
|
||||
|
||||
shell = last_component (shell);
|
||||
@@ -150,8 +151,8 @@ parse_line (char const *line, char **keyword, char **arg)
|
||||
char const *keyword_start;
|
||||
char const *arg_start;
|
||||
|
||||
*keyword = NULL;
|
||||
*arg = NULL;
|
||||
*keyword = nullptr;
|
||||
*arg = nullptr;
|
||||
|
||||
for (p = line; isspace (to_uchar (*p)); ++p)
|
||||
continue;
|
||||
@@ -267,7 +268,7 @@ dc_parse_stream (FILE *fp, char const *filename)
|
||||
{
|
||||
size_t line_number = 0;
|
||||
char const *next_G_line = G_line;
|
||||
char *input_line = NULL;
|
||||
char *input_line = nullptr;
|
||||
size_t input_line_size = 0;
|
||||
char const *line;
|
||||
char const *term;
|
||||
@@ -279,12 +280,12 @@ dc_parse_stream (FILE *fp, char const *filename)
|
||||
|
||||
/* Get terminal type */
|
||||
term = getenv ("TERM");
|
||||
if (term == NULL || *term == '\0')
|
||||
if (term == nullptr || *term == '\0')
|
||||
term = "none";
|
||||
|
||||
/* Also match $COLORTERM. */
|
||||
colorterm = getenv ("COLORTERM");
|
||||
if (colorterm == NULL)
|
||||
if (colorterm == nullptr)
|
||||
colorterm = ""; /* Doesn't match default "?*" */
|
||||
|
||||
while (true)
|
||||
@@ -318,10 +319,10 @@ dc_parse_stream (FILE *fp, char const *filename)
|
||||
|
||||
parse_line (line, &keywd, &arg);
|
||||
|
||||
if (keywd == NULL)
|
||||
if (keywd == nullptr)
|
||||
continue;
|
||||
|
||||
if (arg == NULL)
|
||||
if (arg == nullptr)
|
||||
{
|
||||
error (0, 0, _("%s:%lu: invalid line; missing second token"),
|
||||
quotef (filename), (unsigned long int) line_number);
|
||||
@@ -362,11 +363,11 @@ dc_parse_stream (FILE *fp, char const *filename)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; slack_codes[i] != NULL; ++i)
|
||||
for (i = 0; slack_codes[i] != nullptr; ++i)
|
||||
if (c_strcasecmp (keywd, slack_codes[i]) == 0)
|
||||
break;
|
||||
|
||||
if (slack_codes[i] != NULL)
|
||||
if (slack_codes[i] != nullptr)
|
||||
append_entry (0, ls_codes[i], arg);
|
||||
else
|
||||
unrecognized = true;
|
||||
@@ -396,7 +397,7 @@ dc_parse_file (char const *filename)
|
||||
{
|
||||
bool ok;
|
||||
|
||||
if (! STREQ (filename, "-") && freopen (filename, "r", stdin) == NULL)
|
||||
if (! STREQ (filename, "-") && freopen (filename, "r", stdin) == nullptr)
|
||||
{
|
||||
error (0, errno, "%s", quotef (filename));
|
||||
return false;
|
||||
@@ -429,7 +430,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "bcp", long_options, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "bcp", long_options, nullptr)) != -1)
|
||||
switch (optc)
|
||||
{
|
||||
case 'b': /* Bourne shell syntax. */
|
||||
@@ -512,7 +513,7 @@ main (int argc, char **argv)
|
||||
|
||||
obstack_init (&lsc_obstack);
|
||||
if (argc == 0)
|
||||
ok = dc_parse_stream (NULL, NULL);
|
||||
ok = dc_parse_stream (nullptr, nullptr);
|
||||
else
|
||||
ok = dc_parse_file (argv[0]);
|
||||
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"zero", no_argument, NULL, 'z'},
|
||||
{"zero", no_argument, nullptr, 'z'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -92,7 +92,7 @@ main (int argc, char **argv)
|
||||
|
||||
while (true)
|
||||
{
|
||||
int c = getopt_long (argc, argv, "z", longopts, NULL);
|
||||
int c = getopt_long (argc, argv, "z", longopts, nullptr);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
77
src/du.c
77
src/du.c
@@ -179,10 +179,10 @@ enum time_type
|
||||
static enum time_type time_type = time_mtime;
|
||||
|
||||
/* User specified date / time style */
|
||||
static char const *time_style = NULL;
|
||||
static char const *time_style = nullptr;
|
||||
|
||||
/* Format used to display date / time. Controlled by --time-style */
|
||||
static char const *time_format = NULL;
|
||||
static char const *time_format = nullptr;
|
||||
|
||||
/* The local time zone rules, as per the TZ environment variable. */
|
||||
static timezone_t localtz;
|
||||
@@ -216,38 +216,38 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"all", no_argument, NULL, 'a'},
|
||||
{"apparent-size", no_argument, NULL, APPARENT_SIZE_OPTION},
|
||||
{"block-size", required_argument, NULL, 'B'},
|
||||
{"bytes", no_argument, NULL, 'b'},
|
||||
{"count-links", no_argument, NULL, 'l'},
|
||||
/* {"-debug", no_argument, NULL, FTS_DEBUG}, */
|
||||
{"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},
|
||||
{"all", no_argument, nullptr, 'a'},
|
||||
{"apparent-size", no_argument, nullptr, APPARENT_SIZE_OPTION},
|
||||
{"block-size", required_argument, nullptr, 'B'},
|
||||
{"bytes", no_argument, nullptr, 'b'},
|
||||
{"count-links", no_argument, nullptr, 'l'},
|
||||
/* {"-debug", no_argument, nullptr, FTS_DEBUG}, */
|
||||
{"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},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
static char const *const time_args[] =
|
||||
{
|
||||
"atime", "access", "use", "ctime", "status", NULL
|
||||
"atime", "access", "use", "ctime", "status", nullptr
|
||||
};
|
||||
static enum time_type const time_types[] =
|
||||
{
|
||||
@@ -267,7 +267,7 @@ enum time_style
|
||||
|
||||
static char const *const time_style_args[] =
|
||||
{
|
||||
"full-iso", "long-iso", "iso", NULL
|
||||
"full-iso", "long-iso", "iso", nullptr
|
||||
};
|
||||
static enum time_style const time_style_types[] =
|
||||
{
|
||||
@@ -671,7 +671,7 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
}
|
||||
|
||||
/* Recursively print the sizes of the directories (and, if selected, files)
|
||||
named in FILES, the last entry of which is NULL.
|
||||
named in FILES, the last entry of which is null.
|
||||
BIT_FLAGS controls how fts works.
|
||||
Return true if successful. */
|
||||
|
||||
@@ -682,14 +682,14 @@ du_files (char **files, int bit_flags)
|
||||
|
||||
if (*files)
|
||||
{
|
||||
FTS *fts = xfts_open (files, bit_flags, NULL);
|
||||
FTS *fts = xfts_open (files, bit_flags, nullptr);
|
||||
|
||||
while (true)
|
||||
{
|
||||
FTSENT *ent;
|
||||
|
||||
ent = fts_read (fts);
|
||||
if (ent == NULL)
|
||||
if (ent == nullptr)
|
||||
{
|
||||
if (errno != 0)
|
||||
{
|
||||
@@ -725,7 +725,7 @@ main (int argc, char **argv)
|
||||
char *cwd_only[2];
|
||||
bool max_depth_specified = false;
|
||||
bool ok = true;
|
||||
char *files_from = NULL;
|
||||
char *files_from = nullptr;
|
||||
|
||||
/* Bit flags that control how fts works. */
|
||||
int bit_flags = FTS_NOSTAT;
|
||||
@@ -738,7 +738,7 @@ main (int argc, char **argv)
|
||||
bool opt_summarize_only = false;
|
||||
|
||||
cwd_only[0] = bad_cast (".");
|
||||
cwd_only[1] = NULL;
|
||||
cwd_only[1] = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -809,7 +809,7 @@ main (int argc, char **argv)
|
||||
case 'd': /* --max-depth=N */
|
||||
{
|
||||
uintmax_t tmp;
|
||||
if (xstrtoumax (optarg, NULL, 0, &tmp, "") == LONGINT_OK
|
||||
if (xstrtoumax (optarg, nullptr, 0, &tmp, "") == LONGINT_OK
|
||||
&& tmp <= SIZE_MAX)
|
||||
{
|
||||
max_depth_specified = true;
|
||||
@@ -840,7 +840,8 @@ main (int argc, char **argv)
|
||||
case 't':
|
||||
{
|
||||
enum strtol_error e;
|
||||
e = xstrtoimax (optarg, NULL, 0, &opt_threshold, "kKmMGTPEZYRQ0");
|
||||
e = xstrtoimax (optarg, nullptr, 0, &opt_threshold,
|
||||
"kKmMGTPEZYRQ0");
|
||||
if (e != LONGINT_OK)
|
||||
xstrtol_fatal (e, oi, c, long_options, optarg);
|
||||
if (opt_threshold == 0 && *optarg == '-')
|
||||
@@ -1057,7 +1058,7 @@ main (int argc, char **argv)
|
||||
bit_flags |= FTS_TIGHT_CYCLE_CHECK;
|
||||
|
||||
bit_flags |= symlink_deref_bits;
|
||||
static char *temp_argv[] = { NULL, NULL };
|
||||
static char *temp_argv[] = { nullptr, nullptr };
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -1101,7 +1102,7 @@ main (int argc, char **argv)
|
||||
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 == NULL)
|
||||
if (files_from == nullptr)
|
||||
error (0, 0, "%s", _("invalid zero-length file name"));
|
||||
else
|
||||
{
|
||||
|
||||
@@ -140,7 +140,7 @@ main (int argc, char **argv)
|
||||
if (STREQ (argv[1], "--version"))
|
||||
{
|
||||
version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
|
||||
(char *) NULL);
|
||||
(char *) nullptr);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
58
src/env.c
58
src/env.c
@@ -90,19 +90,19 @@ enum
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -187,7 +187,7 @@ unset_envvars (void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Return a pointer to the end of a valid ${VARNAME} string, or NULL.
|
||||
/* Return a pointer to the end of a valid ${VARNAME} string, or nullptr.
|
||||
'str' should point to the '$' character.
|
||||
First letter in VARNAME must be alpha or underscore,
|
||||
rest of letters are alnum or underscore.
|
||||
@@ -205,14 +205,14 @@ scan_varname (char const *str)
|
||||
return end;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* 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 NULL if not a valid ${VARNAME} syntax. */
|
||||
Return nullptr if not a valid ${VARNAME} syntax. */
|
||||
static char *
|
||||
extract_varname (char const *str)
|
||||
{
|
||||
@@ -221,7 +221,7 @@ extract_varname (char const *str)
|
||||
|
||||
p = scan_varname (str);
|
||||
if (!p)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
/* -2 and +2 (below) account for the '${' prefix. */
|
||||
i = p - str - 2;
|
||||
@@ -496,7 +496,7 @@ build_argv (char const *str, int extra_argc, int *argc)
|
||||
argv[1] = "-S-i -C/tmp A=B"
|
||||
argv[2] = "foo"
|
||||
argv[3] = "bar"
|
||||
argv[4] = NULL
|
||||
argv[4] = nullptr
|
||||
This function will modify argv to be:
|
||||
argv[0] = "env"
|
||||
argv[1] = "-i"
|
||||
@@ -504,7 +504,7 @@ build_argv (char const *str, int extra_argc, int *argc)
|
||||
argv[3] = "A=B"
|
||||
argv[4] = "foo"
|
||||
argv[5] = "bar"
|
||||
argv[6] = NULL
|
||||
argv[6] = nullptr
|
||||
argc will be updated from 4 to 6.
|
||||
optind will be reset to 0 to force getopt_long to rescan all arguments. */
|
||||
static void
|
||||
@@ -569,7 +569,7 @@ parse_signal_action_params (char const *optarg, bool set_default)
|
||||
|
||||
signals[signum] = set_default ? DEFAULT : IGNORE;
|
||||
|
||||
opt_sig = strtok (NULL, ",");
|
||||
opt_sig = strtok (nullptr, ",");
|
||||
}
|
||||
|
||||
free (optarg_writable);
|
||||
@@ -591,7 +591,7 @@ reset_signal_handlers (void)
|
||||
bool set_to_default = (signals[i] == DEFAULT
|
||||
|| signals[i] == DEFAULT_NOERR);
|
||||
|
||||
int sig_err = sigaction (i, NULL, &act);
|
||||
int sig_err = sigaction (i, nullptr, &act);
|
||||
|
||||
if (sig_err && !ignore_errors)
|
||||
die (EXIT_CANCELED, errno,
|
||||
@@ -600,7 +600,7 @@ reset_signal_handlers (void)
|
||||
if (! sig_err)
|
||||
{
|
||||
act.sa_handler = set_to_default ? SIG_DFL : SIG_IGN;
|
||||
sig_err = sigaction (i, &act, NULL);
|
||||
sig_err = sigaction (i, &act, nullptr);
|
||||
if (sig_err && !ignore_errors)
|
||||
die (EXIT_CANCELED, errno,
|
||||
_("failed to set signal action for signal %d"), i);
|
||||
@@ -659,7 +659,7 @@ parse_block_signal_params (char const *optarg, bool block)
|
||||
sigaddset (block ? &block_signals : &unblock_signals, signum);
|
||||
sigdelset (block ? &unblock_signals : &block_signals, signum);
|
||||
|
||||
opt_sig = strtok (NULL, ",");
|
||||
opt_sig = strtok (nullptr, ",");
|
||||
}
|
||||
|
||||
free (optarg_writable);
|
||||
@@ -674,7 +674,7 @@ set_signal_proc_mask (void)
|
||||
|
||||
sigemptyset (&set);
|
||||
|
||||
if (sigprocmask (0, NULL, &set))
|
||||
if (sigprocmask (0, nullptr, &set))
|
||||
die (EXIT_CANCELED, errno, _("failed to get signal process mask"));
|
||||
|
||||
for (int i = 1; i <= SIGNUM_BOUND; i++)
|
||||
@@ -691,7 +691,7 @@ set_signal_proc_mask (void)
|
||||
}
|
||||
else
|
||||
{
|
||||
debug_act = NULL;
|
||||
debug_act = nullptr;
|
||||
}
|
||||
|
||||
if (dev_debug && debug_act)
|
||||
@@ -703,7 +703,7 @@ set_signal_proc_mask (void)
|
||||
}
|
||||
}
|
||||
|
||||
if (sigprocmask (SIG_SETMASK, &set, NULL))
|
||||
if (sigprocmask (SIG_SETMASK, &set, nullptr))
|
||||
die (EXIT_CANCELED, errno, _("failed to set signal process mask"));
|
||||
}
|
||||
|
||||
@@ -714,13 +714,13 @@ list_signal_handling (void)
|
||||
char signame[SIG2STR_MAX];
|
||||
|
||||
sigemptyset (&set);
|
||||
if (sigprocmask (0, NULL, &set))
|
||||
if (sigprocmask (0, nullptr, &set))
|
||||
die (EXIT_CANCELED, errno, _("failed to get signal process mask"));
|
||||
|
||||
for (int i = 1; i <= SIGNUM_BOUND; i++)
|
||||
{
|
||||
struct sigaction act;
|
||||
if (sigaction (i, NULL, &act))
|
||||
if (sigaction (i, nullptr, &act))
|
||||
continue;
|
||||
|
||||
char const *ignored = act.sa_handler == SIG_IGN ? "IGNORE" : "";
|
||||
@@ -753,7 +753,7 @@ main (int argc, char **argv)
|
||||
int optc;
|
||||
bool ignore_environment = false;
|
||||
bool opt_nul_terminate_output = false;
|
||||
char const *newdir = NULL;
|
||||
char const *newdir = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -766,7 +766,7 @@ main (int argc, char **argv)
|
||||
|
||||
initialize_signals ();
|
||||
|
||||
while ((optc = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, shortopts, longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
@@ -826,7 +826,7 @@ main (int argc, char **argv)
|
||||
if (ignore_environment)
|
||||
{
|
||||
devmsg ("cleaning environ\n");
|
||||
static char *dummy_environ[] = { NULL };
|
||||
static char *dummy_environ[] = { nullptr };
|
||||
environ = dummy_environ;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -46,7 +46,7 @@ size_t max_column_width;
|
||||
/* 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 uintmax_t *tab_list = NULL;
|
||||
static uintmax_t *tab_list = nullptr;
|
||||
|
||||
/* The number of allocated entries in 'tab_list'. */
|
||||
static size_t n_tabs_allocated = 0;
|
||||
@@ -56,12 +56,12 @@ static size_t n_tabs_allocated = 0;
|
||||
static size_t first_free_tab = 0;
|
||||
|
||||
/* Null-terminated array of input filenames. */
|
||||
static char **file_list = NULL;
|
||||
static char **file_list = nullptr;
|
||||
|
||||
/* Default for 'file_list' if no files are given on the command line. */
|
||||
static char *stdin_argv[] =
|
||||
{
|
||||
(char *) "-", NULL
|
||||
(char *) "-", nullptr
|
||||
};
|
||||
|
||||
/* True if we have ever read standard input. */
|
||||
@@ -134,7 +134,7 @@ parse_tab_stops (char const *stops)
|
||||
uintmax_t tabval = 0;
|
||||
bool extend_tabval = false;
|
||||
bool increment_tabval = false;
|
||||
char const *num_start = NULL;
|
||||
char const *num_start = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
for (; *stops; stops++)
|
||||
@@ -324,10 +324,10 @@ set_file_list (char **list)
|
||||
file_list = list;
|
||||
}
|
||||
|
||||
/* Close the old stream pointer FP if it is non-NULL,
|
||||
/* 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 NULL if there are no more input files. */
|
||||
Return nullptr if there are no more input files. */
|
||||
|
||||
extern FILE *
|
||||
next_file (FILE *fp)
|
||||
@@ -352,7 +352,7 @@ next_file (FILE *fp)
|
||||
}
|
||||
}
|
||||
|
||||
while ((file = *file_list++) != NULL)
|
||||
while ((file = *file_list++) != nullptr)
|
||||
{
|
||||
if (STREQ (file, "-"))
|
||||
{
|
||||
@@ -370,7 +370,7 @@ next_file (FILE *fp)
|
||||
error (0, errno, "%s", quotef (file));
|
||||
exit_status = EXIT_FAILURE;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* */
|
||||
|
||||
@@ -52,10 +52,10 @@ finalize_tab_stops (void);
|
||||
extern void
|
||||
set_file_list (char **file_list);
|
||||
|
||||
/* Close the old stream pointer FP if it is non-NULL,
|
||||
/* 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 NULL if there are no more input files. */
|
||||
Return nullptr if there are no more input files. */
|
||||
extern FILE *
|
||||
next_file (FILE *fp);
|
||||
|
||||
|
||||
12
src/expand.c
12
src/expand.c
@@ -51,11 +51,11 @@ static char const shortopts[] = "it:0::1::2::3::4::5::6::7::8::9::";
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"tabs", required_argument, NULL, 't'},
|
||||
{"initial", no_argument, NULL, 'i'},
|
||||
{"tabs", required_argument, nullptr, 't'},
|
||||
{"initial", no_argument, nullptr, 'i'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -96,7 +96,7 @@ static void
|
||||
expand (void)
|
||||
{
|
||||
/* Input stream. */
|
||||
FILE *fp = next_file (NULL);
|
||||
FILE *fp = next_file (nullptr);
|
||||
|
||||
if (!fp)
|
||||
return;
|
||||
@@ -191,7 +191,7 @@ main (int argc, char **argv)
|
||||
atexit (close_stdout);
|
||||
convert_entire_line = true;
|
||||
|
||||
while ((c = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1)
|
||||
while ((c = getopt_long (argc, argv, shortopts, longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
@@ -227,7 +227,7 @@ main (int argc, char **argv)
|
||||
|
||||
finalize_tab_stops ();
|
||||
|
||||
set_file_list ((optind < argc) ? &argv[optind] : NULL);
|
||||
set_file_list (optind < argc ? &argv[optind] : nullptr);
|
||||
|
||||
expand ();
|
||||
|
||||
|
||||
18
src/expr.c
18
src/expr.c
@@ -331,7 +331,7 @@ main (int argc, char **argv)
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, VERSION,
|
||||
usage, AUTHORS, (char const *) NULL);
|
||||
usage, AUTHORS, (char const *) nullptr);
|
||||
|
||||
/* The above handles --help and --version.
|
||||
Since there is no other invocation of getopt, handle '--' here. */
|
||||
@@ -470,7 +470,7 @@ tostring (VALUE *v)
|
||||
{
|
||||
case integer:
|
||||
{
|
||||
char *s = mpz_get_str (NULL, 10, v->u.i);
|
||||
char *s = mpz_get_str (nullptr, 10, v->u.i);
|
||||
mpz_clear (v->u.i);
|
||||
v->u.s = s;
|
||||
v->type = string;
|
||||
@@ -527,12 +527,12 @@ getsize (mpz_t i)
|
||||
}
|
||||
|
||||
/* Return true and advance if the next token matches STR exactly.
|
||||
STR must not be NULL. */
|
||||
STR must not be null. */
|
||||
|
||||
static bool
|
||||
nextarg (char const *str)
|
||||
{
|
||||
if (*args == NULL)
|
||||
if (*args == nullptr)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
@@ -596,13 +596,13 @@ docolon (VALUE *sv, VALUE *pv)
|
||||
tostring (pv);
|
||||
|
||||
re_regs.num_regs = 0;
|
||||
re_regs.start = NULL;
|
||||
re_regs.end = NULL;
|
||||
re_regs.start = nullptr;
|
||||
re_regs.end = nullptr;
|
||||
|
||||
re_buffer.buffer = NULL;
|
||||
re_buffer.buffer = nullptr;
|
||||
re_buffer.allocated = 0;
|
||||
re_buffer.fastmap = fastmap;
|
||||
re_buffer.translate = NULL;
|
||||
re_buffer.translate = nullptr;
|
||||
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);
|
||||
@@ -652,7 +652,7 @@ docolon (VALUE *sv, VALUE *pv)
|
||||
free (re_regs.start);
|
||||
free (re_regs.end);
|
||||
}
|
||||
re_buffer.fastmap = NULL;
|
||||
re_buffer.fastmap = nullptr;
|
||||
regfree (&re_buffer);
|
||||
return v;
|
||||
}
|
||||
|
||||
20
src/factor.c
20
src/factor.c
@@ -226,11 +226,11 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"exponents", no_argument, NULL, 'h'},
|
||||
{"-debug", no_argument, NULL, DEV_DEBUG_OPTION},
|
||||
{"exponents", no_argument, nullptr, 'h'},
|
||||
{"-debug", no_argument, nullptr, DEV_DEBUG_OPTION},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* If true, use p^e output format. */
|
||||
@@ -594,8 +594,8 @@ static void mp_factor (mpz_t, struct mp_factors *);
|
||||
static void
|
||||
mp_factor_init (struct mp_factors *factors)
|
||||
{
|
||||
factors->p = NULL;
|
||||
factors->e = NULL;
|
||||
factors->p = nullptr;
|
||||
factors->e = nullptr;
|
||||
factors->nfactors = 0;
|
||||
}
|
||||
|
||||
@@ -1389,7 +1389,7 @@ mp_prime_p (mpz_t n)
|
||||
if (mpz_cmp_ui (n, (long) FIRST_OMITTED_PRIME * FIRST_OMITTED_PRIME) < 0)
|
||||
return true;
|
||||
|
||||
mpz_inits (q, a, nm1, tmp, NULL);
|
||||
mpz_inits (q, a, nm1, tmp, nullptr);
|
||||
|
||||
/* Precomputation for Miller-Rabin. */
|
||||
mpz_sub_ui (nm1, n, 1);
|
||||
@@ -1453,7 +1453,7 @@ mp_prime_p (mpz_t n)
|
||||
if (flag_prove_primality)
|
||||
mp_factor_clear (&factors);
|
||||
ret2:
|
||||
mpz_clears (q, a, nm1, tmp, NULL);
|
||||
mpz_clears (q, a, nm1, tmp, nullptr);
|
||||
|
||||
return is_prime;
|
||||
}
|
||||
@@ -1677,7 +1677,7 @@ mp_factor_using_pollard_rho (mpz_t n, unsigned long int a,
|
||||
|
||||
devmsg ("[pollard-rho (%lu)] ", a);
|
||||
|
||||
mpz_inits (t, t2, NULL);
|
||||
mpz_inits (t, t2, nullptr);
|
||||
mpz_init_set_si (y, 2);
|
||||
mpz_init_set_si (x, 2);
|
||||
mpz_init_set_si (z, 2);
|
||||
@@ -1757,7 +1757,7 @@ mp_factor_using_pollard_rho (mpz_t n, unsigned long int a,
|
||||
mpz_mod (y, y, n);
|
||||
}
|
||||
|
||||
mpz_clears (P, t2, t, z, x, y, NULL);
|
||||
mpz_clears (P, t2, t, z, x, y, nullptr);
|
||||
}
|
||||
|
||||
#if USE_SQUFOF
|
||||
@@ -2615,7 +2615,7 @@ main (int argc, char **argv)
|
||||
atexit (lbuf_flush);
|
||||
|
||||
int c;
|
||||
while ((c = getopt_long (argc, argv, "h", long_options, NULL)) != -1)
|
||||
while ((c = getopt_long (argc, argv, "h", long_options, nullptr)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
|
||||
@@ -26,19 +26,19 @@
|
||||
|
||||
/* 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 NULL if unable to determine the mount point.
|
||||
Give a diagnostic and return nullptr 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 = NULL; /* The malloc'd mount point. */
|
||||
char *mp = nullptr; /* The malloc'd mount point. */
|
||||
|
||||
if (save_cwd (&cwd) != 0)
|
||||
{
|
||||
error (0, errno, _("cannot get current directory"));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (S_ISDIR (file_stat->st_mode))
|
||||
@@ -48,7 +48,7 @@ find_mount_point (char const *file, struct stat const *file_stat)
|
||||
if (chdir (file) < 0)
|
||||
{
|
||||
error (0, errno, _("cannot change to directory %s"), quoteaf (file));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -62,7 +62,7 @@ find_mount_point (char const *file, struct stat const *file_stat)
|
||||
if (chdir (dir) < 0)
|
||||
{
|
||||
error (0, errno, _("cannot change to directory %s"), quoteaf (dir));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (stat (".", &last_stat) < 0)
|
||||
|
||||
32
src/fmt.c
32
src/fmt.c
@@ -118,9 +118,9 @@ typedef long int COST;
|
||||
|
||||
/* Extra ctype(3)-style macros. */
|
||||
|
||||
#define isopen(c) (strchr ("(['`\"", c) != NULL)
|
||||
#define isclose(c) (strchr (")]'\"", c) != NULL)
|
||||
#define isperiod(c) (strchr (".?!", c) != NULL)
|
||||
#define isopen(c) (strchr ("(['`\"", c) != nullptr)
|
||||
#define isclose(c) (strchr (")]'\"", c) != nullptr)
|
||||
#define isperiod(c) (strchr (".?!", c) != nullptr)
|
||||
|
||||
/* Size of a tab stop, for expansion on input and re-introduction on
|
||||
output. */
|
||||
@@ -303,16 +303,16 @@ The option -WIDTH is an abbreviated form of --width=DIGITS.\n\
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0},
|
||||
{nullptr, 0, nullptr, 0},
|
||||
};
|
||||
|
||||
int
|
||||
@@ -320,8 +320,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
int optchar;
|
||||
bool ok = true;
|
||||
char const *max_width_option = NULL;
|
||||
char const *goal_width_option = NULL;
|
||||
char const *max_width_option = nullptr;
|
||||
char const *goal_width_option = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -348,7 +348,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
while ((optchar = getopt_long (argc, argv, "0123456789cstuw:p:g:",
|
||||
long_options, NULL))
|
||||
long_options, nullptr))
|
||||
!= -1)
|
||||
switch (optchar)
|
||||
{
|
||||
@@ -406,7 +406,7 @@ main (int argc, char **argv)
|
||||
/* Limit goal_width to max_width. */
|
||||
goal_width = xdectoumax (goal_width_option, 0, max_width, "",
|
||||
_("invalid width"), 0);
|
||||
if (max_width_option == NULL)
|
||||
if (max_width_option == nullptr)
|
||||
max_width = goal_width + 10;
|
||||
}
|
||||
else
|
||||
@@ -435,7 +435,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
FILE *in_stream;
|
||||
in_stream = fopen (file, "r");
|
||||
if (in_stream != NULL)
|
||||
if (in_stream != nullptr)
|
||||
ok &= fmt (in_stream, file);
|
||||
else
|
||||
{
|
||||
|
||||
14
src/fold.c
14
src/fold.c
@@ -48,12 +48,12 @@ static char const shortopts[] = "bsw:0::1::2::3::4::5::6::7::8::9::";
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"bytes", no_argument, NULL, 'b'},
|
||||
{"spaces", no_argument, NULL, 's'},
|
||||
{"width", required_argument, NULL, 'w'},
|
||||
{"bytes", no_argument, nullptr, 'b'},
|
||||
{"spaces", no_argument, nullptr, 's'},
|
||||
{"width", required_argument, nullptr, 'w'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -123,7 +123,7 @@ fold_file (char const *filename, size_t width)
|
||||
int c;
|
||||
size_t column = 0; /* Screen column where next char will go. */
|
||||
size_t offset_out = 0; /* Index in 'line_out' for next char. */
|
||||
static char *line_out = NULL;
|
||||
static char *line_out = nullptr;
|
||||
static size_t allocated_out = 0;
|
||||
int saved_errno;
|
||||
|
||||
@@ -135,7 +135,7 @@ fold_file (char const *filename, size_t width)
|
||||
else
|
||||
istream = fopen (filename, "r");
|
||||
|
||||
if (istream == NULL)
|
||||
if (istream == nullptr)
|
||||
{
|
||||
error (0, errno, "%s", quotef (filename));
|
||||
return false;
|
||||
@@ -254,7 +254,7 @@ main (int argc, char **argv)
|
||||
|
||||
break_spaces = count_bytes = have_read_stdin = false;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, shortopts, longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, shortopts, longopts, nullptr)) != -1)
|
||||
{
|
||||
char optargbuf[2];
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ enum { x_suffix_len = sizeof "XXXXXX" - 1 };
|
||||
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 NULL
|
||||
Use BUF if the template fits, otherwise use malloc and return nullptr
|
||||
(setting errno) if unsuccessful. */
|
||||
|
||||
static char *
|
||||
|
||||
@@ -126,7 +126,8 @@ main (int argc, char **argv)
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
|
||||
VERSION, true, usage, AUTHORS, NULL);
|
||||
VERSION, true, usage, AUTHORS,
|
||||
(char const *) nullptr);
|
||||
|
||||
#define print_int(TYPE) \
|
||||
sprintf (limit + 1, "%"PRIuMAX, (uintmax_t) TYPE##_MAX); \
|
||||
|
||||
@@ -38,12 +38,12 @@ print_group_list (char const *username,
|
||||
bool use_names, char delim)
|
||||
{
|
||||
bool ok = true;
|
||||
struct passwd *pwd = NULL;
|
||||
struct passwd *pwd = nullptr;
|
||||
|
||||
if (username)
|
||||
{
|
||||
pwd = getpwuid (ruid);
|
||||
if (pwd == NULL)
|
||||
if (pwd == nullptr)
|
||||
ok = false;
|
||||
}
|
||||
|
||||
@@ -102,13 +102,13 @@ gidtostr_ptr (gid_t const *gid)
|
||||
extern bool
|
||||
print_group (gid_t gid, bool use_name)
|
||||
{
|
||||
struct group *grp = NULL;
|
||||
struct group *grp = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
if (use_name)
|
||||
{
|
||||
grp = getgrgid (gid);
|
||||
if (grp == NULL)
|
||||
if (grp == nullptr)
|
||||
{
|
||||
error (0, 0, _("cannot find name for group ID %lu"),
|
||||
(unsigned long int) gid);
|
||||
|
||||
@@ -41,7 +41,7 @@ static struct option const longopts[] =
|
||||
{
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -83,7 +83,7 @@ main (int argc, char **argv)
|
||||
/* Processing the arguments this way makes groups.c behave differently to
|
||||
* groups.sh if one of the arguments is "--".
|
||||
*/
|
||||
while ((optc = getopt_long (argc, argv, "", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "", longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
@@ -115,7 +115,7 @@ main (int argc, char **argv)
|
||||
if (rgid == NO_GID && errno)
|
||||
die (EXIT_FAILURE, errno, _("cannot get real GID"));
|
||||
|
||||
if (!print_group_list (NULL, ruid, rgid, egid, true, ' '))
|
||||
if (!print_group_list (nullptr, ruid, rgid, egid, true, ' '))
|
||||
ok = false;
|
||||
putchar ('\n');
|
||||
}
|
||||
@@ -125,7 +125,7 @@ main (int argc, char **argv)
|
||||
for ( ; optind < argc; optind++)
|
||||
{
|
||||
struct passwd *pwd = getpwnam (argv[optind]);
|
||||
if (pwd == NULL)
|
||||
if (pwd == nullptr)
|
||||
{
|
||||
error (0, 0, _("%s: no such user"), quote (argv[optind]));
|
||||
ok = false;
|
||||
|
||||
29
src/head.c
29
src/head.c
@@ -87,17 +87,17 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"bytes", required_argument, NULL, 'c'},
|
||||
{"lines", required_argument, NULL, 'n'},
|
||||
{"-presume-input-pipe", no_argument, NULL,
|
||||
{"bytes", required_argument, nullptr, 'c'},
|
||||
{"lines", required_argument, nullptr, 'n'},
|
||||
{"-presume-input-pipe", no_argument, nullptr,
|
||||
PRESUME_INPUT_PIPE_OPTION}, /* do not document */
|
||||
{"quiet", no_argument, NULL, 'q'},
|
||||
{"silent", no_argument, NULL, 'q'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"zero-terminated", no_argument, NULL, 'z'},
|
||||
{"quiet", no_argument, nullptr, 'q'},
|
||||
{"silent", no_argument, nullptr, 'q'},
|
||||
{"verbose", no_argument, nullptr, 'v'},
|
||||
{"zero-terminated", no_argument, nullptr, 'z'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -354,7 +354,7 @@ elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0,
|
||||
size_t n_read;
|
||||
bool buffered_enough;
|
||||
size_t i, i_next;
|
||||
char **b = NULL;
|
||||
char **b = nullptr;
|
||||
/* Round n_elide up to a multiple of READ_BUFSIZE. */
|
||||
size_t rem = READ_BUFSIZE - (n_elide % READ_BUFSIZE);
|
||||
size_t n_elide_round = n_elide + rem;
|
||||
@@ -514,7 +514,7 @@ elide_tail_lines_pipe (char const *filename, int fd, uintmax_t n_elide,
|
||||
|
||||
first = last = xmalloc (sizeof (LBUFFER));
|
||||
first->nbytes = first->nlines = 0;
|
||||
first->next = NULL;
|
||||
first->next = nullptr;
|
||||
tmp = xmalloc (sizeof (LBUFFER));
|
||||
|
||||
/* Always read into a fresh buffer.
|
||||
@@ -535,7 +535,7 @@ elide_tail_lines_pipe (char const *filename, int fd, uintmax_t n_elide,
|
||||
|
||||
tmp->nbytes = n_read;
|
||||
tmp->nlines = 0;
|
||||
tmp->next = NULL;
|
||||
tmp->next = nullptr;
|
||||
|
||||
/* Count the number of newlines just read. */
|
||||
{
|
||||
@@ -690,7 +690,7 @@ elide_tail_lines_seekable (char const *pretty_filename, int fd,
|
||||
{
|
||||
char const *nl;
|
||||
nl = memrchr (buffer, line_end, n);
|
||||
if (nl == NULL)
|
||||
if (nl == nullptr)
|
||||
break;
|
||||
n = nl - buffer;
|
||||
}
|
||||
@@ -936,7 +936,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* Initializer for file_list if no file-arguments
|
||||
were specified on the command line. */
|
||||
static char const *const default_file_list[] = {"-", NULL};
|
||||
static char const *const default_file_list[] = {"-", nullptr};
|
||||
char const *const *file_list;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
@@ -1021,7 +1021,8 @@ main (int argc, char **argv)
|
||||
argc--;
|
||||
}
|
||||
|
||||
while ((c = getopt_long (argc, argv, "c:n:qvz0123456789", long_options, NULL))
|
||||
while ((c = getopt_long (argc, argv, "c:n:qvz0123456789",
|
||||
long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
|
||||
@@ -65,7 +65,7 @@ main (int argc, char **argv)
|
||||
|
||||
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
|
||||
Version, true, usage, AUTHORS,
|
||||
(char const *) NULL);
|
||||
(char const *) nullptr);
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
|
||||
@@ -86,7 +86,7 @@ main (int argc, char **argv)
|
||||
|
||||
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
|
||||
Version, true, usage, AUTHORS,
|
||||
(char const *) NULL);
|
||||
(char const *) nullptr);
|
||||
|
||||
if (optind + 1 < argc)
|
||||
{
|
||||
@@ -105,7 +105,7 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
hostname = xgethostname ();
|
||||
if (hostname == NULL)
|
||||
if (hostname == nullptr)
|
||||
die (EXIT_FAILURE, errno, _("cannot determine hostname"));
|
||||
puts (hostname);
|
||||
}
|
||||
|
||||
34
src/id.c
34
src/id.c
@@ -66,7 +66,7 @@ static gid_t rgid, egid;
|
||||
|
||||
/* 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 = NULL;
|
||||
static char *context = nullptr;
|
||||
|
||||
static void print_user (uid_t uid);
|
||||
static void print_full_info (char const *username);
|
||||
@@ -74,16 +74,16 @@ static void print_stuff (char const *pw_name);
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -136,7 +136,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "agnruzGZ", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "agnruzGZ", longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
@@ -234,18 +234,18 @@ main (int argc, char **argv)
|
||||
/* For each username/userid to get its pw_name field */
|
||||
for (; optind < n_ids; optind++)
|
||||
{
|
||||
char *pw_name = NULL;
|
||||
struct passwd *pwd = NULL;
|
||||
char *pw_name = nullptr;
|
||||
struct passwd *pwd = nullptr;
|
||||
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, NULL, &pw_name, NULL) == NULL)
|
||||
if (! parse_user_spec (spec, &euid, nullptr, &pw_name, nullptr))
|
||||
pwd = pw_name ? getpwnam (pw_name) : getpwuid (euid);
|
||||
}
|
||||
if (pwd == NULL)
|
||||
if (pwd == nullptr)
|
||||
{
|
||||
error (0, errno, _("%s: no such user"), quote (spec));
|
||||
ok &= false;
|
||||
@@ -299,7 +299,7 @@ main (int argc, char **argv)
|
||||
if (rgid == NO_GID && errno)
|
||||
die (EXIT_FAILURE, errno, _("cannot get real GID"));
|
||||
}
|
||||
print_stuff (NULL);
|
||||
print_stuff (nullptr);
|
||||
}
|
||||
|
||||
return ok ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
@@ -332,12 +332,12 @@ uidtostr_ptr (uid_t const *uid)
|
||||
static void
|
||||
print_user (uid_t uid)
|
||||
{
|
||||
struct passwd *pwd = NULL;
|
||||
struct passwd *pwd = nullptr;
|
||||
|
||||
if (use_name)
|
||||
{
|
||||
pwd = getpwuid (uid);
|
||||
if (pwd == NULL)
|
||||
if (pwd == nullptr)
|
||||
{
|
||||
error (0, 0, _("cannot find name for user ID %s"),
|
||||
uidtostr (uid));
|
||||
|
||||
@@ -62,14 +62,14 @@ static bool use_default_selinux_context = true;
|
||||
# define endpwent() ((void) 0)
|
||||
#endif
|
||||
|
||||
/* The user name that will own the files, or NULL to make the owner
|
||||
/* The user name that will own the files, or nullptr 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 NULL to make the group
|
||||
/* The group name that will own the files, or nullptr to make the group
|
||||
the current group ID. */
|
||||
static char *group_name;
|
||||
|
||||
@@ -114,25 +114,25 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"backup", optional_argument, NULL, 'b'},
|
||||
{"compare", no_argument, NULL, 'C'},
|
||||
{"backup", optional_argument, nullptr, 'b'},
|
||||
{"compare", no_argument, nullptr, 'C'},
|
||||
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Compare content of opened files using file descriptors A_FD and B_FD. Return
|
||||
@@ -216,8 +216,8 @@ need_copy (char const *src_name, char const *dest_name,
|
||||
/* compare SELinux context if preserving */
|
||||
if (selinux_enabled && x->preserve_security_context)
|
||||
{
|
||||
char *file_scontext = NULL;
|
||||
char *to_scontext = NULL;
|
||||
char *file_scontext = nullptr;
|
||||
char *to_scontext = nullptr;
|
||||
bool scontext_match;
|
||||
|
||||
if (getfilecon (src_name, &file_scontext) == -1)
|
||||
@@ -295,11 +295,11 @@ cp_option_init (struct cp_options *x)
|
||||
x->update = false;
|
||||
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 = NULL; /* Whether to set sys default context. */
|
||||
x->set_security_context = nullptr; /* Whether to set sys default context. */
|
||||
x->preserve_xattr = false;
|
||||
x->verbose = false;
|
||||
x->dest_info = NULL;
|
||||
x->src_info = NULL;
|
||||
x->dest_info = nullptr;
|
||||
x->src_info = nullptr;
|
||||
}
|
||||
|
||||
static struct selabel_handle *
|
||||
@@ -310,7 +310,7 @@ get_labeling_handle (void)
|
||||
if (!initialized)
|
||||
{
|
||||
initialized = true;
|
||||
hnd = selabel_open (SELABEL_CTX_FILE, NULL, 0);
|
||||
hnd = selabel_open (SELABEL_CTX_FILE, nullptr, 0);
|
||||
if (!hnd)
|
||||
error (0, errno, _("warning: security labeling handle failed"));
|
||||
}
|
||||
@@ -325,7 +325,7 @@ static void
|
||||
setdefaultfilecon (char const *file)
|
||||
{
|
||||
struct stat st;
|
||||
char *scontext = NULL;
|
||||
char *scontext = nullptr;
|
||||
|
||||
if (selinux_enabled != 1)
|
||||
{
|
||||
@@ -428,7 +428,7 @@ copy_file (char const *from, char const *to,
|
||||
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, NULL);
|
||||
return copy (from, to, to_dirfd, to_relname, 0, x, ©_into_self, nullptr);
|
||||
}
|
||||
|
||||
/* Set the attributes of file or directory NAME aka DIRFD+RELNAME.
|
||||
@@ -505,8 +505,8 @@ strip (char const *name)
|
||||
{
|
||||
char const *safe_name = name;
|
||||
if (name && *name == '-')
|
||||
safe_name = file_name_concat (".", name, NULL);
|
||||
execlp (strip_program, strip_program, safe_name, NULL);
|
||||
safe_name = file_name_concat (".", name, nullptr);
|
||||
execlp (strip_program, strip_program, safe_name, nullptr);
|
||||
die (EXIT_FAILURE, errno, _("cannot run %s"), quoteaf (strip_program));
|
||||
}
|
||||
default: /* Parent. */
|
||||
@@ -532,10 +532,10 @@ get_ids (void)
|
||||
if (owner_name)
|
||||
{
|
||||
pw = getpwnam (owner_name);
|
||||
if (pw == NULL)
|
||||
if (pw == nullptr)
|
||||
{
|
||||
uintmax_t tmp;
|
||||
if (xstrtoumax (owner_name, NULL, 0, &tmp, "") != LONGINT_OK
|
||||
if (xstrtoumax (owner_name, nullptr, 0, &tmp, "") != LONGINT_OK
|
||||
|| UID_T_MAX < tmp)
|
||||
die (EXIT_FAILURE, 0, _("invalid user %s"),
|
||||
quote (owner_name));
|
||||
@@ -551,10 +551,10 @@ get_ids (void)
|
||||
if (group_name)
|
||||
{
|
||||
gr = getgrnam (group_name);
|
||||
if (gr == NULL)
|
||||
if (gr == nullptr)
|
||||
{
|
||||
uintmax_t tmp;
|
||||
if (xstrtoumax (group_name, NULL, 0, &tmp, "") != LONGINT_OK
|
||||
if (xstrtoumax (group_name, nullptr, 0, &tmp, "") != LONGINT_OK
|
||||
|| GID_T_MAX < tmp)
|
||||
die (EXIT_FAILURE, 0, _("invalid group %s"),
|
||||
quote (group_name));
|
||||
@@ -777,18 +777,18 @@ main (int argc, char **argv)
|
||||
{
|
||||
int optc;
|
||||
int exit_status = EXIT_SUCCESS;
|
||||
char const *specified_mode = NULL;
|
||||
char const *specified_mode = nullptr;
|
||||
bool make_backups = false;
|
||||
char const *backup_suffix = NULL;
|
||||
char *version_control_string = NULL;
|
||||
char const *backup_suffix = nullptr;
|
||||
char *version_control_string = nullptr;
|
||||
bool mkdir_and_install = false;
|
||||
struct cp_options x;
|
||||
char const *target_directory = NULL;
|
||||
char const *target_directory = nullptr;
|
||||
bool no_target_directory = false;
|
||||
int n_files;
|
||||
char **file;
|
||||
bool strip_program_specified = false;
|
||||
char const *scontext = NULL;
|
||||
char const *scontext = nullptr;
|
||||
/* set iff kernel has extra selinux system calls */
|
||||
selinux_enabled = (0 < is_selinux_enabled ());
|
||||
|
||||
@@ -802,14 +802,15 @@ main (int argc, char **argv)
|
||||
|
||||
cp_option_init (&x);
|
||||
|
||||
owner_name = NULL;
|
||||
group_name = NULL;
|
||||
owner_name = nullptr;
|
||||
group_name = nullptr;
|
||||
strip_files = false;
|
||||
dir_arg = false;
|
||||
umask (0);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "bcCsDdg:m:o:pt:TvS:Z", long_options,
|
||||
NULL)) != -1)
|
||||
nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
@@ -989,7 +990,7 @@ main (int argc, char **argv)
|
||||
struct mode_change *change = mode_compile (specified_mode);
|
||||
if (!change)
|
||||
die (EXIT_FAILURE, 0, _("invalid mode %s"), quote (specified_mode));
|
||||
mode = mode_adjust (0, false, 0, change, NULL);
|
||||
mode = mode_adjust (0, false, 0, change, nullptr);
|
||||
dir_mode = mode_adjust (0, true, 0, change, &dir_mode_bits);
|
||||
free (change);
|
||||
}
|
||||
|
||||
@@ -116,9 +116,9 @@ iopoll_internal (int fdin, int fdout, bool block, bool broken_output)
|
||||
|
||||
struct timeval delay = { .tv_sec = 0, .tv_usec = 0 };
|
||||
ret = select (nfds,
|
||||
broken_output ? &fds : NULL,
|
||||
broken_output ? NULL : &fds,
|
||||
NULL, block ? NULL : &delay);
|
||||
broken_output ? &fds : nullptr,
|
||||
broken_output ? nullptr : &fds,
|
||||
nullptr, block ? nullptr : &delay);
|
||||
|
||||
if (ret < 0)
|
||||
continue;
|
||||
|
||||
48
src/join.c
48
src/join.c
@@ -88,7 +88,7 @@ struct seq
|
||||
};
|
||||
|
||||
/* The previous line read from each file. */
|
||||
static struct line *prevline[2] = {NULL, NULL};
|
||||
static struct line *prevline[2] = {nullptr, nullptr};
|
||||
|
||||
/* The number of lines read from each file. */
|
||||
static uintmax_t line_no[2] = {0, 0};
|
||||
@@ -99,7 +99,7 @@ static char *g_names[2];
|
||||
/* 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] = {NULL, NULL};
|
||||
static struct line *spareline[2] = {nullptr, nullptr};
|
||||
|
||||
/* True if the LC_COLLATE locale is hard. */
|
||||
static bool hard_LC_COLLATE;
|
||||
@@ -159,14 +159,14 @@ enum
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"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},
|
||||
{"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},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Used to print non-joining lines */
|
||||
@@ -283,7 +283,7 @@ xfields (struct line *line)
|
||||
if (0 <= tab && tab != '\n')
|
||||
{
|
||||
char *sep;
|
||||
for (; (sep = memchr (ptr, tab, lim - ptr)) != NULL; ptr = sep + 1)
|
||||
for (; (sep = memchr (ptr, tab, lim - ptr)) != nullptr; ptr = sep + 1)
|
||||
extract_field (line, ptr, sep - ptr);
|
||||
}
|
||||
else if (tab < 0)
|
||||
@@ -313,12 +313,12 @@ xfields (struct line *line)
|
||||
static void
|
||||
freeline (struct line *line)
|
||||
{
|
||||
if (line == NULL)
|
||||
if (line == nullptr)
|
||||
return;
|
||||
free (line->fields);
|
||||
line->fields = NULL;
|
||||
line->fields = nullptr;
|
||||
free (line->buf.buffer);
|
||||
line->buf.buffer = NULL;
|
||||
line->buf.buffer = nullptr;
|
||||
}
|
||||
|
||||
/* Return <0 if the join field in LINE1 compares less than the one in LINE2;
|
||||
@@ -345,7 +345,7 @@ keycmp (struct line const *line1, struct line const *line2,
|
||||
}
|
||||
else
|
||||
{
|
||||
beg1 = NULL;
|
||||
beg1 = nullptr;
|
||||
len1 = 0;
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ keycmp (struct line const *line1, struct line const *line2,
|
||||
}
|
||||
else
|
||||
{
|
||||
beg2 = NULL;
|
||||
beg2 = nullptr;
|
||||
len2 = 0;
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ initseq (struct seq *seq)
|
||||
{
|
||||
seq->count = 0;
|
||||
seq->alloc = 0;
|
||||
seq->lines = NULL;
|
||||
seq->lines = nullptr;
|
||||
}
|
||||
|
||||
/* Read a line from FP and add it to SEQ. Return true if successful. */
|
||||
@@ -511,7 +511,7 @@ getseq (FILE *fp, struct seq *seq, int whichfile)
|
||||
{
|
||||
seq->lines = X2NREALLOC (seq->lines, &seq->alloc);
|
||||
for (size_t i = seq->count; i < seq->alloc; i++)
|
||||
seq->lines[i] = NULL;
|
||||
seq->lines[i] = nullptr;
|
||||
}
|
||||
|
||||
if (get_line (fp, &seq->lines[seq->count], whichfile))
|
||||
@@ -624,7 +624,7 @@ prjoin (struct line const *line1, struct line const *line2)
|
||||
}
|
||||
prfield (field, line);
|
||||
o = o->next;
|
||||
if (o == NULL)
|
||||
if (o == nullptr)
|
||||
break;
|
||||
putchar (output_separator);
|
||||
}
|
||||
@@ -683,8 +683,8 @@ join (FILE *fp1, FILE *fp2)
|
||||
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] = NULL;
|
||||
prevline[1] = NULL;
|
||||
prevline[0] = nullptr;
|
||||
prevline[1] = nullptr;
|
||||
if (seq1.count)
|
||||
advance_seq (fp1, &seq1, true, 1);
|
||||
if (seq2.count)
|
||||
@@ -769,7 +769,7 @@ join (FILE *fp1, FILE *fp2)
|
||||
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 = NULL;
|
||||
struct line *line = nullptr;
|
||||
bool checktail = false;
|
||||
|
||||
if (check_input_order != CHECK_ORDER_DISABLED
|
||||
@@ -826,7 +826,7 @@ add_field (int file, size_t field)
|
||||
o = xmalloc (sizeof *o);
|
||||
o->file = file;
|
||||
o->field = field;
|
||||
o->next = NULL;
|
||||
o->next = nullptr;
|
||||
|
||||
/* Add to the end of the list so the fields are in the right order. */
|
||||
outlist_end->next = o;
|
||||
@@ -845,7 +845,7 @@ string_to_join_field (char const *str)
|
||||
size_t result;
|
||||
uintmax_t val;
|
||||
|
||||
strtol_error s_err = xstrtoumax (str, NULL, 10, &val, "");
|
||||
strtol_error s_err = xstrtoumax (str, nullptr, 10, &val, "");
|
||||
if (s_err == LONGINT_OVERFLOW || (s_err == LONGINT_OK && SIZE_MAX < val))
|
||||
val = SIZE_MAX;
|
||||
else if (s_err != LONGINT_OK || val == 0)
|
||||
@@ -1030,7 +1030,7 @@ main (int argc, char **argv)
|
||||
check_input_order = CHECK_ORDER_DEFAULT;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "-a:e:i1:2:j:o:t:v:z",
|
||||
longopts, NULL))
|
||||
longopts, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
optc_status = MUST_BE_OPERAND;
|
||||
@@ -1044,7 +1044,7 @@ main (int argc, char **argv)
|
||||
case 'a':
|
||||
{
|
||||
unsigned long int val;
|
||||
if (xstrtoul (optarg, NULL, 10, &val, "") != LONGINT_OK
|
||||
if (xstrtoul (optarg, nullptr, 10, &val, "") != LONGINT_OK
|
||||
|| (val != 1 && val != 2))
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid field number: %s"), quote (optarg));
|
||||
|
||||
12
src/kill.c
12
src/kill.c
@@ -59,12 +59,12 @@ static char const short_options[] =
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"list", no_argument, NULL, 'l'},
|
||||
{"signal", required_argument, NULL, 's'},
|
||||
{"table", no_argument, NULL, 't'},
|
||||
{"list", no_argument, nullptr, 'l'},
|
||||
{"signal", required_argument, nullptr, 's'},
|
||||
{"table", no_argument, nullptr, 't'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -235,7 +235,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, short_options, long_options, NULL))
|
||||
while ((optc = getopt_long (argc, argv, short_options, long_options, nullptr))
|
||||
!= -1)
|
||||
switch (optc)
|
||||
{
|
||||
@@ -310,6 +310,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
return (list
|
||||
? list_signals (table, optind < argc ? argv + optind : NULL)
|
||||
? list_signals (table, optind < argc ? argv + optind : nullptr)
|
||||
: send_signals (signum, argv + optind));
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
the buffer size, and more problematically does not give any indication
|
||||
that the new size request was ignored:
|
||||
|
||||
setvbuf (stdout, NULL, _IOFBF, 8192);
|
||||
setvbuf (stdout, nullptr, _IOFBF, 8192);
|
||||
|
||||
The ISO C99 standard section 7.19.5.6 on the setvbuf function says:
|
||||
|
||||
@@ -50,9 +50,9 @@
|
||||
buffer allocation as usual. If it is not zero, then except for
|
||||
unbuffered files, the buf argument should point to a buffer at least size
|
||||
bytes long; this buffer will be used instead of the current buffer. (If
|
||||
the size argument is not zero but buf is NULL, a buffer of the given size
|
||||
the size argument is not zero but buf is null, a buffer of the given size
|
||||
will be allocated immediately, and released on close. This is an extension
|
||||
to ANSI C; portable code should use a size of 0 with any NULL buffer.)
|
||||
to ANSI C; portable code should use a size of 0 with any null buffer.)
|
||||
--------------------
|
||||
Another issue is that on glibc-2.7 the following doesn't buffer
|
||||
the first write if it's greater than 1 byte.
|
||||
@@ -67,7 +67,7 @@
|
||||
static char const *
|
||||
fileno_to_name (const int fd)
|
||||
{
|
||||
char const *ret = NULL;
|
||||
char const *ret = nullptr;
|
||||
|
||||
switch (fd)
|
||||
{
|
||||
@@ -91,7 +91,7 @@ fileno_to_name (const int fd)
|
||||
static void
|
||||
apply_mode (FILE *stream, char const *mode)
|
||||
{
|
||||
char *buf = NULL;
|
||||
char *buf = nullptr;
|
||||
int setvbuf_mode;
|
||||
uintmax_t size = 0;
|
||||
|
||||
@@ -111,11 +111,11 @@ apply_mode (FILE *stream, char const *mode)
|
||||
return;
|
||||
}
|
||||
|
||||
buf = size <= SIZE_MAX ? malloc (size) : NULL;
|
||||
buf = size <= SIZE_MAX ? malloc (size) : nullptr;
|
||||
if (!buf)
|
||||
{
|
||||
/* We could defer the allocation to libc, however since
|
||||
glibc currently ignores the combination of NULL buffer
|
||||
glibc currently ignores the combination of null buffer
|
||||
with non zero size, we'll fail here. */
|
||||
fprintf (stderr,
|
||||
_("failed to allocate a %" PRIuMAX
|
||||
|
||||
@@ -68,7 +68,7 @@ main (int argc, char **argv)
|
||||
|
||||
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
|
||||
Version, true, usage, AUTHORS,
|
||||
(char const *) NULL);
|
||||
(char const *) nullptr);
|
||||
|
||||
if (argc < optind + 2)
|
||||
{
|
||||
|
||||
53
src/ln.c
53
src/ln.c
@@ -92,22 +92,22 @@ enum { DEST_INFO_INITIAL_CAPACITY = 61 };
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Return an errno value for a system call that returned STATUS.
|
||||
@@ -132,7 +132,7 @@ convert_abs_rel (char const *from, char const *target)
|
||||
char *realdest = canonicalize_filename_mode (targetdir, CAN_MISSING);
|
||||
char *realfrom = canonicalize_filename_mode (from, CAN_MISSING);
|
||||
|
||||
char *relative_from = NULL;
|
||||
char *relative_from = nullptr;
|
||||
if (realdest && realfrom)
|
||||
{
|
||||
/* Write to a PATH_MAX buffer. */
|
||||
@@ -141,7 +141,7 @@ convert_abs_rel (char const *from, char const *target)
|
||||
if (!relpath (realfrom, realdest, relative_from, PATH_MAX))
|
||||
{
|
||||
free (relative_from);
|
||||
relative_from = NULL;
|
||||
relative_from = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,8 +182,8 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
|
||||
{
|
||||
struct stat source_stats;
|
||||
int source_status = 1;
|
||||
char *backup_base = NULL;
|
||||
char *rel_source = NULL;
|
||||
char *backup_base = nullptr;
|
||||
char *rel_source = nullptr;
|
||||
int nofollow_flag = logical ? 0 : AT_SYMLINK_NOFOLLOW;
|
||||
if (link_errno < 0)
|
||||
link_errno = atomic_link (source, destdir_fd, dest_base);
|
||||
@@ -296,7 +296,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
|
||||
{
|
||||
int rename_errno = errno;
|
||||
free (backup_base);
|
||||
backup_base = NULL;
|
||||
backup_base = nullptr;
|
||||
if (rename_errno != ENOENT)
|
||||
{
|
||||
error (0, rename_errno, _("cannot backup %s"),
|
||||
@@ -352,7 +352,7 @@ do_link (char const *source, int destdir_fd, char const *dest_base,
|
||||
if (backup_base)
|
||||
{
|
||||
char *backup = backup_base;
|
||||
void *alloc = NULL;
|
||||
void *alloc = nullptr;
|
||||
ptrdiff_t destdirlen = dest_base - dest;
|
||||
if (0 < destdirlen)
|
||||
{
|
||||
@@ -470,9 +470,9 @@ main (int argc, char **argv)
|
||||
int c;
|
||||
bool ok;
|
||||
bool make_backups = false;
|
||||
char const *backup_suffix = NULL;
|
||||
char *version_control_string = NULL;
|
||||
char const *target_directory = NULL;
|
||||
char const *backup_suffix = nullptr;
|
||||
char *version_control_string = nullptr;
|
||||
char const *target_directory = nullptr;
|
||||
int destdir_fd;
|
||||
bool no_target_directory = false;
|
||||
int n_files;
|
||||
@@ -490,7 +490,8 @@ main (int argc, char **argv)
|
||||
symbolic_link = remove_existing_files = interactive = verbose
|
||||
= hard_dir_link = false;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "bdfinrst:vFLPS:T", long_options, NULL))
|
||||
while ((c = getopt_long (argc, argv, "bdfinrst:vFLPS:T",
|
||||
long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -655,11 +656,11 @@ main (int argc, char **argv)
|
||||
&& backup_type != numbered_backups)
|
||||
{
|
||||
dest_set = hash_initialize (DEST_INFO_INITIAL_CAPACITY,
|
||||
NULL,
|
||||
nullptr,
|
||||
triple_hash,
|
||||
triple_compare,
|
||||
triple_free);
|
||||
if (dest_set == NULL)
|
||||
if (dest_set == nullptr)
|
||||
xalloc_die ();
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ main (int argc, char **argv)
|
||||
|
||||
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
|
||||
Version, true, usage, AUTHORS,
|
||||
(char const *) NULL);
|
||||
(char const *) nullptr);
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
|
||||
238
src/ls.c
238
src/ls.c
@@ -447,7 +447,7 @@ enum time_style
|
||||
|
||||
static char const *const time_style_args[] =
|
||||
{
|
||||
"full-iso", "long-iso", "iso", "locale", NULL
|
||||
"full-iso", "long-iso", "iso", "locale", nullptr
|
||||
};
|
||||
static enum time_style const time_style_types[] =
|
||||
{
|
||||
@@ -553,7 +553,7 @@ static enum indicator_style indicator_style;
|
||||
/* Names of indicator styles. */
|
||||
static char const *const indicator_style_args[] =
|
||||
{
|
||||
"none", "slash", "file-type", "classify", NULL
|
||||
"none", "slash", "file-type", "classify", nullptr
|
||||
};
|
||||
static enum indicator_style const indicator_style_types[] =
|
||||
{
|
||||
@@ -604,7 +604,7 @@ static char const *const indicator_name[]=
|
||||
{
|
||||
"lc", "rc", "ec", "rs", "no", "fi", "di", "ln", "pi", "so",
|
||||
"bd", "cd", "mi", "or", "ex", "do", "su", "sg", "st",
|
||||
"ow", "tw", "ca", "mh", "cl", NULL
|
||||
"ow", "tw", "ca", "mh", "cl", nullptr
|
||||
};
|
||||
|
||||
struct color_ext_type
|
||||
@@ -619,18 +619,18 @@ static struct bin_str color_indicator[] =
|
||||
{
|
||||
{ LEN_STR_PAIR ("\033[") }, /* lc: Left of color sequence */
|
||||
{ LEN_STR_PAIR ("m") }, /* rc: Right of color sequence */
|
||||
{ 0, NULL }, /* ec: End color (replaces lc+rs+rc) */
|
||||
{ 0, nullptr }, /* ec: End color (replaces lc+rs+rc) */
|
||||
{ LEN_STR_PAIR ("0") }, /* rs: Reset to ordinary colors */
|
||||
{ 0, NULL }, /* no: Normal */
|
||||
{ 0, NULL }, /* fi: File: default */
|
||||
{ 0, nullptr }, /* no: Normal */
|
||||
{ 0, nullptr }, /* fi: File: default */
|
||||
{ LEN_STR_PAIR ("01;34") }, /* di: Directory: bright blue */
|
||||
{ LEN_STR_PAIR ("01;36") }, /* ln: Symlink: bright cyan */
|
||||
{ LEN_STR_PAIR ("33") }, /* pi: Pipe: yellow/brown */
|
||||
{ LEN_STR_PAIR ("01;35") }, /* so: Socket: bright magenta */
|
||||
{ LEN_STR_PAIR ("01;33") }, /* bd: Block device: bright yellow */
|
||||
{ LEN_STR_PAIR ("01;33") }, /* cd: Char device: bright yellow */
|
||||
{ 0, NULL }, /* mi: Missing file: undefined */
|
||||
{ 0, NULL }, /* or: Orphaned symlink: undefined */
|
||||
{ 0, nullptr }, /* mi: Missing file: undefined */
|
||||
{ 0, nullptr }, /* or: Orphaned symlink: undefined */
|
||||
{ LEN_STR_PAIR ("01;32") }, /* ex: Executable: bright green */
|
||||
{ LEN_STR_PAIR ("01;35") }, /* do: Door: bright magenta */
|
||||
{ LEN_STR_PAIR ("37;41") }, /* su: setuid: white on red */
|
||||
@@ -638,13 +638,13 @@ static struct bin_str color_indicator[] =
|
||||
{ LEN_STR_PAIR ("37;44") }, /* st: sticky: black on blue */
|
||||
{ LEN_STR_PAIR ("34;42") }, /* ow: other-writable: blue on green */
|
||||
{ LEN_STR_PAIR ("30;42") }, /* tw: ow w/ sticky: black on green */
|
||||
{ 0, NULL }, /* ca: disabled by default */
|
||||
{ 0, NULL }, /* mh: disabled by default */
|
||||
{ 0, nullptr }, /* ca: disabled by default */
|
||||
{ 0, nullptr }, /* mh: disabled by default */
|
||||
{ LEN_STR_PAIR ("\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 = NULL;
|
||||
static struct color_ext_type *color_ext_list = nullptr;
|
||||
|
||||
/* Buffer for color sequences */
|
||||
static char *color_buf;
|
||||
@@ -849,59 +849,59 @@ enum
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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,
|
||||
{"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,
|
||||
GROUP_DIRECTORIES_FIRST_OPTION},
|
||||
{"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,
|
||||
{"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,
|
||||
DEREFERENCE_COMMAND_LINE_SYMLINK_TO_DIR_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},
|
||||
{"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},
|
||||
{"context", no_argument, 0, 'Z'},
|
||||
{"author", no_argument, NULL, AUTHOR_OPTION},
|
||||
{"author", no_argument, nullptr, AUTHOR_OPTION},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
static char const *const format_args[] =
|
||||
{
|
||||
"verbose", "long", "commas", "horizontal", "across",
|
||||
"vertical", "single-column", NULL
|
||||
"vertical", "single-column", nullptr
|
||||
};
|
||||
static enum format const format_types[] =
|
||||
{
|
||||
@@ -912,7 +912,7 @@ ARGMATCH_VERIFY (format_args, format_types);
|
||||
|
||||
static char const *const sort_args[] =
|
||||
{
|
||||
"none", "time", "size", "extension", "version", "width", NULL
|
||||
"none", "time", "size", "extension", "version", "width", nullptr
|
||||
};
|
||||
static enum sort_type const sort_types[] =
|
||||
{
|
||||
@@ -926,7 +926,7 @@ static char const *const time_args[] =
|
||||
"ctime", "status",
|
||||
"mtime", "modification",
|
||||
"birth", "creation",
|
||||
NULL
|
||||
nullptr
|
||||
};
|
||||
static enum time_type const time_types[] =
|
||||
{
|
||||
@@ -942,7 +942,7 @@ static char const *const when_args[] =
|
||||
/* force and none are for compatibility with another color-ls version */
|
||||
"always", "yes", "force",
|
||||
"never", "no", "none",
|
||||
"auto", "tty", "if-tty", NULL
|
||||
"auto", "tty", "if-tty", nullptr
|
||||
};
|
||||
static enum when_type const when_types[] =
|
||||
{
|
||||
@@ -1259,7 +1259,7 @@ fstat_for_ino (int fd, struct stat *st)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Return the address of the first plain %b spec in FMT, or NULL if
|
||||
/* Return the address of the first plain %b spec in FMT, or nullptr if
|
||||
there is no such spec. %5b etc. do not match, so that user
|
||||
widths/flags are honored. */
|
||||
|
||||
@@ -1274,7 +1274,7 @@ first_percent_b (char const *fmt)
|
||||
case 'b': return fmt;
|
||||
case '%': fmt++; break;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static char RFC3986[256];
|
||||
@@ -1424,7 +1424,7 @@ visit_dir (dev_t dev, ino_t ino)
|
||||
/* Attempt to insert this entry into the table. */
|
||||
ent_from_table = hash_insert (active_dir_set, ent);
|
||||
|
||||
if (ent_from_table == NULL)
|
||||
if (ent_from_table == nullptr)
|
||||
{
|
||||
/* Insertion failed due to lack of memory. */
|
||||
xalloc_die ();
|
||||
@@ -1538,7 +1538,7 @@ process_signals (void)
|
||||
|
||||
/* Exit or suspend the program. */
|
||||
raise (sig);
|
||||
sigprocmask (SIG_SETMASK, &oldset, NULL);
|
||||
sigprocmask (SIG_SETMASK, &oldset, nullptr);
|
||||
|
||||
/* If execution reaches here, then the program has been
|
||||
continued (after being suspended). */
|
||||
@@ -1591,7 +1591,7 @@ signal_setup (bool init)
|
||||
sigemptyset (&caught_signals);
|
||||
for (j = 0; j < nsigs; j++)
|
||||
{
|
||||
sigaction (sig[j], NULL, &act);
|
||||
sigaction (sig[j], nullptr, &act);
|
||||
if (act.sa_handler != SIG_IGN)
|
||||
sigaddset (&caught_signals, sig[j]);
|
||||
}
|
||||
@@ -1603,7 +1603,7 @@ signal_setup (bool init)
|
||||
if (sigismember (&caught_signals, sig[j]))
|
||||
{
|
||||
act.sa_handler = sig[j] == SIGTSTP ? stophandler : sighandler;
|
||||
sigaction (sig[j], &act, NULL);
|
||||
sigaction (sig[j], &act, nullptr);
|
||||
}
|
||||
#else
|
||||
for (j = 0; j < nsigs; j++)
|
||||
@@ -1664,7 +1664,7 @@ main (int argc, char **argv)
|
||||
|
||||
exit_status = EXIT_SUCCESS;
|
||||
print_dir_name = true;
|
||||
pending_dirs = NULL;
|
||||
pending_dirs = nullptr;
|
||||
|
||||
current_time.tv_sec = TYPE_MINIMUM (time_t);
|
||||
current_time.tv_nsec = -1;
|
||||
@@ -1707,11 +1707,11 @@ main (int argc, char **argv)
|
||||
detect any directory cycles. */
|
||||
if (recursive)
|
||||
{
|
||||
active_dir_set = hash_initialize (INITIAL_TABLE_SIZE, NULL,
|
||||
active_dir_set = hash_initialize (INITIAL_TABLE_SIZE, nullptr,
|
||||
dev_ino_hash,
|
||||
dev_ino_compare,
|
||||
dev_ino_free);
|
||||
if (active_dir_set == NULL)
|
||||
if (active_dir_set == nullptr)
|
||||
xalloc_die ();
|
||||
|
||||
obstack_init (&dev_ino_obstack);
|
||||
@@ -1759,7 +1759,7 @@ main (int argc, char **argv)
|
||||
if (immediate_dirs)
|
||||
gobble_file (".", directory, NOT_AN_INODE_NUMBER, true, "");
|
||||
else
|
||||
queue_directory (".", NULL, true);
|
||||
queue_directory (".", nullptr, true);
|
||||
}
|
||||
else
|
||||
do
|
||||
@@ -1770,7 +1770,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
sort_files ();
|
||||
if (!immediate_dirs)
|
||||
extract_dirs_from_files (NULL, true);
|
||||
extract_dirs_from_files (nullptr, true);
|
||||
/* 'cwd_n_used' might be zero now. */
|
||||
}
|
||||
|
||||
@@ -1794,9 +1794,9 @@ main (int argc, char **argv)
|
||||
|
||||
if (LOOP_DETECT)
|
||||
{
|
||||
if (thispend->name == NULL)
|
||||
if (thispend->name == nullptr)
|
||||
{
|
||||
/* thispend->name == NULL means this is a marker entry
|
||||
/* thispend->name == nullptr 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. */
|
||||
@@ -1873,7 +1873,7 @@ decode_line_length (char const *spec)
|
||||
|
||||
/* Treat too-large values as if they were 0, which is
|
||||
effectively infinity. */
|
||||
switch (xstrtoumax (spec, NULL, 0, &val, ""))
|
||||
switch (xstrtoumax (spec, nullptr, 0, &val, ""))
|
||||
{
|
||||
case LONGINT_OK:
|
||||
return val <= MIN (PTRDIFF_MAX, SIZE_MAX) ? val : 0;
|
||||
@@ -1904,7 +1904,7 @@ stdout_isatty (void)
|
||||
static int
|
||||
decode_switches (int argc, char **argv)
|
||||
{
|
||||
char *time_style_option = NULL;
|
||||
char *time_style_option = nullptr;
|
||||
|
||||
/* These variables are false or -1 unless a switch says otherwise. */
|
||||
bool kibibytes_specified = false;
|
||||
@@ -2326,7 +2326,7 @@ decode_switches (int argc, char **argv)
|
||||
if (p)
|
||||
{
|
||||
uintmax_t tmp;
|
||||
if (xstrtoumax (p, NULL, 0, &tmp, "") == LONGINT_OK
|
||||
if (xstrtoumax (p, nullptr, 0, &tmp, "") == LONGINT_OK
|
||||
&& tmp <= SIZE_MAX)
|
||||
tabsize = tmp;
|
||||
else
|
||||
@@ -2350,15 +2350,15 @@ decode_switches (int argc, char **argv)
|
||||
? (stdout_isatty () ? shell_escape_quoting_style : -1)
|
||||
: escape_quoting_style);
|
||||
if (0 <= qs)
|
||||
set_quoting_style (NULL, qs);
|
||||
qs = get_quoting_style (NULL);
|
||||
set_quoting_style (nullptr, qs);
|
||||
qs = get_quoting_style (nullptr);
|
||||
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 (NULL);
|
||||
filename_quoting_options = clone_quoting_options (nullptr);
|
||||
if (qs == escape_quoting_style)
|
||||
set_char_quoting (filename_quoting_options, ' ', 1);
|
||||
if (file_type <= indicator_style)
|
||||
@@ -2368,7 +2368,7 @@ decode_switches (int argc, char **argv)
|
||||
set_char_quoting (filename_quoting_options, *p, 1);
|
||||
}
|
||||
|
||||
dirname_quoting_options = clone_quoting_options (NULL);
|
||||
dirname_quoting_options = clone_quoting_options (nullptr);
|
||||
set_char_quoting (dirname_quoting_options, ':', 1);
|
||||
|
||||
/* --dired is meaningful only with --format=long (-l) and sans --hyperlink.
|
||||
@@ -2471,7 +2471,7 @@ decode_switches (int argc, char **argv)
|
||||
{
|
||||
for (int i = 0; i < 2; i++)
|
||||
long_time_format[i] =
|
||||
dcgettext (NULL, long_time_format[i], LC_TIME);
|
||||
dcgettext (nullptr, long_time_format[i], LC_TIME);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2733,7 +2733,7 @@ parse_ls_color (void)
|
||||
char label[3]; /* Indicator label */
|
||||
struct color_ext_type *ext; /* Extension we are working on */
|
||||
|
||||
if ((p = getenv ("LS_COLORS")) == NULL || *p == '\0')
|
||||
if ((p = getenv ("LS_COLORS")) == nullptr || *p == '\0')
|
||||
{
|
||||
/* LS_COLORS takes precedence, but if that's not set then
|
||||
honor the COLORTERM and TERM env variables so that
|
||||
@@ -2745,7 +2745,7 @@ parse_ls_color (void)
|
||||
return;
|
||||
}
|
||||
|
||||
ext = NULL;
|
||||
ext = nullptr;
|
||||
strcpy (label, "??");
|
||||
|
||||
/* This is an overly conservative estimate, but any possible
|
||||
@@ -2809,7 +2809,7 @@ parse_ls_color (void)
|
||||
state = PS_FAIL; /* Assume failure... */
|
||||
if (*(p++) == '=')/* It *should* be... */
|
||||
{
|
||||
for (ind_no = 0; indicator_name[ind_no] != NULL; ++ind_no)
|
||||
for (ind_no = 0; indicator_name[ind_no] != nullptr; ++ind_no)
|
||||
{
|
||||
if (STREQ (label, indicator_name[ind_no]))
|
||||
{
|
||||
@@ -2853,7 +2853,7 @@ parse_ls_color (void)
|
||||
error (0, 0,
|
||||
_("unparsable value for LS_COLORS environment variable"));
|
||||
free (color_buf);
|
||||
for (e = color_ext_list; e != NULL; /* empty */)
|
||||
for (e = color_ext_list; e != nullptr; /* empty */)
|
||||
{
|
||||
e2 = e;
|
||||
e = e->next;
|
||||
@@ -2869,12 +2869,12 @@ parse_ls_color (void)
|
||||
match due to precedence, to avoid redundant string compares. */
|
||||
struct color_ext_type *e1;
|
||||
|
||||
for (e1 = color_ext_list; e1 != NULL; e1 = e1->next)
|
||||
for (e1 = color_ext_list; e1 != nullptr; e1 = e1->next)
|
||||
{
|
||||
struct color_ext_type *e2;
|
||||
bool case_ignored = false;
|
||||
|
||||
for (e2 = e1->next; e2 != NULL; e2 = e2->next)
|
||||
for (e2 = e1->next; e2 != nullptr; e2 = e2->next)
|
||||
{
|
||||
if (e2->ext.len < SIZE_MAX && e1->ext.len == e2->ext.len)
|
||||
{
|
||||
@@ -2958,9 +2958,9 @@ file_failure (bool serious, char const *message, char const *file)
|
||||
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 == NULL is used to insert a marker entry for the
|
||||
real names. NAME == nullptr 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
|
||||
If NAME is non-null, we use its dev/ino information to save
|
||||
a call to stat -- when doing a recursive (-R) traversal.
|
||||
COMMAND_LINE_ARG means this directory was mentioned on the command line. */
|
||||
|
||||
@@ -2968,8 +2968,8 @@ static void
|
||||
queue_directory (char const *name, char const *realname, bool command_line_arg)
|
||||
{
|
||||
struct pending *new = xmalloc (sizeof *new);
|
||||
new->realname = realname ? xstrdup (realname) : NULL;
|
||||
new->name = name ? xstrdup (name) : NULL;
|
||||
new->realname = realname ? xstrdup (realname) : nullptr;
|
||||
new->name = name ? xstrdup (name) : nullptr;
|
||||
new->command_line_arg = command_line_arg;
|
||||
new->next = pending_dirs;
|
||||
pending_dirs = new;
|
||||
@@ -3035,7 +3035,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
|
||||
first = false;
|
||||
dired_indent ();
|
||||
|
||||
char *absolute_name = NULL;
|
||||
char *absolute_name = nullptr;
|
||||
if (print_hyperlink)
|
||||
{
|
||||
absolute_name = canonicalize_filename_mode (name, CAN_MISSING);
|
||||
@@ -3044,7 +3044,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
|
||||
_("error canonicalizing %s"), name);
|
||||
}
|
||||
quote_name (realname ? realname : name, dirname_quoting_options, -1,
|
||||
NULL, true, &subdired_obstack, absolute_name);
|
||||
nullptr, true, &subdired_obstack, absolute_name);
|
||||
|
||||
free (absolute_name);
|
||||
|
||||
@@ -3207,10 +3207,10 @@ has_capability (char const *name)
|
||||
bool has_cap;
|
||||
|
||||
cap_t cap_d = cap_get_file (name);
|
||||
if (cap_d == NULL)
|
||||
if (cap_d == nullptr)
|
||||
return false;
|
||||
|
||||
result = cap_to_text (cap_d, NULL);
|
||||
result = cap_to_text (cap_d, nullptr);
|
||||
cap_free (cap_d);
|
||||
if (!result)
|
||||
return false;
|
||||
@@ -3717,7 +3717,7 @@ static void
|
||||
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 == NULL)
|
||||
if (f->linkname == nullptr)
|
||||
file_failure (command_line_arg, _("cannot read symbolic link %s"),
|
||||
filename);
|
||||
}
|
||||
@@ -3745,14 +3745,14 @@ extract_dirs_from_files (char const *dirname, bool command_line_arg)
|
||||
{
|
||||
size_t i;
|
||||
size_t j;
|
||||
bool ignore_dot_and_dot_dot = (dirname != NULL);
|
||||
bool ignore_dot_and_dot_dot = (dirname != nullptr);
|
||||
|
||||
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 (NULL, dirname, false);
|
||||
queue_directory (nullptr, dirname, false);
|
||||
}
|
||||
|
||||
/* Queue the directories last one first, because queueing reverses the
|
||||
@@ -3769,7 +3769,7 @@ extract_dirs_from_files (char const *dirname, bool command_line_arg)
|
||||
queue_directory (f->name, f->linkname, command_line_arg);
|
||||
else
|
||||
{
|
||||
char *name = file_name_concat (dirname, f->name, NULL);
|
||||
char *name = file_name_concat (dirname, f->name, nullptr);
|
||||
queue_directory (name, f->linkname, command_line_arg);
|
||||
free (name);
|
||||
}
|
||||
@@ -4027,13 +4027,13 @@ static qsortFunc const sort_functions[][2][2][2] =
|
||||
{ rev_xstrcoll_version, rev_xstrcoll_df_version },
|
||||
},
|
||||
|
||||
/* We use NULL for the strcmp variants of version comparison
|
||||
/* We use nullptr 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. */
|
||||
{
|
||||
{ NULL, NULL },
|
||||
{ NULL, NULL },
|
||||
{ nullptr, nullptr },
|
||||
{ nullptr, nullptr },
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4248,7 +4248,7 @@ static void
|
||||
format_user (uid_t u, int width, bool stat_ok)
|
||||
{
|
||||
format_user_or_group (! stat_ok ? "?" :
|
||||
(numeric_ids ? NULL : getuser (u)), u, width);
|
||||
(numeric_ids ? nullptr : getuser (u)), u, width);
|
||||
}
|
||||
|
||||
/* Likewise, for groups. */
|
||||
@@ -4257,7 +4257,7 @@ static void
|
||||
format_group (gid_t g, int width, bool stat_ok)
|
||||
{
|
||||
format_user_or_group (! stat_ok ? "?" :
|
||||
(numeric_ids ? NULL : getgroup (g)), g, width);
|
||||
(numeric_ids ? nullptr : getgroup (g)), g, width);
|
||||
}
|
||||
|
||||
/* Return the number of columns that format_user_or_group will print. */
|
||||
@@ -4271,7 +4271,7 @@ format_user_or_group_width (char const *name, uintmax_t id)
|
||||
return MAX (0, len);
|
||||
}
|
||||
else
|
||||
return snprintf (NULL, 0, "%"PRIuMAX, id);
|
||||
return snprintf (nullptr, 0, "%"PRIuMAX, id);
|
||||
}
|
||||
|
||||
/* Return the number of columns that format_user will print. */
|
||||
@@ -4279,7 +4279,7 @@ format_user_or_group_width (char const *name, uintmax_t id)
|
||||
static int
|
||||
format_user_width (uid_t u)
|
||||
{
|
||||
return format_user_or_group_width (numeric_ids ? NULL : getuser (u), u);
|
||||
return format_user_or_group_width (numeric_ids ? nullptr : getuser (u), u);
|
||||
}
|
||||
|
||||
/* Likewise, for groups. */
|
||||
@@ -4287,7 +4287,7 @@ format_user_width (uid_t u)
|
||||
static int
|
||||
format_group_width (gid_t g)
|
||||
{
|
||||
return format_user_or_group_width (numeric_ids ? NULL : getgroup (g), g);
|
||||
return format_user_or_group_width (numeric_ids ? nullptr : getgroup (g), g);
|
||||
}
|
||||
|
||||
/* Return a pointer to a formatted version of F->stat.st_ino,
|
||||
@@ -4500,7 +4500,7 @@ print_long_format (const struct fileinfo *f)
|
||||
if (f->linkname)
|
||||
{
|
||||
dired_outstring (" -> ");
|
||||
print_name_with_quoting (f, true, NULL, (p - buf) + w + 4);
|
||||
print_name_with_quoting (f, true, nullptr, (p - buf) + w + 4);
|
||||
if (indicator_style != none)
|
||||
print_type_indicator (true, f->linkmode, unknown);
|
||||
}
|
||||
@@ -4509,12 +4509,12 @@ print_long_format (const struct fileinfo *f)
|
||||
print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype);
|
||||
}
|
||||
|
||||
/* Write to *BUF a quoted representation of the file name NAME, if non-NULL,
|
||||
/* Write to *BUF a quoted representation of the file name NAME, if non-null,
|
||||
using OPTIONS to control quoting. *BUF is set to NAME if no quoting
|
||||
is required. *BUF is allocated if more space required (and the original
|
||||
*BUF is not deallocated).
|
||||
Store the number of screen columns occupied by NAME's quoted
|
||||
representation into WIDTH, if non-NULL.
|
||||
representation into WIDTH, if non-null.
|
||||
Store into PAD whether an initial space is needed for padding.
|
||||
Return the number of bytes in *BUF. */
|
||||
|
||||
@@ -4678,7 +4678,7 @@ quote_name_buf (char **inbuf, size_t bufsize, char *name,
|
||||
displayed_width = len;
|
||||
}
|
||||
}
|
||||
else if (width != NULL)
|
||||
else if (width != nullptr)
|
||||
{
|
||||
if (MB_CUR_MAX > 1)
|
||||
displayed_width = mbsnwidth (buf, len, 0);
|
||||
@@ -4702,7 +4702,7 @@ quote_name_buf (char **inbuf, size_t bufsize, char *name,
|
||||
not actually part of the name. */
|
||||
*pad = (align_variable_outer_quotes && cwd_some_quoted && ! quoted);
|
||||
|
||||
if (width != NULL)
|
||||
if (width != nullptr)
|
||||
*width = displayed_width;
|
||||
|
||||
*inbuf = buf;
|
||||
@@ -4764,7 +4764,7 @@ quote_name (char const *name, struct quoting_options const *options,
|
||||
bool pad;
|
||||
|
||||
len = quote_name_buf (&buf, sizeof smallbuf, (char *) name, options,
|
||||
needs_general_quoting, NULL, &pad);
|
||||
needs_general_quoting, nullptr, &pad);
|
||||
|
||||
if (pad && allow_pad)
|
||||
dired_outbyte (' ');
|
||||
@@ -4826,8 +4826,8 @@ print_name_with_quoting (const struct fileinfo *f,
|
||||
{
|
||||
char const *name = symlink_target ? f->linkname : f->name;
|
||||
|
||||
const struct bin_str *color = print_with_color ?
|
||||
get_color_indicator (f, symlink_target) : NULL;
|
||||
const struct bin_str *color
|
||||
= print_with_color ? get_color_indicator (f, symlink_target) : nullptr;
|
||||
|
||||
bool used_color_this_time = (print_with_color
|
||||
&& (color || is_colored (C_NORM)));
|
||||
@@ -4857,7 +4857,7 @@ print_name_with_quoting (const struct fileinfo *f,
|
||||
static void
|
||||
prep_non_filename_text (void)
|
||||
{
|
||||
if (color_indicator[C_END].string != NULL)
|
||||
if (color_indicator[C_END].string != nullptr)
|
||||
put_indicator (&color_indicator[C_END]);
|
||||
else
|
||||
{
|
||||
@@ -4891,7 +4891,7 @@ print_file_name_and_frills (const struct fileinfo *f, size_t start_col)
|
||||
if (print_scontext)
|
||||
printf ("%*s ", format == with_commas ? 0 : scontext_width, f->scontext);
|
||||
|
||||
size_t width = print_name_with_quoting (f, false, NULL, start_col);
|
||||
size_t width = print_name_with_quoting (f, false, nullptr, start_col);
|
||||
|
||||
if (indicator_style != none)
|
||||
width += print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype);
|
||||
@@ -4956,10 +4956,10 @@ print_color_indicator (const struct bin_str *ind)
|
||||
put_indicator (&color_indicator[C_RIGHT]);
|
||||
}
|
||||
|
||||
return ind != NULL;
|
||||
return ind != nullptr;
|
||||
}
|
||||
|
||||
/* Returns color indicator or NULL if none. */
|
||||
/* Returns color indicator or nullptr if none. */
|
||||
ATTRIBUTE_PURE
|
||||
static const struct bin_str*
|
||||
get_color_indicator (const struct fileinfo *f, bool symlink_target)
|
||||
@@ -5042,14 +5042,14 @@ get_color_indicator (const struct fileinfo *f, bool symlink_target)
|
||||
}
|
||||
|
||||
/* Check the file's suffix only if still classified as C_FILE. */
|
||||
ext = NULL;
|
||||
ext = nullptr;
|
||||
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 != NULL; ext = ext->next)
|
||||
for (ext = color_ext_list; ext != nullptr; ext = ext->next)
|
||||
{
|
||||
if (ext->ext.len <= len)
|
||||
{
|
||||
@@ -5079,7 +5079,7 @@ get_color_indicator (const struct fileinfo *f, bool symlink_target)
|
||||
const struct bin_str *const s
|
||||
= ext ? &(ext->seq) : &color_indicator[type];
|
||||
|
||||
return s->string ? s : NULL;
|
||||
return s->string ? s : nullptr;
|
||||
}
|
||||
|
||||
/* Output a color indicator (which may contain nulls). */
|
||||
|
||||
24
src/mkdir.c
24
src/mkdir.c
@@ -41,12 +41,12 @@
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
|
||||
{"mode", required_argument, NULL, 'm'},
|
||||
{"parents", no_argument, NULL, 'p'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"mode", required_argument, nullptr, 'm'},
|
||||
{"parents", no_argument, nullptr, 'p'},
|
||||
{"verbose", no_argument, nullptr, 'v'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -85,7 +85,7 @@ Create the DIRECTORY(ies), if they do not already exist.\n\
|
||||
/* Options passed to subsidiary functions. */
|
||||
struct mkdir_options
|
||||
{
|
||||
/* Function to make an ancestor, or NULL if ancestors should not be
|
||||
/* Function to make an ancestor, or nullptr if ancestors should not be
|
||||
made. */
|
||||
int (*make_ancestor_function) (char const *, char const *, void *);
|
||||
|
||||
@@ -192,16 +192,16 @@ process_dir (char *dir, struct savewd *wd, void *options)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char const *specified_mode = NULL;
|
||||
char const *specified_mode = nullptr;
|
||||
int optc;
|
||||
char const *scontext = NULL;
|
||||
char const *scontext = nullptr;
|
||||
struct mkdir_options options;
|
||||
|
||||
options.make_ancestor_function = NULL;
|
||||
options.make_ancestor_function = nullptr;
|
||||
options.mode = S_IRWXUGO;
|
||||
options.mode_bits = 0;
|
||||
options.created_directory_format = NULL;
|
||||
options.set_security_context = NULL;
|
||||
options.created_directory_format = nullptr;
|
||||
options.set_security_context = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -211,7 +211,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "pm:vZ", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "pm:vZ", longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
@@ -237,7 +237,7 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
options.set_security_context = selabel_open (SELABEL_CTX_FILE,
|
||||
NULL, 0);
|
||||
nullptr, 0);
|
||||
if (! options.set_security_context)
|
||||
error (0, errno, _("warning: ignoring --context"));
|
||||
}
|
||||
|
||||
16
src/mkfifo.c
16
src/mkfifo.c
@@ -38,10 +38,10 @@
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
|
||||
{"mode", required_argument, NULL, 'm'},
|
||||
{"mode", required_argument, nullptr, 'm'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -77,11 +77,11 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
mode_t newmode;
|
||||
char const *specified_mode = NULL;
|
||||
char const *specified_mode = nullptr;
|
||||
int exit_status = EXIT_SUCCESS;
|
||||
int optc;
|
||||
char const *scontext = NULL;
|
||||
struct selabel_handle *set_security_context = NULL;
|
||||
char const *scontext = nullptr;
|
||||
struct selabel_handle *set_security_context = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -91,7 +91,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "m:Z", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "m:Z", longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
@@ -111,7 +111,7 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
set_security_context = selabel_open (SELABEL_CTX_FILE,
|
||||
NULL, 0);
|
||||
nullptr, 0);
|
||||
if (! set_security_context)
|
||||
error (0, errno, _("warning: ignoring --context"));
|
||||
}
|
||||
@@ -159,7 +159,7 @@ main (int argc, char **argv)
|
||||
die (EXIT_FAILURE, 0, _("invalid mode"));
|
||||
umask_value = umask (0);
|
||||
umask (umask_value);
|
||||
newmode = mode_adjust (newmode, false, umask_value, change, NULL);
|
||||
newmode = mode_adjust (newmode, false, umask_value, change, nullptr);
|
||||
free (change);
|
||||
if (newmode & ~S_IRWXUGO)
|
||||
die (EXIT_FAILURE, 0,
|
||||
|
||||
20
src/mknod.c
20
src/mknod.c
@@ -39,10 +39,10 @@
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{GETOPT_SELINUX_CONTEXT_OPTION_DECL},
|
||||
{"mode", required_argument, NULL, 'm'},
|
||||
{"mode", required_argument, nullptr, 'm'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -93,12 +93,12 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
mode_t newmode;
|
||||
char const *specified_mode = NULL;
|
||||
char const *specified_mode = nullptr;
|
||||
int optc;
|
||||
size_t expected_operands;
|
||||
mode_t node_type;
|
||||
char const *scontext = NULL;
|
||||
struct selabel_handle *set_security_context = NULL;
|
||||
char const *scontext = nullptr;
|
||||
struct selabel_handle *set_security_context = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -108,7 +108,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "m:Z", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "m:Z", longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
@@ -128,7 +128,7 @@ main (int argc, char **argv)
|
||||
else
|
||||
{
|
||||
set_security_context = selabel_open (SELABEL_CTX_FILE,
|
||||
NULL, 0);
|
||||
nullptr, 0);
|
||||
if (! set_security_context)
|
||||
error (0, errno, _("warning: ignoring --context"));
|
||||
}
|
||||
@@ -156,7 +156,7 @@ main (int argc, char **argv)
|
||||
die (EXIT_FAILURE, 0, _("invalid mode"));
|
||||
umask_value = umask (0);
|
||||
umask (umask_value);
|
||||
newmode = mode_adjust (newmode, false, umask_value, change, NULL);
|
||||
newmode = mode_adjust (newmode, false, umask_value, change, nullptr);
|
||||
free (change);
|
||||
if (newmode & ~S_IRWXUGO)
|
||||
die (EXIT_FAILURE, 0,
|
||||
@@ -235,12 +235,12 @@ main (int argc, char **argv)
|
||||
uintmax_t i_major, i_minor;
|
||||
dev_t device;
|
||||
|
||||
if (xstrtoumax (s_major, NULL, 0, &i_major, "") != LONGINT_OK
|
||||
if (xstrtoumax (s_major, nullptr, 0, &i_major, "") != LONGINT_OK
|
||||
|| i_major != (major_t) i_major)
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid major device number %s"), quote (s_major));
|
||||
|
||||
if (xstrtoumax (s_minor, NULL, 0, &i_minor, "") != LONGINT_OK
|
||||
if (xstrtoumax (s_minor, nullptr, 0, &i_minor, "") != LONGINT_OK
|
||||
|| i_minor != (minor_t) i_minor)
|
||||
die (EXIT_FAILURE, 0,
|
||||
_("invalid minor device number %s"), quote (s_minor));
|
||||
|
||||
20
src/mktemp.c
20
src/mktemp.c
@@ -47,14 +47,14 @@ enum
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -146,12 +146,12 @@ int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
char const *dest_dir;
|
||||
char const *dest_dir_arg = NULL;
|
||||
char const *dest_dir_arg = nullptr;
|
||||
bool suppress_file_err = false;
|
||||
int c;
|
||||
unsigned int n_args;
|
||||
char *template;
|
||||
char *suffix = NULL;
|
||||
char *suffix = nullptr;
|
||||
bool use_dest_dir = false;
|
||||
bool deprecated_t_option = false;
|
||||
bool create_directory = false;
|
||||
@@ -169,7 +169,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (maybe_close_stdout);
|
||||
|
||||
while ((c = getopt_long (argc, argv, "dp:qtuV", longopts, NULL)) != -1)
|
||||
while ((c = getopt_long (argc, argv, "dp:qtuV", longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
@@ -293,7 +293,7 @@ main (int argc, char **argv)
|
||||
quote (template));
|
||||
}
|
||||
|
||||
dest_name = file_name_concat (dest_dir, template, NULL);
|
||||
dest_name = file_name_concat (dest_dir, template, nullptr);
|
||||
free (template);
|
||||
template = dest_name;
|
||||
/* Note that suffix is now invalid. */
|
||||
|
||||
60
src/mv.c
60
src/mv.c
@@ -56,7 +56,7 @@ enum
|
||||
|
||||
static char const *const update_type_string[] =
|
||||
{
|
||||
"all", "none", "older", NULL
|
||||
"all", "none", "older", nullptr
|
||||
};
|
||||
static enum Update_type const update_type[] =
|
||||
{
|
||||
@@ -66,22 +66,23 @@ ARGMATCH_VERIFY (update_type_string, update_type);
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"backup", optional_argument, NULL, 'b'},
|
||||
{"context", no_argument, NULL, 'Z'},
|
||||
{"debug", no_argument, NULL, DEBUG_OPTION},
|
||||
{"force", no_argument, NULL, 'f'},
|
||||
{"interactive", no_argument, NULL, 'i'},
|
||||
{"no-clobber", no_argument, NULL, 'n'},
|
||||
{"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, NULL, 'S'},
|
||||
{"target-directory", required_argument, NULL, 't'},
|
||||
{"update", optional_argument, NULL, 'u'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"backup", optional_argument, nullptr, 'b'},
|
||||
{"context", no_argument, nullptr, 'Z'},
|
||||
{"debug", no_argument, nullptr, DEBUG_OPTION},
|
||||
{"force", no_argument, nullptr, 'f'},
|
||||
{"interactive", no_argument, nullptr, 'i'},
|
||||
{"no-clobber", no_argument, nullptr, 'n'},
|
||||
{"no-copy", no_argument, nullptr, NO_COPY_OPTION},
|
||||
{"no-target-directory", no_argument, nullptr, 'T'},
|
||||
{"strip-trailing-slashes", no_argument, nullptr,
|
||||
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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
static void
|
||||
@@ -108,7 +109,7 @@ rm_option_init (struct rm_options *x)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
x->root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (x->root_dev_ino == NULL)
|
||||
if (x->root_dev_ino == nullptr)
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
@@ -138,7 +139,7 @@ cp_option_init (struct cp_options *x)
|
||||
x->preserve_timestamps = true;
|
||||
x->explicit_no_preserve_mode= false;
|
||||
x->preserve_security_context = selinux_enabled;
|
||||
x->set_security_context = NULL;
|
||||
x->set_security_context = nullptr;
|
||||
x->reduce_diagnostics = false;
|
||||
x->data_copy_required = true;
|
||||
x->require_preserve = false; /* FIXME: maybe make this an option */
|
||||
@@ -155,8 +156,8 @@ cp_option_init (struct cp_options *x)
|
||||
x->open_dangling_dest_symlink = false;
|
||||
x->update = false;
|
||||
x->verbose = false;
|
||||
x->dest_info = NULL;
|
||||
x->src_info = NULL;
|
||||
x->dest_info = nullptr;
|
||||
x->src_info = nullptr;
|
||||
}
|
||||
|
||||
/* Move SOURCE onto DEST aka DEST_DIRFD+DEST_RELNAME.
|
||||
@@ -189,14 +190,14 @@ do_move (char const *source, char const *dest,
|
||||
copied-into-self directory, DEST ('b/b' in the example),
|
||||
and failing. */
|
||||
|
||||
dir_to_remove = NULL;
|
||||
dir_to_remove = nullptr;
|
||||
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 = NULL;
|
||||
dir_to_remove = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -225,7 +226,7 @@ do_move (char const *source, char const *dest,
|
||||
dir_to_remove = source;
|
||||
}
|
||||
|
||||
if (dir_to_remove != NULL)
|
||||
if (dir_to_remove != nullptr)
|
||||
{
|
||||
struct rm_options rm_options;
|
||||
enum RM_status status;
|
||||
@@ -234,7 +235,7 @@ do_move (char const *source, char const *dest,
|
||||
rm_option_init (&rm_options);
|
||||
rm_options.verbose = x->verbose;
|
||||
dir[0] = dir_to_remove;
|
||||
dir[1] = NULL;
|
||||
dir[1] = nullptr;
|
||||
|
||||
status = rm ((void *) dir, &rm_options);
|
||||
assert (VALID_STATUS (status));
|
||||
@@ -314,11 +315,11 @@ main (int argc, char **argv)
|
||||
int c;
|
||||
bool ok;
|
||||
bool make_backups = false;
|
||||
char const *backup_suffix = NULL;
|
||||
char *version_control_string = NULL;
|
||||
char const *backup_suffix = nullptr;
|
||||
char *version_control_string = nullptr;
|
||||
struct cp_options x;
|
||||
bool remove_trailing_slashes = false;
|
||||
char const *target_directory = NULL;
|
||||
char const *target_directory = nullptr;
|
||||
bool no_target_directory = false;
|
||||
int n_files;
|
||||
char **file;
|
||||
@@ -337,7 +338,7 @@ main (int argc, char **argv)
|
||||
/* Try to disable the ability to unlink a directory. */
|
||||
priv_set_remove_linkdir ();
|
||||
|
||||
while ((c = getopt_long (argc, argv, "bfint:uvS:TZ", long_options, NULL))
|
||||
while ((c = getopt_long (argc, argv, "bfint:uvS:TZ", long_options, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -374,7 +375,7 @@ main (int argc, char **argv)
|
||||
no_target_directory = true;
|
||||
break;
|
||||
case 'u':
|
||||
if (optarg == NULL)
|
||||
if (optarg == nullptr)
|
||||
x.update = true;
|
||||
else if (x.interactive != I_ALWAYS_NO) /* -n takes precedence. */
|
||||
{
|
||||
@@ -412,7 +413,8 @@ main (int argc, char **argv)
|
||||
if (selinux_enabled)
|
||||
{
|
||||
x.preserve_security_context = false;
|
||||
x.set_security_context = selabel_open (SELABEL_CTX_FILE, NULL, 0);
|
||||
x.set_security_context = selabel_open (SELABEL_CTX_FILE,
|
||||
nullptr, 0);
|
||||
if (! x.set_security_context)
|
||||
error (0, errno, _("warning: ignoring --context"));
|
||||
}
|
||||
|
||||
10
src/nice.c
10
src/nice.c
@@ -57,10 +57,10 @@
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"adjustment", required_argument, NULL, 'n'},
|
||||
{"adjustment", required_argument, nullptr, 'n'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -103,7 +103,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
int current_niceness;
|
||||
int adjustment = 10;
|
||||
char const *adjustment_given = NULL;
|
||||
char const *adjustment_given = nullptr;
|
||||
bool ok;
|
||||
int i;
|
||||
|
||||
@@ -137,7 +137,7 @@ main (int argc, char **argv)
|
||||
/* Initialize getopt_long's internal state. */
|
||||
optind = 0;
|
||||
|
||||
c = getopt_long (fake_argc, fake_argv, "+n:", longopts, NULL);
|
||||
c = getopt_long (fake_argc, fake_argv, "+n:", longopts, nullptr);
|
||||
i += optind - 1;
|
||||
|
||||
switch (c)
|
||||
@@ -170,7 +170,7 @@ main (int argc, char **argv)
|
||||
"setpriority" and "nice" do. */
|
||||
enum { MIN_ADJUSTMENT = 1 - 2 * NZERO, MAX_ADJUSTMENT = 2 * NZERO - 1 };
|
||||
long int tmp;
|
||||
if (LONGINT_OVERFLOW < xstrtol (adjustment_given, NULL, 10, &tmp, ""))
|
||||
if (LONGINT_OVERFLOW < xstrtol (adjustment_given, nullptr, 10, &tmp, ""))
|
||||
die (EXIT_CANCELED, 0, _("invalid adjustment %s"),
|
||||
quote (adjustment_given));
|
||||
adjustment = MAX (MIN_ADJUSTMENT, MIN (tmp, MAX_ADJUSTMENT));
|
||||
|
||||
45
src/nl.c
45
src/nl.c
@@ -90,7 +90,7 @@ static char header_fastmap[UCHAR_MAX + 1];
|
||||
static char footer_fastmap[UCHAR_MAX + 1];
|
||||
|
||||
/* Pointer to current regex, if any. */
|
||||
static struct re_pattern_buffer *current_regex = NULL;
|
||||
static struct re_pattern_buffer *current_regex = nullptr;
|
||||
|
||||
/* Separator string to print after line number (-s). */
|
||||
static char const *separator_str = "\t";
|
||||
@@ -99,19 +99,19 @@ static char const *separator_str = "\t";
|
||||
static char *section_del = DEFAULT_SECTION_DELIMITERS;
|
||||
|
||||
/* Header delimiter string. */
|
||||
static char *header_del = NULL;
|
||||
static char *header_del = nullptr;
|
||||
|
||||
/* Header section delimiter length. */
|
||||
static size_t header_del_len;
|
||||
|
||||
/* Body delimiter string. */
|
||||
static char *body_del = NULL;
|
||||
static char *body_del = nullptr;
|
||||
|
||||
/* Body section delimiter length. */
|
||||
static size_t body_del_len;
|
||||
|
||||
/* Footer delimiter string. */
|
||||
static char *footer_del = NULL;
|
||||
static char *footer_del = nullptr;
|
||||
|
||||
/* Footer section delimiter length. */
|
||||
static size_t footer_del_len;
|
||||
@@ -120,7 +120,7 @@ static size_t footer_del_len;
|
||||
static struct linebuffer line_buf;
|
||||
|
||||
/* printf format string for unnumbered lines. */
|
||||
static char *print_no_line_fmt = NULL;
|
||||
static char *print_no_line_fmt = nullptr;
|
||||
|
||||
/* Starting line number on each page (-v). */
|
||||
static intmax_t starting_line_number = 1;
|
||||
@@ -151,20 +151,20 @@ static bool have_read_stdin;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Print a usage message and quit. */
|
||||
@@ -258,10 +258,10 @@ build_type_arg (char const **typep,
|
||||
break;
|
||||
case 'p':
|
||||
*typep = optarg++;
|
||||
regexp->buffer = NULL;
|
||||
regexp->buffer = nullptr;
|
||||
regexp->allocated = 0;
|
||||
regexp->fastmap = fastmap;
|
||||
regexp->translate = NULL;
|
||||
regexp->translate = nullptr;
|
||||
re_syntax_options =
|
||||
RE_SYNTAX_POSIX_BASIC & ~RE_CONTEXT_INVALID_DUP & ~RE_NO_EMPTY_RANGES;
|
||||
errmsg = re_compile_pattern (optarg, strlen (optarg), regexp);
|
||||
@@ -366,7 +366,7 @@ proc_text (void)
|
||||
break;
|
||||
case 'p':
|
||||
switch (re_search (current_regex, line_buf.buffer, line_buf.length - 1,
|
||||
0, line_buf.length - 1, NULL))
|
||||
0, line_buf.length - 1, nullptr))
|
||||
{
|
||||
case -2:
|
||||
die (EXIT_FAILURE, errno, _("error in regular expression search"));
|
||||
@@ -446,7 +446,7 @@ nl_file (char const *file)
|
||||
else
|
||||
{
|
||||
stream = fopen (file, "r");
|
||||
if (stream == NULL)
|
||||
if (stream == nullptr)
|
||||
{
|
||||
error (0, errno, "%s", quotef (file));
|
||||
return false;
|
||||
@@ -492,7 +492,8 @@ main (int argc, char **argv)
|
||||
have_read_stdin = false;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "h:b:f:v:i:pl:s:w:n:d:", longopts,
|
||||
NULL)) != -1)
|
||||
nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
|
||||
@@ -106,7 +106,7 @@ main (int argc, char **argv)
|
||||
|
||||
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
|
||||
Version, false, usage, AUTHORS,
|
||||
(char const *) NULL);
|
||||
(char const *) nullptr);
|
||||
|
||||
if (argc <= optind)
|
||||
{
|
||||
@@ -137,7 +137,7 @@ main (int argc, char **argv)
|
||||
$HOME/nohup.out without redirecting anything. */
|
||||
if (redirecting_stdout || (redirecting_stderr && stdout_is_closed))
|
||||
{
|
||||
char *in_home = NULL;
|
||||
char *in_home = nullptr;
|
||||
char const *file = "nohup.out";
|
||||
int flags = O_CREAT | O_WRONLY | O_APPEND;
|
||||
mode_t mode = S_IRUSR | S_IWUSR;
|
||||
@@ -152,7 +152,7 @@ main (int argc, char **argv)
|
||||
char const *home = getenv ("HOME");
|
||||
if (home)
|
||||
{
|
||||
in_home = file_name_concat (home, file, NULL);
|
||||
in_home = file_name_concat (home, file, nullptr);
|
||||
out_fd = (redirecting_stdout
|
||||
? fd_reopen (STDOUT_FILENO, in_home, flags, mode)
|
||||
: open (in_home, flags, mode));
|
||||
|
||||
@@ -40,11 +40,11 @@ enum
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"all", no_argument, NULL, ALL_OPTION},
|
||||
{"ignore", required_argument, NULL, IGNORE_OPTION},
|
||||
{"all", no_argument, nullptr, ALL_OPTION},
|
||||
{"ignore", required_argument, nullptr, IGNORE_OPTION},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -88,7 +88,7 @@ main (int argc, char **argv)
|
||||
|
||||
while (true)
|
||||
{
|
||||
int c = getopt_long (argc, argv, "", longopts, NULL);
|
||||
int c = getopt_long (argc, argv, "", longopts, nullptr);
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c)
|
||||
|
||||
78
src/numfmt.c
78
src/numfmt.c
@@ -73,7 +73,7 @@ enum scale_type
|
||||
|
||||
static char const *const scale_from_args[] =
|
||||
{
|
||||
"none", "auto", "si", "iec", "iec-i", NULL
|
||||
"none", "auto", "si", "iec", "iec-i", nullptr
|
||||
};
|
||||
|
||||
static enum scale_type const scale_from_types[] =
|
||||
@@ -83,7 +83,7 @@ static enum scale_type const scale_from_types[] =
|
||||
|
||||
static char const *const scale_to_args[] =
|
||||
{
|
||||
"none", "si", "iec", "iec-i", NULL
|
||||
"none", "si", "iec", "iec-i", nullptr
|
||||
};
|
||||
|
||||
static enum scale_type const scale_to_types[] =
|
||||
@@ -103,7 +103,7 @@ enum round_type
|
||||
|
||||
static char const *const round_args[] =
|
||||
{
|
||||
"up", "down", "from-zero", "towards-zero", "nearest", NULL
|
||||
"up", "down", "from-zero", "towards-zero", "nearest", nullptr
|
||||
};
|
||||
|
||||
static enum round_type const round_types[] =
|
||||
@@ -122,7 +122,7 @@ enum inval_type
|
||||
|
||||
static char const *const inval_args[] =
|
||||
{
|
||||
"abort", "fail", "warn", "ignore", NULL
|
||||
"abort", "fail", "warn", "ignore", nullptr
|
||||
};
|
||||
|
||||
static enum inval_type const inval_types[] =
|
||||
@@ -132,25 +132,25 @@ static enum inval_type const inval_types[] =
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"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},
|
||||
{"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'},
|
||||
{"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},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* If delimiter has this value, blanks separate fields. */
|
||||
@@ -170,18 +170,18 @@ static enum scale_type scale_from = scale_none;
|
||||
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 = NULL;
|
||||
static char const *suffix = nullptr;
|
||||
static uintmax_t from_unit_size = 1;
|
||||
static uintmax_t to_unit_size = 1;
|
||||
static int grouping = 0;
|
||||
static char *padding_buffer = NULL;
|
||||
static char *padding_buffer = nullptr;
|
||||
static size_t padding_buffer_size = 0;
|
||||
static long int padding_width = 0;
|
||||
static long int zero_padding_width = 0;
|
||||
static long int user_precision = -1;
|
||||
static char const *format_str = NULL;
|
||||
static char *format_str_prefix = NULL;
|
||||
static char *format_str_suffix = NULL;
|
||||
static char const *format_str = nullptr;
|
||||
static char *format_str_prefix = nullptr;
|
||||
static char *format_str_suffix = nullptr;
|
||||
|
||||
/* By default, any conversion error will terminate the program. */
|
||||
static int conv_exit_code = EXIT_CONVERSION_WARNINGS;
|
||||
@@ -235,7 +235,7 @@ static char const *valid_suffixes = 1 + zero_and_valid_suffixes;
|
||||
static inline bool
|
||||
valid_suffix (const char suf)
|
||||
{
|
||||
return strchr (valid_suffixes, suf) != NULL;
|
||||
return strchr (valid_suffixes, suf) != nullptr;
|
||||
}
|
||||
|
||||
static inline int
|
||||
@@ -695,7 +695,7 @@ simple_strtod_human (char const *input_str,
|
||||
static void
|
||||
simple_strtod_fatal (enum simple_strtod_error err, char const *input_str)
|
||||
{
|
||||
char const *msgid = NULL;
|
||||
char const *msgid = nullptr;
|
||||
|
||||
switch (err)
|
||||
{
|
||||
@@ -840,9 +840,9 @@ unit_to_umax (char const *n_string)
|
||||
{
|
||||
strtol_error s_err;
|
||||
char const *c_string = n_string;
|
||||
char *t_string = NULL;
|
||||
char *t_string = nullptr;
|
||||
size_t n_len = strlen (n_string);
|
||||
char *end = NULL;
|
||||
char *end = nullptr;
|
||||
uintmax_t n;
|
||||
char const *suffixes = valid_suffixes;
|
||||
|
||||
@@ -1064,7 +1064,7 @@ parse_format_string (char const *fmt)
|
||||
size_t prefix_len = 0;
|
||||
size_t suffix_pos;
|
||||
long int pad = 0;
|
||||
char *endptr = NULL;
|
||||
char *endptr = nullptr;
|
||||
bool zero_padding = false;
|
||||
|
||||
for (i = 0; !(fmt[i] == '%' && fmt[i + 1] != '%'); i += (fmt[i] == '%') + 1)
|
||||
@@ -1182,7 +1182,7 @@ static enum simple_strtod_error
|
||||
parse_human_number (char const *str, long double /*output */ *value,
|
||||
size_t *precision)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
char *ptr = nullptr;
|
||||
|
||||
enum simple_strtod_error e =
|
||||
simple_strtod_human (str, &ptr, value, precision, scale_from);
|
||||
@@ -1469,7 +1469,7 @@ main (int argc, char **argv)
|
||||
#endif
|
||||
|
||||
decimal_point = nl_langinfo (RADIXCHAR);
|
||||
if (decimal_point == NULL || strlen (decimal_point) == 0)
|
||||
if (decimal_point == nullptr || strlen (decimal_point) == 0)
|
||||
decimal_point = ".";
|
||||
decimal_point_length = strlen (decimal_point);
|
||||
|
||||
@@ -1477,7 +1477,7 @@ main (int argc, char **argv)
|
||||
|
||||
while (true)
|
||||
{
|
||||
int c = getopt_long (argc, argv, "d:z", longopts, NULL);
|
||||
int c = getopt_long (argc, argv, "d:z", longopts, nullptr);
|
||||
|
||||
if (c == -1)
|
||||
break;
|
||||
@@ -1511,7 +1511,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case PADDING_OPTION:
|
||||
if (xstrtol (optarg, NULL, 10, &padding_width, "") != LONGINT_OK
|
||||
if (xstrtol (optarg, nullptr, 10, &padding_width, "") != LONGINT_OK
|
||||
|| padding_width == 0 || padding_width < -LONG_MAX)
|
||||
die (EXIT_FAILURE, 0, _("invalid padding value %s"),
|
||||
quote (optarg));
|
||||
@@ -1558,7 +1558,7 @@ main (int argc, char **argv)
|
||||
case HEADER_OPTION:
|
||||
if (optarg)
|
||||
{
|
||||
if (xstrtoumax (optarg, NULL, 10, &header, "") != LONGINT_OK
|
||||
if (xstrtoumax (optarg, nullptr, 10, &header, "") != LONGINT_OK
|
||||
|| header == 0)
|
||||
die (EXIT_FAILURE, 0, _("invalid header value %s"),
|
||||
quote (optarg));
|
||||
@@ -1586,7 +1586,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (format_str != NULL && grouping)
|
||||
if (format_str != nullptr && grouping)
|
||||
die (EXIT_FAILURE, 0, _("--grouping cannot be combined with --format"));
|
||||
|
||||
if (debug && ! locale_ok)
|
||||
@@ -1594,7 +1594,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* Warn about no-op. */
|
||||
if (debug && scale_from == scale_none && scale_to == scale_none
|
||||
&& !grouping && (padding_width == 0) && (format_str == NULL))
|
||||
&& !grouping && (padding_width == 0) && (format_str == nullptr))
|
||||
error (0, 0, _("no conversion option specified"));
|
||||
|
||||
if (format_str)
|
||||
@@ -1625,7 +1625,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
char *line = NULL;
|
||||
char *line = nullptr;
|
||||
size_t line_allocated = 0;
|
||||
ssize_t len;
|
||||
|
||||
|
||||
75
src/od.c
75
src/od.c
@@ -246,12 +246,12 @@ static size_t bytes_per_block;
|
||||
It differs from file_list[-1] only when file_list[-1] is "-". */
|
||||
static char const *input_filename;
|
||||
|
||||
/* A NULL-terminated list of the file-arguments from the command line. */
|
||||
/* A null-terminated list of the file-arguments from the command line. */
|
||||
static char const *const *file_list;
|
||||
|
||||
/* Initializer for file_list if no file-arguments
|
||||
were specified on the command line. */
|
||||
static char const *const default_file_list[] = {"-", NULL};
|
||||
static char const *const default_file_list[] = {"-", nullptr};
|
||||
|
||||
/* The input stream associated with the current file. */
|
||||
static FILE *in_stream;
|
||||
@@ -290,7 +290,7 @@ enum endian_type
|
||||
|
||||
static char const *const endian_args[] =
|
||||
{
|
||||
"little", "big", NULL
|
||||
"little", "big", nullptr
|
||||
};
|
||||
|
||||
static enum endian_type const endian_types[] =
|
||||
@@ -300,19 +300,19 @@ static enum endian_type const endian_types[] =
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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 },
|
||||
{"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 },
|
||||
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -616,7 +616,7 @@ simple_strtoul (char const *s, char const **p, unsigned long int *val)
|
||||
|
||||
/* If S points to a single valid modern od format string, put
|
||||
a description of that format in *TSPEC, make *NEXT point at the
|
||||
character following the just-decoded format (if *NEXT is non-NULL),
|
||||
character following the just-decoded format (if *NEXT is non-null),
|
||||
and return true. If S is not valid, don't modify *NEXT or *TSPEC,
|
||||
give a diagnostic, and return false. For example, if S were
|
||||
"d4afL" *NEXT would be set to "afL" and *TSPEC would be
|
||||
@@ -646,7 +646,7 @@ decode_one_format (char const *s_orig, char const *s, char const **next,
|
||||
char c;
|
||||
int field_width;
|
||||
|
||||
assert (tspec != NULL);
|
||||
assert (tspec != nullptr);
|
||||
|
||||
switch (*s)
|
||||
{
|
||||
@@ -887,7 +887,7 @@ decode_one_format (char const *s_orig, char const *s, char const **next,
|
||||
if (tspec->hexl_mode_trailer)
|
||||
s++;
|
||||
|
||||
if (next != NULL)
|
||||
if (next != nullptr)
|
||||
*next = s;
|
||||
|
||||
return true;
|
||||
@@ -908,7 +908,7 @@ open_next_file (void)
|
||||
do
|
||||
{
|
||||
input_filename = *file_list;
|
||||
if (input_filename == NULL)
|
||||
if (input_filename == nullptr)
|
||||
return ok;
|
||||
++file_list;
|
||||
|
||||
@@ -922,17 +922,17 @@ open_next_file (void)
|
||||
else
|
||||
{
|
||||
in_stream = fopen (input_filename, (O_BINARY ? "rb" : "r"));
|
||||
if (in_stream == NULL)
|
||||
if (in_stream == nullptr)
|
||||
{
|
||||
error (0, errno, "%s", quotef (input_filename));
|
||||
ok = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
while (in_stream == NULL);
|
||||
while (in_stream == nullptr);
|
||||
|
||||
if (limit_bytes_to_format && !flag_dump_strings)
|
||||
setvbuf (in_stream, NULL, _IONBF, 0);
|
||||
setvbuf (in_stream, nullptr, _IONBF, 0);
|
||||
|
||||
return ok;
|
||||
}
|
||||
@@ -949,7 +949,7 @@ check_and_close (int in_errno)
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
if (in_stream != NULL)
|
||||
if (in_stream != nullptr)
|
||||
{
|
||||
if (!ferror (in_stream))
|
||||
in_errno = 0;
|
||||
@@ -963,7 +963,7 @@ check_and_close (int in_errno)
|
||||
ok = false;
|
||||
}
|
||||
|
||||
in_stream = NULL;
|
||||
in_stream = nullptr;
|
||||
}
|
||||
|
||||
if (ferror (stdout))
|
||||
@@ -983,7 +983,7 @@ static bool
|
||||
decode_format_string (char const *s)
|
||||
{
|
||||
char const *s_orig = s;
|
||||
assert (s != NULL);
|
||||
assert (s != nullptr);
|
||||
|
||||
while (*s != '\0')
|
||||
{
|
||||
@@ -1019,7 +1019,7 @@ skip (uintmax_t n_skip)
|
||||
if (n_skip == 0)
|
||||
return true;
|
||||
|
||||
while (in_stream != NULL) /* EOF. */
|
||||
while (in_stream != nullptr) /* EOF. */
|
||||
{
|
||||
struct stat file_stats;
|
||||
|
||||
@@ -1257,7 +1257,7 @@ read_char (int *c)
|
||||
|
||||
*c = EOF;
|
||||
|
||||
while (in_stream != NULL) /* EOF. */
|
||||
while (in_stream != nullptr) /* EOF. */
|
||||
{
|
||||
*c = fgetc (in_stream);
|
||||
|
||||
@@ -1295,7 +1295,7 @@ read_block (size_t n, char *block, size_t *n_bytes_in_buffer)
|
||||
|
||||
*n_bytes_in_buffer = 0;
|
||||
|
||||
while (in_stream != NULL) /* EOF. */
|
||||
while (in_stream != nullptr) /* EOF. */
|
||||
{
|
||||
size_t n_needed;
|
||||
size_t n_read;
|
||||
@@ -1348,7 +1348,7 @@ parse_old_offset (char const *s, uintmax_t *offset)
|
||||
/* Determine the radix we'll use to interpret S. If there is a '.',
|
||||
it's decimal, otherwise, if the string begins with '0X'or '0x',
|
||||
it's hexadecimal, else octal. */
|
||||
if (strchr (s, '.') != NULL)
|
||||
if (strchr (s, '.') != nullptr)
|
||||
radix = 10;
|
||||
else
|
||||
{
|
||||
@@ -1358,7 +1358,7 @@ parse_old_offset (char const *s, uintmax_t *offset)
|
||||
radix = 8;
|
||||
}
|
||||
|
||||
return xstrtoumax (s, NULL, radix, offset, "Bb") == LONGINT_OK;
|
||||
return xstrtoumax (s, nullptr, radix, offset, "Bb") == LONGINT_OK;
|
||||
}
|
||||
|
||||
/* Read a chunk of size BYTES_PER_BLOCK from the input files, write the
|
||||
@@ -1616,7 +1616,7 @@ main (int argc, char **argv)
|
||||
|
||||
n_specs = 0;
|
||||
n_specs_allocated = 0;
|
||||
spec = NULL;
|
||||
spec = nullptr;
|
||||
|
||||
format_address = format_address_std;
|
||||
address_base = 8;
|
||||
@@ -1668,7 +1668,8 @@ main (int argc, char **argv)
|
||||
|
||||
case 'j':
|
||||
modern = true;
|
||||
s_err = xstrtoumax (optarg, NULL, 0, &n_bytes_to_skip, multipliers);
|
||||
s_err = xstrtoumax (optarg, nullptr, 0,
|
||||
&n_bytes_to_skip, multipliers);
|
||||
if (s_err != LONGINT_OK)
|
||||
xstrtol_fatal (s_err, oi, c, long_options, optarg);
|
||||
break;
|
||||
@@ -1677,7 +1678,7 @@ main (int argc, char **argv)
|
||||
modern = true;
|
||||
limit_bytes_to_format = true;
|
||||
|
||||
s_err = xstrtoumax (optarg, NULL, 0, &max_bytes_to_format,
|
||||
s_err = xstrtoumax (optarg, nullptr, 0, &max_bytes_to_format,
|
||||
multipliers);
|
||||
if (s_err != LONGINT_OK)
|
||||
xstrtol_fatal (s_err, oi, c, long_options, optarg);
|
||||
@@ -1685,11 +1686,11 @@ main (int argc, char **argv)
|
||||
|
||||
case 'S':
|
||||
modern = true;
|
||||
if (optarg == NULL)
|
||||
if (optarg == nullptr)
|
||||
string_min = 3;
|
||||
else
|
||||
{
|
||||
s_err = xstrtoumax (optarg, NULL, 0, &tmp, multipliers);
|
||||
s_err = xstrtoumax (optarg, nullptr, 0, &tmp, multipliers);
|
||||
if (s_err != LONGINT_OK)
|
||||
xstrtol_fatal (s_err, oi, c, long_options, optarg);
|
||||
|
||||
@@ -1766,14 +1767,14 @@ main (int argc, char **argv)
|
||||
case 'w':
|
||||
modern = true;
|
||||
width_specified = true;
|
||||
if (optarg == NULL)
|
||||
if (optarg == nullptr)
|
||||
{
|
||||
desired_width = 32;
|
||||
}
|
||||
else
|
||||
{
|
||||
uintmax_t w_tmp;
|
||||
s_err = xstrtoumax (optarg, NULL, 10, &w_tmp, "");
|
||||
s_err = xstrtoumax (optarg, nullptr, 10, &w_tmp, "");
|
||||
if (s_err != LONGINT_OK)
|
||||
xstrtol_fatal (s_err, oi, c, long_options, optarg);
|
||||
if (SIZE_MAX < w_tmp)
|
||||
@@ -1917,12 +1918,12 @@ main (int argc, char **argv)
|
||||
|
||||
/* open the first input file */
|
||||
ok = open_next_file ();
|
||||
if (in_stream == NULL)
|
||||
if (in_stream == nullptr)
|
||||
goto cleanup;
|
||||
|
||||
/* skip over any unwanted header bytes */
|
||||
ok &= skip (n_bytes_to_skip);
|
||||
if (in_stream == NULL)
|
||||
if (in_stream == nullptr)
|
||||
goto cleanup;
|
||||
|
||||
pseudo_offset = (flag_pseudo_start ? pseudo_start - n_bytes_to_skip : 0);
|
||||
|
||||
18
src/paste.c
18
src/paste.c
@@ -72,12 +72,12 @@ static unsigned char line_delim = '\n';
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"serial", no_argument, NULL, 's'},
|
||||
{"delimiters", required_argument, NULL, 'd'},
|
||||
{"zero-terminated", no_argument, NULL, 'z'},
|
||||
{"serial", no_argument, nullptr, 's'},
|
||||
{"delimiters", required_argument, nullptr, 'd'},
|
||||
{"zero-terminated", no_argument, nullptr, 'z'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Set globals delims and delim_end. Copy STRPTR to DELIMS, converting
|
||||
@@ -185,7 +185,7 @@ paste_parallel (size_t nfiles, char **fnamptr)
|
||||
store the delimiters for closed files. */
|
||||
char *delbuf = xmalloc (nfiles + 2);
|
||||
|
||||
/* Streams open to the files to process; NULL if the corresponding
|
||||
/* Streams open to the files to process; null if the corresponding
|
||||
stream is closed. */
|
||||
FILE **fileptr = xnmalloc (nfiles + 1, sizeof *fileptr);
|
||||
|
||||
@@ -209,7 +209,7 @@ paste_parallel (size_t nfiles, char **fnamptr)
|
||||
else
|
||||
{
|
||||
fileptr[files_open] = fopen (fnamptr[files_open], "r");
|
||||
if (fileptr[files_open] == NULL)
|
||||
if (fileptr[files_open] == nullptr)
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (fnamptr[files_open]));
|
||||
else if (fileno (fileptr[files_open]) == STDIN_FILENO)
|
||||
opened_stdin = true;
|
||||
@@ -277,7 +277,7 @@ paste_parallel (size_t nfiles, char **fnamptr)
|
||||
ok = false;
|
||||
}
|
||||
|
||||
fileptr[i] = NULL;
|
||||
fileptr[i] = nullptr;
|
||||
files_open--;
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ paste_serial (size_t nfiles, char **fnamptr)
|
||||
else
|
||||
{
|
||||
fileptr = fopen (*fnamptr, "r");
|
||||
if (fileptr == NULL)
|
||||
if (fileptr == nullptr)
|
||||
{
|
||||
error (0, errno, "%s", quotef (*fnamptr));
|
||||
ok = false;
|
||||
@@ -474,7 +474,7 @@ main (int argc, char **argv)
|
||||
have_read_stdin = false;
|
||||
serial_merge = false;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "d:sz", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "d:sz", longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
|
||||
@@ -72,10 +72,10 @@ enum
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"portability", no_argument, NULL, PORTABILITY_OPTION},
|
||||
{"portability", no_argument, nullptr, PORTABILITY_OPTION},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -116,7 +116,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "+pP", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "+pP", longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
|
||||
15
src/pinky.c
15
src/pinky.c
@@ -76,7 +76,7 @@ static struct option const longopts[] =
|
||||
{
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Count and return the number of ampersands in STR. */
|
||||
@@ -237,7 +237,7 @@ print_entry (const STRUCT_UTMP *utmp_ent)
|
||||
|
||||
stzncpy (name, UT_USER (utmp_ent), UT_USER_SIZE);
|
||||
pw = getpwnam (name);
|
||||
if (pw == NULL)
|
||||
if (pw == nullptr)
|
||||
/* TRANSLATORS: Real name is unknown; at most 19 characters. */
|
||||
printf (" %19s", _(" ???"));
|
||||
else
|
||||
@@ -272,8 +272,8 @@ print_entry (const STRUCT_UTMP *utmp_ent)
|
||||
if (include_where && utmp_ent->ut_host[0])
|
||||
{
|
||||
char ut_host[sizeof (utmp_ent->ut_host) + 1];
|
||||
char *host = NULL;
|
||||
char *display = NULL;
|
||||
char *host = nullptr;
|
||||
char *display = nullptr;
|
||||
|
||||
/* Copy the host name into UT_HOST, and ensure it's nul terminated. */
|
||||
stzncpy (ut_host, utmp_ent->ut_host, sizeof (utmp_ent->ut_host));
|
||||
@@ -315,7 +315,7 @@ print_long_entry (const char name[])
|
||||
printf ("%-28s", name);
|
||||
|
||||
printf (_("In real life: "));
|
||||
if (pw == NULL)
|
||||
if (pw == nullptr)
|
||||
{
|
||||
/* TRANSLATORS: Real name is unknown; no hard limit. */
|
||||
printf (" %s", _("???\n"));
|
||||
@@ -463,7 +463,7 @@ short_pinky (char const *filename,
|
||||
const int argc_names, char *const argv_names[])
|
||||
{
|
||||
size_t n_users;
|
||||
STRUCT_UTMP *utmp_buf = NULL;
|
||||
STRUCT_UTMP *utmp_buf = nullptr;
|
||||
|
||||
if (read_utmp (filename, &n_users, &utmp_buf, 0) != 0)
|
||||
die (EXIT_FAILURE, errno, "%s", quotef (filename));
|
||||
@@ -528,7 +528,8 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "sfwiqbhlp", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "sfwiqbhlp", longopts, nullptr))
|
||||
!= -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
|
||||
66
src/pr.c
66
src/pr.c
@@ -743,33 +743,33 @@ static char const short_options[] =
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
static _Noreturn void
|
||||
@@ -865,7 +865,7 @@ main (int argc, char **argv)
|
||||
char **file_names;
|
||||
|
||||
/* Accumulate the digits of old-style options like -99. */
|
||||
char *column_count_string = NULL;
|
||||
char *column_count_string = nullptr;
|
||||
size_t n_digits = 0;
|
||||
size_t n_alloc = 0;
|
||||
|
||||
@@ -880,7 +880,7 @@ main (int argc, char **argv)
|
||||
n_files = 0;
|
||||
file_names = (argc > 1
|
||||
? xnmalloc (argc - 1, sizeof (char *))
|
||||
: NULL);
|
||||
: nullptr);
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -930,7 +930,7 @@ main (int argc, char **argv)
|
||||
short-named option syntax, e.g., -9, ensure that this
|
||||
long-name-specified value overrides it. */
|
||||
free (column_count_string);
|
||||
column_count_string = NULL;
|
||||
column_count_string = nullptr;
|
||||
n_alloc = 0;
|
||||
break;
|
||||
}
|
||||
@@ -1130,7 +1130,7 @@ main (int argc, char **argv)
|
||||
if (n_files == 0)
|
||||
{
|
||||
/* No file arguments specified; read from standard input. */
|
||||
print_files (0, NULL);
|
||||
print_files (0, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1179,7 +1179,7 @@ getoptarg (char *arg, char switch_char, char *character, int *number)
|
||||
if (*arg)
|
||||
{
|
||||
long int tmp_long;
|
||||
strtol_error e = xstrtol (arg, NULL, 10, &tmp_long, "");
|
||||
strtol_error e = xstrtol (arg, nullptr, 10, &tmp_long, "");
|
||||
if (e == LONGINT_OK)
|
||||
{
|
||||
if (tmp_long <= 0)
|
||||
@@ -1492,7 +1492,7 @@ open_file (char *name, COLUMN *p)
|
||||
p->name = name;
|
||||
p->fp = fopen (name, "r");
|
||||
}
|
||||
if (p->fp == NULL)
|
||||
if (p->fp == nullptr)
|
||||
{
|
||||
failed_opens = true;
|
||||
if (!ignore_failed_opens)
|
||||
@@ -1645,7 +1645,7 @@ print_files (int number_of_files, char **av)
|
||||
static void
|
||||
init_header (char const *filename, int desc)
|
||||
{
|
||||
char *buf = NULL;
|
||||
char *buf = nullptr;
|
||||
struct stat st;
|
||||
struct timespec t;
|
||||
int ns;
|
||||
@@ -1668,7 +1668,7 @@ init_header (char const *filename, int desc)
|
||||
if (localtime_rz (localtz, &t.tv_sec, &tm))
|
||||
{
|
||||
size_t bufsize
|
||||
= nstrftime (NULL, SIZE_MAX, date_format, &tm, localtz, ns) + 1;
|
||||
= nstrftime (nullptr, SIZE_MAX, date_format, &tm, localtz, ns) + 1;
|
||||
buf = xmalloc (bufsize);
|
||||
nstrftime (buf, bufsize, date_format, &tm, localtz, ns);
|
||||
}
|
||||
|
||||
@@ -46,10 +46,10 @@ enum { PRINTENV_FAILURE = 2 };
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"null", no_argument, NULL, '0'},
|
||||
{"null", no_argument, nullptr, '0'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -96,7 +96,7 @@ main (int argc, char **argv)
|
||||
initialize_exit_failure (PRINTENV_FAILURE);
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "+iu:0", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "+iu:0", longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
@@ -112,7 +112,7 @@ main (int argc, char **argv)
|
||||
|
||||
if (optind >= argc)
|
||||
{
|
||||
for (env = environ; *env != NULL; ++env)
|
||||
for (env = environ; *env != nullptr; ++env)
|
||||
printf ("%s%c", *env, opt_nul_terminate_output ? '\0' : '\n');
|
||||
ok = true;
|
||||
}
|
||||
|
||||
@@ -674,7 +674,7 @@ main (int argc, char **argv)
|
||||
|
||||
exit_status = EXIT_SUCCESS;
|
||||
|
||||
posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
|
||||
posixly_correct = (getenv ("POSIXLY_CORRECT") != nullptr);
|
||||
|
||||
/* We directly parse options, rather than use parse_long_options, in
|
||||
order to avoid accepting abbreviations. */
|
||||
@@ -686,7 +686,7 @@ main (int argc, char **argv)
|
||||
if (STREQ (argv[1], "--version"))
|
||||
{
|
||||
version_etc (stdout, PROGRAM_NAME, PACKAGE_NAME, Version, AUTHORS,
|
||||
(char *) NULL);
|
||||
(char *) nullptr);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
|
||||
101
src/ptx.c
101
src/ptx.c
@@ -85,9 +85,9 @@ static enum Format output_format = UNKNOWN_FORMAT;
|
||||
/* output format */
|
||||
|
||||
static bool ignore_case = false; /* fold lower to upper for sorting */
|
||||
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 */
|
||||
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 */
|
||||
|
||||
/* Options that use regular expressions. */
|
||||
struct regex_data
|
||||
@@ -185,7 +185,8 @@ static BLOCK *text_buffers; /* files to study */
|
||||
if (word_regex.string) \
|
||||
{ \
|
||||
regoff_t count; \
|
||||
count = re_match (&word_regex.pattern, cursor, limit - cursor, 0, NULL); \
|
||||
count = re_match (&word_regex.pattern, cursor, limit - cursor, \
|
||||
0, nullptr); \
|
||||
if (count == -2) \
|
||||
matcher_error (); \
|
||||
cursor += count == -1 ? 1 : count; \
|
||||
@@ -406,10 +407,10 @@ compile_regex (struct regex_data *regex)
|
||||
char const *string = regex->string;
|
||||
char const *message;
|
||||
|
||||
pattern->buffer = NULL;
|
||||
pattern->buffer = nullptr;
|
||||
pattern->allocated = 0;
|
||||
pattern->fastmap = regex->fastmap;
|
||||
pattern->translate = ignore_case ? folded_chars : NULL;
|
||||
pattern->translate = ignore_case ? folded_chars : nullptr;
|
||||
|
||||
message = re_compile_pattern (string, strlen (string), pattern);
|
||||
if (message)
|
||||
@@ -441,14 +442,14 @@ initialize_regex (void)
|
||||
/* Unless the user already provided a description of the end of line or
|
||||
end of sentence sequence, select an end of line sequence to compile.
|
||||
If the user provided an empty definition, thus disabling end of line
|
||||
or sentence feature, make it NULL to speed up tests. If GNU
|
||||
or sentence feature, make it null to speed up tests. If GNU
|
||||
extensions are enabled, use end of sentence like in GNU emacs. If
|
||||
disabled, use end of lines. */
|
||||
|
||||
if (context_regex.string)
|
||||
{
|
||||
if (!*context_regex.string)
|
||||
context_regex.string = NULL;
|
||||
context_regex.string = nullptr;
|
||||
}
|
||||
else if (gnu_extensions && !input_reference)
|
||||
context_regex.string = "[.?!][]\"')}]*\\($\\|\t\\| \\)[ \t\n]*";
|
||||
@@ -494,7 +495,7 @@ initialize_regex (void)
|
||||
/*------------------------------------------------------------------------.
|
||||
| This routine will attempt to swallow a whole file name FILE_NAME into a |
|
||||
| contiguous region of memory and return a description of it into BLOCK. |
|
||||
| Standard input is assumed whenever FILE_NAME is NULL, empty or "-". |
|
||||
| Standard input is assumed whenever FILE_NAME is null, empty or "-". |
|
||||
| |
|
||||
| Previously, in some cases, white space compression was attempted while |
|
||||
| inputting text. This was defeating some regexps like default end of |
|
||||
@@ -507,7 +508,7 @@ swallow_file_in_memory (char const *file_name, BLOCK *block)
|
||||
{
|
||||
size_t used_length; /* used length in memory buffer */
|
||||
|
||||
/* As special cases, a file name which is NULL or "-" indicates standard
|
||||
/* As special cases, a file name which is null or "-" indicates standard
|
||||
input, which is already opened. In all other cases, open the file from
|
||||
its name. */
|
||||
bool using_stdin = !file_name || !*file_name || STREQ (file_name, "-");
|
||||
@@ -693,7 +694,7 @@ digest_word_file (char const *file_name, WORD_TABLE *table)
|
||||
|
||||
swallow_file_in_memory (file_name, &file_contents);
|
||||
|
||||
table->start = NULL;
|
||||
table->start = nullptr;
|
||||
table->alloc = 0;
|
||||
table->length = 0;
|
||||
|
||||
@@ -1145,14 +1146,14 @@ fix_output_parameters (void)
|
||||
before_max_width = half_line_width - gap_size;
|
||||
keyafter_max_width = half_line_width;
|
||||
|
||||
/* If truncation_string is the empty string, make it NULL to speed up
|
||||
/* If truncation_string is the empty string, make it null to speed up
|
||||
tests. In this case, truncation_string_length will never get used, so
|
||||
there is no need to set it. */
|
||||
|
||||
if (truncation_string && *truncation_string)
|
||||
truncation_string_length = strlen (truncation_string);
|
||||
else
|
||||
truncation_string = NULL;
|
||||
truncation_string = nullptr;
|
||||
|
||||
if (gnu_extensions)
|
||||
{
|
||||
@@ -1367,8 +1368,8 @@ define_all_fields (OCCURS *occurs)
|
||||
|
||||
/* No place left for a tail field. */
|
||||
|
||||
tail.start = NULL;
|
||||
tail.end = NULL;
|
||||
tail.start = nullptr;
|
||||
tail.end = nullptr;
|
||||
tail_truncation = false;
|
||||
}
|
||||
|
||||
@@ -1406,8 +1407,8 @@ define_all_fields (OCCURS *occurs)
|
||||
|
||||
/* No place left for a head field. */
|
||||
|
||||
head.start = NULL;
|
||||
head.end = NULL;
|
||||
head.start = nullptr;
|
||||
head.end = nullptr;
|
||||
head_truncation = false;
|
||||
}
|
||||
|
||||
@@ -1646,12 +1647,12 @@ generate_all_output (void)
|
||||
line contexts or references are not used, in which case these variables
|
||||
would never be computed. */
|
||||
|
||||
tail.start = NULL;
|
||||
tail.end = NULL;
|
||||
tail.start = nullptr;
|
||||
tail.end = nullptr;
|
||||
tail_truncation = false;
|
||||
|
||||
head.start = NULL;
|
||||
head.end = NULL;
|
||||
head.start = nullptr;
|
||||
head.end = nullptr;
|
||||
head_truncation = false;
|
||||
|
||||
/* Loop over all keyword occurrences. */
|
||||
@@ -1758,30 +1759,30 @@ Output a permuted index, including context, of the words in the input files.\n\
|
||||
/* Long options equivalences. */
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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, 10},
|
||||
{"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'},
|
||||
{"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, 10},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0},
|
||||
{nullptr, 0, nullptr, 0},
|
||||
};
|
||||
|
||||
static char const *const format_args[] =
|
||||
{
|
||||
"roff", "tex", NULL
|
||||
"roff", "tex", nullptr
|
||||
};
|
||||
|
||||
static enum Format const format_vals[] =
|
||||
@@ -1806,11 +1807,11 @@ main (int argc, char **argv)
|
||||
atexit (close_stdout);
|
||||
|
||||
#if HAVE_SETCHRCLASS
|
||||
setchrclass (NULL);
|
||||
setchrclass (nullptr);
|
||||
#endif
|
||||
|
||||
while (optchar = getopt_long (argc, argv, "AF:GM:ORS:TW:b:i:fg:o:trw:",
|
||||
long_options, NULL),
|
||||
long_options, nullptr),
|
||||
optchar != EOF)
|
||||
{
|
||||
switch (optchar)
|
||||
@@ -1833,7 +1834,7 @@ main (int argc, char **argv)
|
||||
case 'g':
|
||||
{
|
||||
intmax_t tmp;
|
||||
if (! (xstrtoimax (optarg, NULL, 0, &tmp, "") == LONGINT_OK
|
||||
if (! (xstrtoimax (optarg, nullptr, 0, &tmp, "") == LONGINT_OK
|
||||
&& 0 < tmp && tmp <= PTRDIFF_MAX))
|
||||
die (EXIT_FAILURE, 0, _("invalid gap width: %s"),
|
||||
quote (optarg));
|
||||
@@ -1860,7 +1861,7 @@ main (int argc, char **argv)
|
||||
case 'w':
|
||||
{
|
||||
intmax_t tmp;
|
||||
if (! (xstrtoimax (optarg, NULL, 0, &tmp, "") == LONGINT_OK
|
||||
if (! (xstrtoimax (optarg, nullptr, 0, &tmp, "") == LONGINT_OK
|
||||
&& 0 < tmp && tmp <= PTRDIFF_MAX))
|
||||
die (EXIT_FAILURE, 0, _("invalid line width: %s"),
|
||||
quote (optarg));
|
||||
@@ -1902,7 +1903,7 @@ main (int argc, char **argv)
|
||||
word_regex.string = optarg;
|
||||
unescape_string (optarg);
|
||||
if (!*word_regex.string)
|
||||
word_regex.string = NULL;
|
||||
word_regex.string = nullptr;
|
||||
break;
|
||||
|
||||
case 10:
|
||||
@@ -1929,7 +1930,7 @@ main (int argc, char **argv)
|
||||
file_line_count = xmalloc (sizeof *file_line_count);
|
||||
text_buffers = xmalloc (sizeof *text_buffers);
|
||||
number_input_files = 1;
|
||||
input_file_name[0] = NULL;
|
||||
input_file_name[0] = nullptr;
|
||||
}
|
||||
else if (gnu_extensions)
|
||||
{
|
||||
@@ -1941,7 +1942,7 @@ main (int argc, char **argv)
|
||||
for (file_index = 0; file_index < number_input_files; file_index++)
|
||||
{
|
||||
if (!*argv[optind] || STREQ (argv[optind], "-"))
|
||||
input_file_name[file_index] = NULL;
|
||||
input_file_name[file_index] = nullptr;
|
||||
else
|
||||
input_file_name[file_index] = argv[optind];
|
||||
optind++;
|
||||
@@ -1957,7 +1958,7 @@ main (int argc, char **argv)
|
||||
file_line_count = xmalloc (sizeof *file_line_count);
|
||||
text_buffers = xmalloc (sizeof *text_buffers);
|
||||
if (!*argv[optind] || STREQ (argv[optind], "-"))
|
||||
input_file_name[0] = NULL;
|
||||
input_file_name[0] = nullptr;
|
||||
else
|
||||
input_file_name[0] = argv[optind];
|
||||
optind++;
|
||||
@@ -1996,21 +1997,21 @@ main (int argc, char **argv)
|
||||
digest_break_file (break_file);
|
||||
|
||||
/* Read 'Ignore words' file and 'Only words' files, if any. If any of
|
||||
these files is empty, reset the name of the file to NULL, to avoid
|
||||
these files is empty, reset the name of the file to null, to avoid
|
||||
unnecessary calls to search_table. */
|
||||
|
||||
if (ignore_file)
|
||||
{
|
||||
digest_word_file (ignore_file, &ignore_table);
|
||||
if (ignore_table.length == 0)
|
||||
ignore_file = NULL;
|
||||
ignore_file = nullptr;
|
||||
}
|
||||
|
||||
if (only_file)
|
||||
{
|
||||
digest_word_file (only_file, &only_table);
|
||||
if (only_table.length == 0)
|
||||
only_file = NULL;
|
||||
only_file = nullptr;
|
||||
}
|
||||
|
||||
/* Prepare to study all the input files. */
|
||||
|
||||
30
src/pwd.c
30
src/pwd.c
@@ -40,11 +40,11 @@ struct file_name
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"logical", no_argument, NULL, 'L'},
|
||||
{"physical", no_argument, NULL, 'P'},
|
||||
{"logical", no_argument, nullptr, 'L'},
|
||||
{"physical", no_argument, nullptr, 'P'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -160,7 +160,7 @@ find_dir_entry (struct stat *dot_sb, struct file_name *file_name,
|
||||
bool found;
|
||||
|
||||
dirp = opendir ("..");
|
||||
if (dirp == NULL)
|
||||
if (dirp == nullptr)
|
||||
die (EXIT_FAILURE, errno, _("cannot open directory %s"),
|
||||
quote (nth_parent (parent_height)));
|
||||
|
||||
@@ -185,7 +185,7 @@ find_dir_entry (struct stat *dot_sb, struct file_name *file_name,
|
||||
ino_t ino;
|
||||
|
||||
errno = 0;
|
||||
if ((dp = readdir_ignoring_dot_and_dotdot (dirp)) == NULL)
|
||||
if ((dp = readdir_ignoring_dot_and_dotdot (dirp)) == nullptr)
|
||||
{
|
||||
if (errno)
|
||||
{
|
||||
@@ -195,7 +195,7 @@ find_dir_entry (struct stat *dot_sb, struct file_name *file_name,
|
||||
errno = e;
|
||||
|
||||
/* Arrange to give a diagnostic after exiting this loop. */
|
||||
dirp = NULL;
|
||||
dirp = nullptr;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -225,7 +225,7 @@ find_dir_entry (struct stat *dot_sb, struct file_name *file_name,
|
||||
}
|
||||
}
|
||||
|
||||
if (dirp == NULL || closedir (dirp) != 0)
|
||||
if (dirp == nullptr || closedir (dirp) != 0)
|
||||
{
|
||||
/* Note that this diagnostic serves for both readdir
|
||||
and closedir failures. */
|
||||
@@ -272,7 +272,7 @@ robust_getcwd (struct file_name *file_name)
|
||||
struct dev_ino *root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
struct stat dot_sb;
|
||||
|
||||
if (root_dev_ino == NULL)
|
||||
if (root_dev_ino == nullptr)
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
|
||||
@@ -295,7 +295,7 @@ robust_getcwd (struct file_name *file_name)
|
||||
|
||||
|
||||
/* Return PWD from the environment if it is acceptable for 'pwd -L'
|
||||
output, otherwise NULL. */
|
||||
output, otherwise nullptr. */
|
||||
static char *
|
||||
logical_getcwd (void)
|
||||
{
|
||||
@@ -306,20 +306,20 @@ logical_getcwd (void)
|
||||
|
||||
/* Textual validation first. */
|
||||
if (!wd || wd[0] != '/')
|
||||
return NULL;
|
||||
return nullptr;
|
||||
p = wd;
|
||||
while ((p = strstr (p, "/.")))
|
||||
{
|
||||
if (!p[2] || p[2] == '/'
|
||||
|| (p[2] == '.' && (!p[3] || p[3] == '/')))
|
||||
return NULL;
|
||||
return nullptr;
|
||||
p++;
|
||||
}
|
||||
|
||||
/* System call validation. */
|
||||
if (stat (wd, &st1) == 0 && stat (".", &st2) == 0 && SAME_INODE (st1, st2))
|
||||
return wd;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ main (int argc, char **argv)
|
||||
/* 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") != NULL);
|
||||
bool logical = (getenv ("POSIXLY_CORRECT") != nullptr);
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -342,7 +342,7 @@ main (int argc, char **argv)
|
||||
|
||||
while (true)
|
||||
{
|
||||
int c = getopt_long (argc, argv, "LP", longopts, NULL);
|
||||
int c = getopt_long (argc, argv, "LP", longopts, nullptr);
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c)
|
||||
@@ -377,7 +377,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
wd = xgetcwd ();
|
||||
if (wd != NULL)
|
||||
if (wd != nullptr)
|
||||
{
|
||||
puts (wd);
|
||||
free (wd);
|
||||
|
||||
@@ -39,17 +39,17 @@ static bool verbose;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -107,7 +107,7 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "efmnqsvz", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "efmnqsvz", longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
|
||||
@@ -46,19 +46,19 @@ static char const *can_relative_base;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -160,7 +160,7 @@ process_path (char const *fname, int can_mode)
|
||||
|
||||
if (!can_relative_to
|
||||
|| (can_relative_base && !path_prefix (can_relative_base, can_fname))
|
||||
|| (can_relative_to && !relpath (can_fname, can_relative_to, NULL, 0)))
|
||||
|| (can_relative_to && !relpath (can_fname, can_relative_to, nullptr, 0)))
|
||||
fputs (can_fname, stdout);
|
||||
|
||||
putchar (use_nuls ? '\0' : '\n');
|
||||
@@ -175,8 +175,8 @@ main (int argc, char **argv)
|
||||
{
|
||||
bool ok = true;
|
||||
int can_mode = CAN_ALL_BUT_LAST;
|
||||
char const *relative_to = NULL;
|
||||
char const *relative_base = NULL;
|
||||
char const *relative_to = nullptr;
|
||||
char const *relative_base = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -188,7 +188,7 @@ main (int argc, char **argv)
|
||||
|
||||
while (true)
|
||||
{
|
||||
int c = getopt_long (argc, argv, "eLmPqsz", longopts, NULL);
|
||||
int c = getopt_long (argc, argv, "eLmPqsz", longopts, nullptr);
|
||||
if (c == -1)
|
||||
break;
|
||||
switch (c)
|
||||
@@ -267,7 +267,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
free (base);
|
||||
can_relative_base = can_relative_to;
|
||||
can_relative_to = NULL;
|
||||
can_relative_to = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ path_common_prefix (char const *path1, char const *path2)
|
||||
}
|
||||
|
||||
/* Either output STR to stdout or
|
||||
if *PBUF is not NULL then append STR to *PBUF
|
||||
if *PBUF is not null then append STR to *PBUF
|
||||
and update *PBUF to point to the end of the buffer
|
||||
and adjust *PLEN to reflect the remaining space.
|
||||
Return TRUE on failure. */
|
||||
@@ -84,7 +84,7 @@ buffer_or_output (char const *str, char **pbuf, size_t *plen)
|
||||
}
|
||||
|
||||
/* Output the relative representation if possible.
|
||||
If BUF is non-NULL, write to that buffer rather than to stdout. */
|
||||
If BUF is non-null, write to that buffer rather than to stdout. */
|
||||
bool
|
||||
relpath (char const *can_fname, char const *can_reldir, char *buf, size_t len)
|
||||
{
|
||||
|
||||
@@ -494,7 +494,7 @@ rm_fts (FTS *fts, FTSENT *ent, struct rm_options const *x)
|
||||
if (x->preserve_all_root)
|
||||
{
|
||||
bool failed = false;
|
||||
char *parent = file_name_concat (ent->fts_accpath, "..", NULL);
|
||||
char *parent = file_name_concat (ent->fts_accpath, "..", nullptr);
|
||||
struct stat statbuf;
|
||||
|
||||
if (!parent || lstat (parent, &statbuf))
|
||||
@@ -615,14 +615,14 @@ rm (char *const *file, struct rm_options const *x)
|
||||
if (x->one_file_system)
|
||||
bit_flags |= FTS_XDEV;
|
||||
|
||||
FTS *fts = xfts_open (file, bit_flags, NULL);
|
||||
FTS *fts = xfts_open (file, bit_flags, nullptr);
|
||||
|
||||
while (true)
|
||||
{
|
||||
FTSENT *ent;
|
||||
|
||||
ent = fts_read (fts);
|
||||
if (ent == NULL)
|
||||
if (ent == nullptr)
|
||||
{
|
||||
if (errno != 0)
|
||||
{
|
||||
|
||||
@@ -53,7 +53,7 @@ struct rm_options
|
||||
bool remove_empty_directories;
|
||||
|
||||
/* Pointer to the device and inode numbers of '/', when --recursive
|
||||
and preserving '/'. Otherwise NULL. */
|
||||
and preserving '/'. Otherwise null. */
|
||||
struct dev_ino *root_dev_ino;
|
||||
|
||||
/* If true, do not traverse into (or remove) any directory that is
|
||||
|
||||
28
src/rm.c
28
src/rm.c
@@ -62,32 +62,32 @@ enum interactive_type
|
||||
|
||||
static struct option const long_opts[] =
|
||||
{
|
||||
{"force", no_argument, NULL, 'f'},
|
||||
{"interactive", optional_argument, NULL, INTERACTIVE_OPTION},
|
||||
{"force", no_argument, nullptr, 'f'},
|
||||
{"interactive", optional_argument, nullptr, INTERACTIVE_OPTION},
|
||||
|
||||
{"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},
|
||||
{"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},
|
||||
|
||||
/* 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, NULL, PRESUME_INPUT_TTY_OPTION},
|
||||
{"-presume-input-tty", no_argument, nullptr, PRESUME_INPUT_TTY_OPTION},
|
||||
|
||||
{"recursive", no_argument, NULL, 'r'},
|
||||
{"dir", no_argument, NULL, 'd'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"recursive", no_argument, nullptr, 'r'},
|
||||
{"dir", no_argument, nullptr, 'd'},
|
||||
{"verbose", no_argument, nullptr, 'v'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
static char const *const interactive_args[] =
|
||||
{
|
||||
"never", "no", "none",
|
||||
"once",
|
||||
"always", "yes", NULL
|
||||
"always", "yes", nullptr
|
||||
};
|
||||
static enum interactive_type const interactive_types[] =
|
||||
{
|
||||
@@ -195,7 +195,7 @@ rm_option_init (struct rm_options *x)
|
||||
x->one_file_system = false;
|
||||
x->remove_empty_directories = false;
|
||||
x->recursive = false;
|
||||
x->root_dev_ino = NULL;
|
||||
x->root_dev_ino = nullptr;
|
||||
x->preserve_all_root = false;
|
||||
x->stdin_tty = isatty (STDIN_FILENO);
|
||||
x->verbose = false;
|
||||
@@ -226,7 +226,7 @@ main (int argc, char **argv)
|
||||
/* Try to disable the ability to unlink a directory. */
|
||||
priv_set_remove_linkdir ();
|
||||
|
||||
while ((c = getopt_long (argc, argv, "dfirvIR", long_opts, NULL)) != -1)
|
||||
while ((c = getopt_long (argc, argv, "dfirvIR", long_opts, nullptr)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
@@ -344,7 +344,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
x.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
if (x.root_dev_ino == NULL)
|
||||
if (x.root_dev_ino == nullptr)
|
||||
die (EXIT_FAILURE, errno, _("failed to get attributes of %s"),
|
||||
quoteaf ("/"));
|
||||
}
|
||||
|
||||
14
src/rmdir.c
14
src/rmdir.c
@@ -57,15 +57,15 @@ static struct option const longopts[] =
|
||||
{
|
||||
/* 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, NULL,
|
||||
{"ignore-fail-on-non-empty", no_argument, nullptr,
|
||||
IGNORE_FAIL_ON_NON_EMPTY_OPTION},
|
||||
|
||||
{"path", no_argument, NULL, 'p'}, /* Deprecated. */
|
||||
{"parents", no_argument, NULL, 'p'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{"path", no_argument, nullptr, 'p'}, /* Deprecated. */
|
||||
{"parents", no_argument, nullptr, 'p'},
|
||||
{"verbose", no_argument, nullptr, 'v'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
/* Return true if ERROR_NUMBER is one of the values associated
|
||||
@@ -119,7 +119,7 @@ remove_parents (char *dir)
|
||||
while (true)
|
||||
{
|
||||
slash = strrchr (dir, '/');
|
||||
if (slash == NULL)
|
||||
if (slash == nullptr)
|
||||
break;
|
||||
/* Remove any characters after the slash, skipping any extra
|
||||
slashes in a row. */
|
||||
@@ -210,7 +210,7 @@ main (int argc, char **argv)
|
||||
|
||||
remove_empty_parents = false;
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "pv", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "pv", longopts, nullptr)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
|
||||
30
src/runcon.c
30
src/runcon.c
@@ -58,14 +58,14 @@
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -105,14 +105,14 @@ With neither CONTEXT nor COMMAND, print the current security context.\n\
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
bool compute_trans = false;
|
||||
|
||||
context_t con;
|
||||
@@ -254,7 +254,7 @@ main (int argc, char **argv)
|
||||
if (setexeccon (context_str (con)) != 0)
|
||||
die (EXIT_CANCELED, errno, _("unable to set security context %s"),
|
||||
quote (context_str (con)));
|
||||
if (cur_context != NULL)
|
||||
if (cur_context != nullptr)
|
||||
freecon (cur_context);
|
||||
|
||||
(compute_trans ? execv : execvp) (argv[optind], argv + optind);
|
||||
|
||||
@@ -71,8 +71,8 @@ mode_to_security_class (mode_t m)
|
||||
static int
|
||||
computecon (char const *path, mode_t mode, char **con)
|
||||
{
|
||||
char *scon = NULL;
|
||||
char *tcon = NULL;
|
||||
char *scon = nullptr;
|
||||
char *tcon = nullptr;
|
||||
security_class_t tclass;
|
||||
int rc = -1;
|
||||
|
||||
@@ -111,12 +111,12 @@ defaultcon (struct selabel_handle *selabel_handle,
|
||||
char const *path, mode_t mode)
|
||||
{
|
||||
int rc = -1;
|
||||
char *scon = NULL;
|
||||
char *tcon = NULL;
|
||||
char *scon = nullptr;
|
||||
char *tcon = nullptr;
|
||||
context_t scontext = 0, tcontext = 0;
|
||||
char const *contype;
|
||||
char const *constr;
|
||||
char *newpath = NULL;
|
||||
char *newpath = nullptr;
|
||||
|
||||
if (! IS_ABSOLUTE_FILE_NAME (path))
|
||||
{
|
||||
@@ -179,8 +179,8 @@ restorecon_private (struct selabel_handle *selabel_handle, char const *path)
|
||||
{
|
||||
int rc = -1;
|
||||
struct stat sb;
|
||||
char *scon = NULL;
|
||||
char *tcon = NULL;
|
||||
char *scon = nullptr;
|
||||
char *tcon = nullptr;
|
||||
context_t scontext = 0, tcontext = 0;
|
||||
char const *contype;
|
||||
char const *constr;
|
||||
@@ -285,7 +285,7 @@ bool
|
||||
restorecon (struct selabel_handle *selabel_handle,
|
||||
char const *path, bool recurse)
|
||||
{
|
||||
char *newpath = NULL;
|
||||
char *newpath = nullptr;
|
||||
|
||||
if (! IS_ABSOLUTE_FILE_NAME (path))
|
||||
{
|
||||
@@ -307,8 +307,8 @@ restorecon (struct selabel_handle *selabel_handle,
|
||||
return ok;
|
||||
}
|
||||
|
||||
char const *ftspath[2] = { path, NULL };
|
||||
FTS *fts = xfts_open ((char *const *) ftspath, FTS_PHYSICAL, NULL);
|
||||
char const *ftspath[2] = { path, nullptr };
|
||||
FTS *fts = xfts_open ((char *const *) ftspath, FTS_PHYSICAL, nullptr);
|
||||
|
||||
int err = 0;
|
||||
for (FTSENT *ent; (ent = fts_read (fts)); )
|
||||
|
||||
29
src/seq.c
29
src/seq.c
@@ -62,12 +62,12 @@ static char const terminator[] = "\n";
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{ "equal-width", no_argument, NULL, 'w'},
|
||||
{ "format", required_argument, NULL, 'f'},
|
||||
{ "separator", required_argument, NULL, 's'},
|
||||
{ "equal-width", no_argument, nullptr, 'w'},
|
||||
{ "format", required_argument, nullptr, 'f'},
|
||||
{ "separator", required_argument, nullptr, 's'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{ NULL, 0, NULL, 0}
|
||||
{ nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -150,7 +150,7 @@ scan_arg (char const *arg)
|
||||
{
|
||||
operand ret;
|
||||
|
||||
if (! xstrtold (arg, NULL, &ret.value, cl_strtold))
|
||||
if (! xstrtold (arg, nullptr, &ret.value, cl_strtold))
|
||||
{
|
||||
error (0, 0, _("invalid floating point argument: %s"), quote (arg));
|
||||
usage (EXIT_FAILURE);
|
||||
@@ -197,7 +197,7 @@ scan_arg (char const *arg)
|
||||
e = strchr (arg, 'E');
|
||||
if (e)
|
||||
{
|
||||
long exponent = MAX (strtol (e + 1, NULL, 10), -LONG_MAX);
|
||||
long exponent = MAX (strtol (e + 1, nullptr, 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. */
|
||||
@@ -341,10 +341,11 @@ print_numbers (char const *fmt, struct layout layout,
|
||||
xalloc_die ();
|
||||
x_str[x_strlen - layout.suffix_len] = '\0';
|
||||
|
||||
if (xstrtold (x_str + layout.prefix_len, NULL, &x_val, cl_strtold)
|
||||
if (xstrtold (x_str + layout.prefix_len, nullptr,
|
||||
&x_val, cl_strtold)
|
||||
&& x_val == last)
|
||||
{
|
||||
char *x0_str = NULL;
|
||||
char *x0_str = nullptr;
|
||||
int x0_strlen = asprintf (&x0_str, fmt, x0);
|
||||
if (x0_strlen < 0)
|
||||
xalloc_die ();
|
||||
@@ -489,7 +490,7 @@ seq_fast (char const *a, char const *b, uintmax_t step)
|
||||
q = memcpy (q0 + inc_size - q_len, b, q_len + 1);
|
||||
}
|
||||
else
|
||||
q = q0 = NULL;
|
||||
q = q0 = nullptr;
|
||||
|
||||
bool ok = inf || cmp (p, p_len, q, q_len) <= 0;
|
||||
if (ok)
|
||||
@@ -577,7 +578,7 @@ main (int argc, char **argv)
|
||||
struct layout layout = { 0, 0 };
|
||||
|
||||
/* The printf(3) format used for output. */
|
||||
char const *format_str = NULL;
|
||||
char const *format_str = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -602,7 +603,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
}
|
||||
|
||||
optc = getopt_long (argc, argv, "+f:s:w", long_options, NULL);
|
||||
optc = getopt_long (argc, argv, "+f:s:w", long_options, nullptr);
|
||||
if (optc == -1)
|
||||
break;
|
||||
|
||||
@@ -645,7 +646,7 @@ main (int argc, char **argv)
|
||||
if (format_str)
|
||||
format_str = long_double_format (format_str, &layout);
|
||||
|
||||
if (format_str != NULL && equal_width)
|
||||
if (format_str != nullptr && equal_width)
|
||||
{
|
||||
error (0, 0, _("format string may not be specified"
|
||||
" when printing equal width strings"));
|
||||
@@ -662,7 +663,7 @@ main (int argc, char **argv)
|
||||
bool fast_step_ok = false;
|
||||
if (n_args != 3
|
||||
|| (all_digits_p (argv[optind + 1])
|
||||
&& xstrtold (argv[optind + 1], NULL, &step.value, cl_strtold)
|
||||
&& xstrtold (argv[optind + 1], nullptr, &step.value, cl_strtold)
|
||||
&& 0 < step.value && step.value <= SEQ_FAST_STEP_LIMIT))
|
||||
fast_step_ok = true;
|
||||
|
||||
@@ -724,7 +725,7 @@ main (int argc, char **argv)
|
||||
/* Upon any failure, let the more general code deal with it. */
|
||||
}
|
||||
|
||||
if (format_str == NULL)
|
||||
if (format_str == nullptr)
|
||||
format_str = get_default_format (first, step, last);
|
||||
|
||||
print_numbers (format_str, layout, first.value, step.value, last.value);
|
||||
|
||||
@@ -72,7 +72,7 @@ complement_rp (void)
|
||||
struct field_range_pair *c = frp;
|
||||
size_t n = n_frp;
|
||||
|
||||
frp = NULL;
|
||||
frp = nullptr;
|
||||
n_frp = 0;
|
||||
n_frp_allocated = 0;
|
||||
|
||||
|
||||
32
src/shred.c
32
src/shred.c
@@ -120,7 +120,7 @@ enum remove_method
|
||||
|
||||
static char const *const remove_args[] =
|
||||
{
|
||||
"unlink", "wipe", "wipesync", NULL
|
||||
"unlink", "wipe", "wipesync", nullptr
|
||||
};
|
||||
|
||||
static enum remove_method const remove_methods[] =
|
||||
@@ -148,17 +148,17 @@ enum
|
||||
|
||||
static struct option const long_opts[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0}
|
||||
{nullptr, 0, nullptr, 0}
|
||||
};
|
||||
|
||||
void
|
||||
@@ -454,7 +454,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
|
||||
if (n)
|
||||
{
|
||||
error (0, 0, _("%s: pass %lu/%lu (%s)..."), qname, k, n, pass_string);
|
||||
thresh = time (NULL) + VERBOSE_UPDATE;
|
||||
thresh = time (nullptr) + VERBOSE_UPDATE;
|
||||
previous_human_offset = "";
|
||||
}
|
||||
|
||||
@@ -548,7 +548,7 @@ dopass (int fd, struct stat const *st, char const *qname, off_t *sizep,
|
||||
|
||||
/* Time to print progress? */
|
||||
if (n && ((done && *previous_human_offset)
|
||||
|| thresh <= (now = time (NULL))))
|
||||
|| thresh <= (now = time (nullptr))))
|
||||
{
|
||||
char offset_buf[LONGEST_HUMAN_READABLE + 1];
|
||||
char size_buf[LONGEST_HUMAN_READABLE + 1];
|
||||
@@ -996,7 +996,7 @@ incname (char *name, size_t len)
|
||||
char const *p = strchr (nameset, name[len]);
|
||||
|
||||
/* Given that NAME is composed of bytes from NAMESET,
|
||||
P will never be NULL here. */
|
||||
P will never be null here. */
|
||||
assert (p);
|
||||
|
||||
/* If this character has a successor, use it. */
|
||||
@@ -1173,7 +1173,7 @@ main (int argc, char **argv)
|
||||
int n_files;
|
||||
int c;
|
||||
int i;
|
||||
char const *random_source = NULL;
|
||||
char const *random_source = nullptr;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -1186,7 +1186,7 @@ main (int argc, char **argv)
|
||||
flags.n_iterations = DEFAULT_PASSES;
|
||||
flags.size = -1;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "fn:s:uvxz", long_opts, NULL)) != -1)
|
||||
while ((c = getopt_long (argc, argv, "fn:s:uvxz", long_opts, nullptr)) != -1)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
@@ -1208,7 +1208,7 @@ main (int argc, char **argv)
|
||||
break;
|
||||
|
||||
case 'u':
|
||||
if (optarg == NULL)
|
||||
if (optarg == nullptr)
|
||||
flags.remove_file = remove_wipesync;
|
||||
else
|
||||
flags.remove_file = XARGMATCH ("--remove", optarg,
|
||||
|
||||
51
src/shuf.c
51
src/shuf.c
@@ -99,13 +99,13 @@ enum
|
||||
|
||||
static struct option const long_opts[] =
|
||||
{
|
||||
{"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'},
|
||||
{"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'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{0, 0, 0, 0},
|
||||
@@ -177,7 +177,7 @@ read_input_reservoir_sampling (FILE *in, char eolbyte, size_t k,
|
||||
{
|
||||
randint n_lines = 0;
|
||||
size_t n_alloc_lines = MIN (k, RESERVOIR_LINES_INCREMENT);
|
||||
struct linebuffer *line = NULL;
|
||||
struct linebuffer *line = nullptr;
|
||||
struct linebuffer *rsrv;
|
||||
|
||||
rsrv = xcalloc (n_alloc_lines, sizeof (struct linebuffer));
|
||||
@@ -185,7 +185,7 @@ read_input_reservoir_sampling (FILE *in, char eolbyte, size_t k,
|
||||
/* Fill the first K lines, directly into the reservoir. */
|
||||
while (n_lines < k
|
||||
&& (line =
|
||||
readlinebuffer_delim (&rsrv[n_lines], in, eolbyte)) != NULL)
|
||||
readlinebuffer_delim (&rsrv[n_lines], in, eolbyte)) != nullptr)
|
||||
{
|
||||
n_lines++;
|
||||
|
||||
@@ -199,8 +199,8 @@ read_input_reservoir_sampling (FILE *in, char eolbyte, size_t k,
|
||||
}
|
||||
}
|
||||
|
||||
/* last line wasn't NULL - so there may be more lines to read. */
|
||||
if (line != NULL)
|
||||
/* last line wasn't null - so there may be more lines to read. */
|
||||
if (line != nullptr)
|
||||
{
|
||||
struct linebuffer dummy;
|
||||
initbuffer (&dummy); /* space for lines not put in reservoir. */
|
||||
@@ -219,7 +219,7 @@ read_input_reservoir_sampling (FILE *in, char eolbyte, size_t k,
|
||||
randint j = randint_choose (s, n_lines + 1); /* 0 .. n_lines. */
|
||||
line = (j < k) ? (&rsrv[j]) : (&dummy);
|
||||
}
|
||||
while (readlinebuffer_delim (line, in, eolbyte) != NULL && n_lines++);
|
||||
while (readlinebuffer_delim (line, in, eolbyte) != nullptr && n_lines++);
|
||||
|
||||
if (! n_lines)
|
||||
die (EXIT_FAILURE, EOVERFLOW, _("too many input lines"));
|
||||
@@ -259,7 +259,7 @@ static size_t
|
||||
read_input (FILE *in, char eolbyte, char ***pline)
|
||||
{
|
||||
char *p;
|
||||
char *buf = NULL;
|
||||
char *buf = nullptr;
|
||||
size_t used;
|
||||
char *lim;
|
||||
char **line;
|
||||
@@ -375,10 +375,10 @@ main (int argc, char **argv)
|
||||
size_t lo_input = SIZE_MAX;
|
||||
size_t hi_input = 0;
|
||||
size_t head_lines = SIZE_MAX;
|
||||
char const *outfile = NULL;
|
||||
char *random_source = NULL;
|
||||
char const *outfile = nullptr;
|
||||
char *random_source = nullptr;
|
||||
char eolbyte = '\n';
|
||||
char **input_lines = NULL;
|
||||
char **input_lines = nullptr;
|
||||
bool use_reservoir_sampling = false;
|
||||
bool repeat = false;
|
||||
|
||||
@@ -386,10 +386,10 @@ main (int argc, char **argv)
|
||||
int n_operands;
|
||||
char **operand;
|
||||
size_t n_lines;
|
||||
char **line = NULL;
|
||||
struct linebuffer *reservoir = NULL;
|
||||
char **line = nullptr;
|
||||
struct linebuffer *reservoir = nullptr;
|
||||
struct randint_source *randint_source;
|
||||
size_t *permutation = NULL;
|
||||
size_t *permutation = nullptr;
|
||||
int i;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
@@ -400,7 +400,8 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "ei:n:o:rz", long_opts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "ei:n:o:rz", long_opts, nullptr))
|
||||
!= -1)
|
||||
switch (optc)
|
||||
{
|
||||
case 'e':
|
||||
@@ -415,7 +416,7 @@ main (int argc, char **argv)
|
||||
|
||||
uintmax_t u;
|
||||
char *lo_end;
|
||||
strtol_error err = xstrtoumax (optarg, &lo_end, 10, &u, NULL);
|
||||
strtol_error err = xstrtoumax (optarg, &lo_end, 10, &u, nullptr);
|
||||
if (err == LONGINT_OK)
|
||||
{
|
||||
lo_input = u;
|
||||
@@ -425,7 +426,7 @@ main (int argc, char **argv)
|
||||
err = LONGINT_INVALID;
|
||||
else
|
||||
{
|
||||
err = xstrtoumax (lo_end + 1, NULL, 10, &u, "");
|
||||
err = xstrtoumax (lo_end + 1, nullptr, 10, &u, "");
|
||||
if (err == LONGINT_OK)
|
||||
{
|
||||
hi_input = u;
|
||||
@@ -446,7 +447,7 @@ main (int argc, char **argv)
|
||||
case 'n':
|
||||
{
|
||||
uintmax_t argval;
|
||||
strtol_error e = xstrtoumax (optarg, NULL, 10, &argval, "");
|
||||
strtol_error e = xstrtoumax (optarg, nullptr, 10, &argval, "");
|
||||
|
||||
if (e == LONGINT_OK)
|
||||
head_lines = MIN (head_lines, argval);
|
||||
@@ -501,7 +502,7 @@ main (int argc, char **argv)
|
||||
if (head_lines == 0)
|
||||
{
|
||||
n_lines = 0;
|
||||
line = NULL;
|
||||
line = nullptr;
|
||||
}
|
||||
else if (echo)
|
||||
{
|
||||
@@ -512,7 +513,7 @@ main (int argc, char **argv)
|
||||
else if (input_range)
|
||||
{
|
||||
n_lines = hi_input - lo_input + 1;
|
||||
line = NULL;
|
||||
line = nullptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -109,7 +109,7 @@ main (int argc, char **argv)
|
||||
|
||||
parse_gnu_standard_options_only (argc, argv, PROGRAM_NAME, PACKAGE_NAME,
|
||||
Version, true, usage, AUTHORS,
|
||||
(char const *) NULL);
|
||||
(char const *) nullptr);
|
||||
|
||||
if (argc == 1)
|
||||
{
|
||||
|
||||
191
src/sort.c
191
src/sort.c
@@ -550,37 +550,37 @@ static char const short_options[] = "-bcCdfghik:mMno:rRsS:t:T:uVy:z";
|
||||
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
{"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},
|
||||
{"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},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
{NULL, 0, NULL, 0},
|
||||
{nullptr, 0, nullptr, 0},
|
||||
};
|
||||
|
||||
#define CHECK_TABLE \
|
||||
@@ -591,7 +591,7 @@ static struct option const long_options[] =
|
||||
static char const *const check_args[] =
|
||||
{
|
||||
#define _ct_(_s, _c) _s,
|
||||
CHECK_TABLE NULL
|
||||
CHECK_TABLE nullptr
|
||||
#undef _ct_
|
||||
};
|
||||
static char const check_types[] =
|
||||
@@ -612,7 +612,7 @@ static char const check_types[] =
|
||||
static char const *const sort_args[] =
|
||||
{
|
||||
#define _st_(_s, _c) _s,
|
||||
SORT_TABLE NULL
|
||||
SORT_TABLE nullptr
|
||||
#undef _st_
|
||||
};
|
||||
static char const sort_types[] =
|
||||
@@ -647,7 +647,7 @@ cs_leave (struct cs_status const *status)
|
||||
if (status->valid)
|
||||
{
|
||||
/* Ignore failure when restoring the signal mask. */
|
||||
pthread_sigmask (SIG_SETMASK, &status->sigs, NULL);
|
||||
pthread_sigmask (SIG_SETMASK, &status->sigs, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -737,10 +737,10 @@ register_proc (struct tempnode *temp)
|
||||
{
|
||||
if (! proctab)
|
||||
{
|
||||
proctab = hash_initialize (INIT_PROCTAB_SIZE, NULL,
|
||||
proctab = hash_initialize (INIT_PROCTAB_SIZE, nullptr,
|
||||
proctab_hasher,
|
||||
proctab_comparator,
|
||||
NULL);
|
||||
nullptr);
|
||||
if (! proctab)
|
||||
xalloc_die ();
|
||||
}
|
||||
@@ -814,7 +814,7 @@ cleanup (void)
|
||||
|
||||
for (node = temphead; node; node = node->next)
|
||||
unlink (node->name);
|
||||
temphead = NULL;
|
||||
temphead = nullptr;
|
||||
}
|
||||
|
||||
/* Cleanup actions to take when exiting. */
|
||||
@@ -837,7 +837,7 @@ exit_cleanup (void)
|
||||
|
||||
/* Create a new temporary file, returning its newly allocated tempnode.
|
||||
Store into *PFD the file descriptor open for writing.
|
||||
If the creation fails, return NULL and store -1 into *PFD if the
|
||||
If the creation fails, return nullptr and store -1 into *PFD if the
|
||||
failure is due to file descriptor exhaustion and
|
||||
SURVIVE_FD_EXHAUSTION; otherwise, die. */
|
||||
|
||||
@@ -857,7 +857,7 @@ create_temp_file (int *pfd, bool survive_fd_exhaustion)
|
||||
|
||||
memcpy (file, temp_dir, len);
|
||||
memcpy (file + len, slashbase, sizeof slashbase);
|
||||
node->next = NULL;
|
||||
node->next = nullptr;
|
||||
if (++temp_dir_index == temp_dir_count)
|
||||
temp_dir_index = 0;
|
||||
|
||||
@@ -879,14 +879,14 @@ create_temp_file (int *pfd, bool survive_fd_exhaustion)
|
||||
die (SORT_FAILURE, errno, _("cannot create temporary file in %s"),
|
||||
quoteaf (temp_dir));
|
||||
free (node);
|
||||
node = NULL;
|
||||
node = nullptr;
|
||||
}
|
||||
|
||||
*pfd = fd;
|
||||
return node;
|
||||
}
|
||||
|
||||
/* Return a pointer to stdout status, or NULL on failure. */
|
||||
/* Return a pointer to stdout status, or nullptr on failure. */
|
||||
|
||||
static struct stat *
|
||||
get_outstatus (void)
|
||||
@@ -895,7 +895,7 @@ 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 : NULL;
|
||||
return outstat_errno < 0 ? &outstat : nullptr;
|
||||
}
|
||||
|
||||
/* Return a stream for FILE, opened with mode HOW. If HOW is "w",
|
||||
@@ -903,7 +903,7 @@ get_outstatus (void)
|
||||
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 NULL if unsuccessful.
|
||||
opening an ordinary FILE. Return nullptr if unsuccessful.
|
||||
|
||||
Use fadvise to specify an access pattern for input files.
|
||||
There are a few hints we could possibly provide,
|
||||
@@ -961,7 +961,7 @@ stream_open (char const *file, char const *how)
|
||||
else
|
||||
{
|
||||
int fd = open (file, O_RDONLY | O_CLOEXEC);
|
||||
fp = fd < 0 ? NULL : fdopen (fd, how);
|
||||
fp = fd < 0 ? nullptr : fdopen (fd, how);
|
||||
}
|
||||
fadvise (fp, FADVISE_SEQUENTIAL);
|
||||
}
|
||||
@@ -1067,7 +1067,7 @@ pipe_fork (int pipefds[2], size_t tries)
|
||||
if it receives a signal before exec-ing. */
|
||||
cs_enter (&cs);
|
||||
saved_temphead = temphead;
|
||||
temphead = NULL;
|
||||
temphead = nullptr;
|
||||
|
||||
pid = fork ();
|
||||
saved_errno = errno;
|
||||
@@ -1112,7 +1112,7 @@ pipe_fork (int pipefds[2], size_t tries)
|
||||
/* 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 NULL if the failure is due to file descriptor
|
||||
fails, return nullptr if the failure is due to file descriptor
|
||||
exhaustion and SURVIVE_FD_EXHAUSTION; otherwise, die. */
|
||||
|
||||
static struct tempnode *
|
||||
@@ -1121,7 +1121,7 @@ maybe_create_temp (FILE **pfp, bool survive_fd_exhaustion)
|
||||
int tempfd;
|
||||
struct tempnode *node = create_temp_file (&tempfd, survive_fd_exhaustion);
|
||||
if (! node)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
node->state = UNCOMPRESSED;
|
||||
|
||||
@@ -1146,7 +1146,7 @@ maybe_create_temp (FILE **pfp, bool survive_fd_exhaustion)
|
||||
move_fd (tempfd, STDOUT_FILENO);
|
||||
move_fd (pipefds[0], STDIN_FILENO);
|
||||
|
||||
execlp (compress_program, compress_program, (char *) NULL);
|
||||
execlp (compress_program, compress_program, (char *) nullptr);
|
||||
|
||||
async_safe_die (errno, "couldn't execute compress program");
|
||||
}
|
||||
@@ -1170,7 +1170,7 @@ create_temp (FILE **pfp)
|
||||
}
|
||||
|
||||
/* Open a compressed temp file and start a decompression process through
|
||||
which to filter the input. Return NULL (setting errno to
|
||||
which to filter the input. Return nullptr (setting errno to
|
||||
EMFILE) if we ran out of file descriptors, and die on any other
|
||||
kind of failure. */
|
||||
|
||||
@@ -1178,14 +1178,14 @@ static FILE *
|
||||
open_temp (struct tempnode *temp)
|
||||
{
|
||||
int tempfd, pipefds[2];
|
||||
FILE *fp = NULL;
|
||||
FILE *fp = nullptr;
|
||||
|
||||
if (temp->state == UNREAPED)
|
||||
wait_proc (temp->pid);
|
||||
|
||||
tempfd = open (temp->name, O_RDONLY);
|
||||
if (tempfd < 0)
|
||||
return NULL;
|
||||
return nullptr;
|
||||
|
||||
pid_t child = pipe_fork (pipefds, MAX_FORK_TRIES_DECOMPRESS);
|
||||
|
||||
@@ -1206,7 +1206,7 @@ open_temp (struct tempnode *temp)
|
||||
move_fd (tempfd, STDIN_FILENO);
|
||||
move_fd (pipefds[1], STDOUT_FILENO);
|
||||
|
||||
execlp (compress_program, compress_program, "-d", (char *) NULL);
|
||||
execlp (compress_program, compress_program, "-d", (char *) nullptr);
|
||||
|
||||
async_safe_die (errno, "couldn't execute compress program (with -d)");
|
||||
|
||||
@@ -1333,7 +1333,7 @@ specify_nmerge (int oi, char c, char const *s)
|
||||
{
|
||||
uintmax_t n;
|
||||
struct rlimit rlimit;
|
||||
enum strtol_error e = xstrtoumax (s, NULL, 10, &n, "");
|
||||
enum strtol_error e = xstrtoumax (s, nullptr, 10, &n, "");
|
||||
|
||||
/* Try to find out how many file descriptors we'll be able
|
||||
to open. We need at least nmerge + 3 (STDIN_FILENO,
|
||||
@@ -1447,7 +1447,7 @@ static size_t
|
||||
specify_nthreads (int oi, char c, char const *s)
|
||||
{
|
||||
uintmax_t nthreads;
|
||||
enum strtol_error e = xstrtoumax (s, NULL, 10, &nthreads, "");
|
||||
enum strtol_error e = xstrtoumax (s, nullptr, 10, &nthreads, "");
|
||||
if (e == LONGINT_OVERFLOW)
|
||||
return SIZE_MAX;
|
||||
if (e != LONGINT_OK)
|
||||
@@ -2141,7 +2141,7 @@ compare_random (char *restrict texta, size_t lena,
|
||||
char stackbuf[4000];
|
||||
char *buf = stackbuf;
|
||||
size_t bufsize = sizeof stackbuf;
|
||||
void *allocated = NULL;
|
||||
void *allocated = nullptr;
|
||||
uint32_t dig[2][MD5_DIGEST_SIZE / sizeof (uint32_t)];
|
||||
struct md5_ctx s[2];
|
||||
s[0] = s[1] = random_md5_state;
|
||||
@@ -2186,7 +2186,7 @@ compare_random (char *restrict texta, size_t lena,
|
||||
bool a_fits = sizea <= bufsize;
|
||||
size_t sizeb =
|
||||
(textb < limb
|
||||
? (xstrxfrm ((a_fits ? buf + sizea : NULL), textb,
|
||||
? (xstrxfrm ((a_fits ? buf + sizea : nullptr), textb,
|
||||
(a_fits ? bufsize - sizea : 0))
|
||||
+ 1)
|
||||
: 0);
|
||||
@@ -2505,9 +2505,9 @@ key_warnings (struct keyfield const *gkey, bool gkey_only)
|
||||
|
||||
/* Flag global options not copied or specified in any key. */
|
||||
if (ugkey.ignore && (ugkey.ignore == key->ignore))
|
||||
ugkey.ignore = NULL;
|
||||
ugkey.ignore = nullptr;
|
||||
if (ugkey.translate && (ugkey.translate == key->translate))
|
||||
ugkey.translate = NULL;
|
||||
ugkey.translate = nullptr;
|
||||
ugkey.skipsblanks &= !key->skipsblanks;
|
||||
ugkey.skipeblanks &= !key->skipeblanks;
|
||||
ugkey.month &= !key->month;
|
||||
@@ -2653,7 +2653,7 @@ keycompare (struct line const *a, struct line const *b)
|
||||
char enda = ta[tlena];
|
||||
char endb = tb[tlenb];
|
||||
|
||||
void *allocated = NULL;
|
||||
void *allocated = nullptr;
|
||||
char stackbuf[4000];
|
||||
|
||||
if (ignore || translate)
|
||||
@@ -2697,7 +2697,7 @@ keycompare (struct line const *a, struct line const *b)
|
||||
else if (key->human_numeric)
|
||||
diff = human_numcompare (ta, tb);
|
||||
else if (key->month)
|
||||
diff = getmonth (ta, NULL) - getmonth (tb, NULL);
|
||||
diff = getmonth (ta, nullptr) - getmonth (tb, nullptr);
|
||||
else if (key->random)
|
||||
diff = compare_random (ta, tlena, tb, tlenb);
|
||||
else if (key->version)
|
||||
@@ -2910,7 +2910,7 @@ check (char const *file_name, char checkonly)
|
||||
|
||||
initbuf (&buf, sizeof (struct line),
|
||||
MAX (merge_buffer_size, sort_size));
|
||||
temp.text = NULL;
|
||||
temp.text = nullptr;
|
||||
|
||||
while (fillbuf (&buf, fp, file_name))
|
||||
{
|
||||
@@ -3008,7 +3008,7 @@ open_input_files (struct sortfile *files, size_t nfiles, FILE ***pfps)
|
||||
NFILES is the number of files; 0 <= NTEMPS <= NFILES <= NMERGE.
|
||||
FPS is the vector of open stream corresponding to the files.
|
||||
Close input and output streams before returning.
|
||||
OUTPUT_FILE gives the name of the output file. If it is NULL,
|
||||
OUTPUT_FILE gives the name of the output file. If it is null,
|
||||
the output file is standard output. */
|
||||
|
||||
static void
|
||||
@@ -3018,7 +3018,7 @@ mergefps (struct sortfile *files, size_t ntemps, size_t nfiles,
|
||||
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 = NULL;
|
||||
struct line const *savedline = nullptr;
|
||||
/* &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);
|
||||
@@ -3033,7 +3033,7 @@ mergefps (struct sortfile *files, size_t ntemps, size_t nfiles,
|
||||
size_t j;
|
||||
size_t t;
|
||||
struct keyfield const *key = keylist;
|
||||
saved.text = NULL;
|
||||
saved.text = nullptr;
|
||||
|
||||
/* Read initial lines from each input file. */
|
||||
for (i = 0; i < nfiles; )
|
||||
@@ -3086,7 +3086,7 @@ mergefps (struct sortfile *files, size_t ntemps, size_t nfiles,
|
||||
{
|
||||
if (savedline && compare (savedline, smallest))
|
||||
{
|
||||
savedline = NULL;
|
||||
savedline = nullptr;
|
||||
write_line (&saved, ofp, output_file);
|
||||
}
|
||||
if (!savedline)
|
||||
@@ -3339,13 +3339,13 @@ merge_tree_init (size_t nthreads, size_t nlines, struct line *dest)
|
||||
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 = NULL;
|
||||
root->dest = NULL;
|
||||
root->lo = root->hi = root->end_lo = root->end_hi = nullptr;
|
||||
root->dest = nullptr;
|
||||
root->nlo = root->nhi = nlines;
|
||||
root->parent = NULL;
|
||||
root->parent = nullptr;
|
||||
root->level = MERGE_END;
|
||||
root->queued = false;
|
||||
pthread_mutex_init (&root->lock, NULL);
|
||||
pthread_mutex_init (&root->lock, nullptr);
|
||||
|
||||
init_node (root, root + 1, dest, nthreads, nlines, false);
|
||||
return merge_tree;
|
||||
@@ -3396,7 +3396,7 @@ init_node (struct merge_node *restrict parent,
|
||||
node->parent = parent;
|
||||
node->level = parent->level + 1;
|
||||
node->queued = false;
|
||||
pthread_mutex_init (&node->lock, NULL);
|
||||
pthread_mutex_init (&node->lock, nullptr);
|
||||
|
||||
if (nthreads > 1)
|
||||
{
|
||||
@@ -3411,8 +3411,8 @@ init_node (struct merge_node *restrict parent,
|
||||
}
|
||||
else
|
||||
{
|
||||
node->lo_child = NULL;
|
||||
node->hi_child = NULL;
|
||||
node->lo_child = nullptr;
|
||||
node->hi_child = nullptr;
|
||||
}
|
||||
return node_pool;
|
||||
}
|
||||
@@ -3463,11 +3463,11 @@ static void
|
||||
queue_init (struct merge_node_queue *queue, size_t nthreads)
|
||||
{
|
||||
/* Though it's highly unlikely all nodes are in the heap at the same
|
||||
time, the heap should accommodate all of them. Counting a NULL
|
||||
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, NULL);
|
||||
pthread_cond_init (&queue->cond, NULL);
|
||||
pthread_mutex_init (&queue->mutex, nullptr);
|
||||
pthread_cond_init (&queue->cond, nullptr);
|
||||
}
|
||||
|
||||
/* Insert NODE into QUEUE. The caller either holds a lock on NODE, or
|
||||
@@ -3696,7 +3696,7 @@ sortlines_thread (void *data)
|
||||
sortlines (args->lines, args->nthreads, args->total_lines,
|
||||
args->node, args->queue, args->tfp,
|
||||
args->output_temp);
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Sort lines, possibly in parallel. The arguments are as in struct
|
||||
@@ -3738,11 +3738,11 @@ sortlines (struct line *restrict lines, size_t nthreads,
|
||||
node->lo_child, queue, tfp, temp_output};
|
||||
|
||||
if (nthreads > 1 && SUBTHREAD_LINES_HEURISTIC <= nlines
|
||||
&& pthread_create (&thread, NULL, sortlines_thread, &args) == 0)
|
||||
&& pthread_create (&thread, nullptr, sortlines_thread, &args) == 0)
|
||||
{
|
||||
sortlines (lines - node->nlo, hi_threads, total_lines,
|
||||
node->hi_child, queue, tfp, temp_output);
|
||||
pthread_join (thread, NULL);
|
||||
pthread_join (thread, nullptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3788,7 +3788,7 @@ static void
|
||||
avoid_trashing_input (struct sortfile *files, size_t ntemps,
|
||||
size_t nfiles, char const *outfile)
|
||||
{
|
||||
struct tempnode *tempcopy = NULL;
|
||||
struct tempnode *tempcopy = nullptr;
|
||||
|
||||
for (size_t i = ntemps; i < nfiles; i++)
|
||||
{
|
||||
@@ -4041,7 +4041,7 @@ sort (char *const *files, size_t nfiles, char const *output_file,
|
||||
break;
|
||||
}
|
||||
|
||||
saved_line.text = NULL;
|
||||
saved_line.text = nullptr;
|
||||
line = buffer_linelim (&buf);
|
||||
if (buf.eof && !nfiles && !ntemps && !buf.left)
|
||||
{
|
||||
@@ -4110,7 +4110,7 @@ insertkey (struct keyfield *key_arg)
|
||||
for (p = &keylist; *p; p = &(*p)->next)
|
||||
continue;
|
||||
*p = key;
|
||||
key->next = NULL;
|
||||
key->next = nullptr;
|
||||
}
|
||||
|
||||
/* Report a bad field specification SPEC, with extra info MSGID. */
|
||||
@@ -4153,7 +4153,7 @@ check_ordering_compatibility (void)
|
||||
/* 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 NULL after
|
||||
substitute SIZE_MAX. If MSGID is null, return nullptr after
|
||||
failure; otherwise, report MSGID and exit on failure. */
|
||||
|
||||
static char const *
|
||||
@@ -4179,7 +4179,7 @@ parse_field_count (char const *string, size_t *val, char const *msgid)
|
||||
if (msgid)
|
||||
die (SORT_FAILURE, 0, _("%s: invalid count at start of %s"),
|
||||
_(msgid), quote (string));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return suffix;
|
||||
@@ -4279,17 +4279,17 @@ main (int argc, char **argv)
|
||||
int c = 0;
|
||||
char checkonly = 0;
|
||||
bool mergeonly = false;
|
||||
char *random_source = NULL;
|
||||
char *random_source = nullptr;
|
||||
bool need_random = false;
|
||||
size_t nthreads = 0;
|
||||
size_t nfiles = 0;
|
||||
bool posixly_correct = (getenv ("POSIXLY_CORRECT") != NULL);
|
||||
bool posixly_correct = (getenv ("POSIXLY_CORRECT") != nullptr);
|
||||
int posix_ver = posix2_version ();
|
||||
bool traditional_usage = ! (200112 <= posix_ver && posix_ver < 200809);
|
||||
char **files;
|
||||
char *files_from = NULL;
|
||||
char *files_from = nullptr;
|
||||
struct Tokens tok;
|
||||
char const *outfile = NULL;
|
||||
char const *outfile = nullptr;
|
||||
bool locale_ok;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
@@ -4357,7 +4357,7 @@ main (int argc, char **argv)
|
||||
sigemptyset (&caught_signals);
|
||||
for (i = 0; i < nsigs; i++)
|
||||
{
|
||||
sigaction (sig[i], NULL, &act);
|
||||
sigaction (sig[i], nullptr, &act);
|
||||
if (act.sa_handler != SIG_IGN)
|
||||
sigaddset (&caught_signals, sig[i]);
|
||||
}
|
||||
@@ -4368,7 +4368,7 @@ main (int argc, char **argv)
|
||||
|
||||
for (i = 0; i < nsigs; i++)
|
||||
if (sigismember (&caught_signals, sig[i]))
|
||||
sigaction (sig[i], &act, NULL);
|
||||
sigaction (sig[i], &act, nullptr);
|
||||
#else
|
||||
for (i = 0; i < nsigs; i++)
|
||||
if (signal (sig[i], SIG_IGN) != SIG_IGN)
|
||||
@@ -4414,7 +4414,7 @@ main (int argc, char **argv)
|
||||
else switch (c)
|
||||
{
|
||||
case 1:
|
||||
key = NULL;
|
||||
key = nullptr;
|
||||
if (optarg[0] == '+')
|
||||
{
|
||||
bool minus_pos_usage = (optind != argc && argv[optind][0] == '-'
|
||||
@@ -4425,13 +4425,13 @@ main (int argc, char **argv)
|
||||
/* 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, NULL);
|
||||
s = parse_field_count (optarg + 1, &key->sword, nullptr);
|
||||
if (s && *s == '.')
|
||||
s = parse_field_count (s + 1, &key->schar, NULL);
|
||||
s = parse_field_count (s + 1, &key->schar, nullptr);
|
||||
if (! (key->sword || key->schar))
|
||||
key->sword = SIZE_MAX;
|
||||
if (! s || *set_ordering (s, key, bl_start))
|
||||
key = NULL;
|
||||
key = nullptr;
|
||||
else
|
||||
{
|
||||
if (minus_pos_usage)
|
||||
@@ -4439,9 +4439,10 @@ main (int argc, char **argv)
|
||||
char const *optarg1 = argv[optind++];
|
||||
s = parse_field_count (optarg1 + 1, &key->eword,
|
||||
N_("invalid number after '-'"));
|
||||
/* When called with a non-NULL message ID,
|
||||
parse_field_count cannot return NULL. Tell static
|
||||
analysis tools that dereferencing S is safe. */
|
||||
/* When called with a non-null message ID,
|
||||
parse_field_count cannot return a null pointer.
|
||||
Tell static analysis tools that
|
||||
dereferencing S is safe. */
|
||||
assert (s);
|
||||
if (*s == '.')
|
||||
s = parse_field_count (s + 1, &key->echar,
|
||||
@@ -4765,7 +4766,7 @@ main (int argc, char **argv)
|
||||
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, NULL)));
|
||||
quote (setlocale (LC_COLLATE, nullptr)));
|
||||
else
|
||||
error (0, 0, "%s",
|
||||
_("text ordering performed using simple byte comparison"));
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user