halt='Use _GL... attribute macros' \
$(_sc_search_regexp)
+# Prefer the const declaration form, with const following the type
+sc_prohibit-const-char:
+ @prohibit='const char \*' \
+ in_vc_files='\.[ch]$$' \
+ halt='Use char const *, not const char *' \
+ $(_sc_search_regexp)
+
# Look for lines longer than 80 characters, except omit:
# - urls
# - the fdl.texi file copied from gnulib,
Update *WIDTH to indicate how many columns were used before padding. */
size_t
-mbsalign (const char *src, char *dest, size_t dest_size,
+mbsalign (char const *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags)
{
size_t ret = SIZE_MAX;
size_t src_size = strlen (src) + 1;
char *newstr = NULL;
wchar_t *str_wc = NULL;
- const char *str_to_print = src;
+ char const *str_to_print = src;
size_t n_cols = src_size - 1;
size_t n_used_bytes = n_cols; /* Not including NUL */
size_t n_spaces = 0;
Return NULL on failure. */
char *
-ambsalign (const char *src, size_t *width, mbs_align_t align, int flags)
+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
-mbsalign (const char *src, char *dest, size_t dest_size,
+mbsalign (char const *src, char *dest, size_t dest_size,
size_t *width, mbs_align_t align, int flags);
char *
-ambsalign (const char *src, size_t *width, mbs_align_t align, int flags);
+ambsalign (char const *src, size_t *width, mbs_align_t align, int flags);
}
static inline int
-smack_set_label_for_self (const char *label)
+smack_set_label_for_self (char const *label)
{
return -1;
}
ERR is printed along with N_STR on error. */
__xdectoint_t
-__xnumtoint (const char *n_str, int base, __xdectoint_t min, __xdectoint_t max,
- const char *suffixes, const char *err, int err_exit)
+__xnumtoint (char const *n_str, int base, __xdectoint_t min, __xdectoint_t max,
+ char const *suffixes, char const *err, int err_exit)
{
strtol_error s_err;
ERR is printed along with N_STR on error. */
__xdectoint_t
-__xdectoint (const char *n_str, __xdectoint_t min, __xdectoint_t max,
- const char *suffixes, const char *err, int err_exit)
+__xdectoint (char const *n_str, __xdectoint_t min, __xdectoint_t max,
+ char const *suffixes, char const *err, int err_exit)
{
return __xnumtoint (n_str, 10, min, max, suffixes, err, err_exit);
}
# include <inttypes.h>
# define _DECLARE_XDECTOINT(name, type) \
- type name (const char *n_str, type min, type max, \
- const char *suffixes, const char *err, int err_exit);
+ type name (char const *n_str, type min, type max, \
+ char const *suffixes, char const *err, int err_exit);
# define _DECLARE_XNUMTOINT(name, type) \
- type name (const char *n_str, int base, type min, type max, \
- const char *suffixes, const char *err, int err_exit);
+ type name (char const *n_str, int base, type min, type max, \
+ char const *suffixes, char const *err, int err_exit);
_DECLARE_XDECTOINT (xdectoimax, intmax_t)
_DECLARE_XDECTOINT (xdectoumax, uintmax_t)
consists entirely of SUFFIX. */
static void
-remove_suffix (char *name, const char *suffix)
+remove_suffix (char *name, char const *suffix)
{
char *np;
- const char *sp;
+ char const *sp;
np = name + strlen (name);
sp = suffix + strlen (suffix);
the trailing SUFFIX. Finally, output the result string. */
static void
-perform_basename (const char *string, const char *suffix, bool use_nuls)
+perform_basename (char const *string, char const *suffix, bool use_nuls)
{
char *name = base_name (string);
strip_trailing_slashes (name);
{
bool multiple_names = false;
bool use_nuls = false;
- const char *suffix = NULL;
+ char const *suffix = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
static int (*base_length) (int i);
static bool (*isbase) (char ch);
-static void (*base_encode) (const char *restrict in, size_t inlen,
+static void (*base_encode) (char const *restrict in, size_t inlen,
char *restrict out, size_t outlen);
struct base16_decode_context
};
static void (*base_decode_ctx_init) (struct base_decode_context *ctx);
static bool (*base_decode_ctx) (struct base_decode_context *ctx,
-const char *restrict in, size_t inlen,
+char const *restrict in, size_t inlen,
char *restrict out, size_t *outlen);
#endif
static bool
base64_decode_ctx_wrapper (struct base_decode_context *ctx,
- const char *restrict in, size_t inlen,
+ char const *restrict in, size_t inlen,
char *restrict out, size_t *outlen)
{
bool b = base64_decode_ctx (&ctx->ctx.base64, in, inlen, out, outlen);
static void
-base64url_encode (const char *restrict in, size_t inlen,
+base64url_encode (char const *restrict in, size_t inlen,
char *restrict out, size_t outlen)
{
base64_encode (in, inlen, out, outlen);
static bool
base64url_decode_ctx_wrapper (struct base_decode_context *ctx,
- const char *restrict in, size_t inlen,
+ char const *restrict in, size_t inlen,
char *restrict out, size_t *outlen)
{
prepare_inbuf (ctx, inlen);
static bool
base32_decode_ctx_wrapper (struct base_decode_context *ctx,
- const char *restrict in, size_t inlen,
+ char const *restrict in, size_t inlen,
char *restrict out, size_t *outlen)
{
bool b = base32_decode_ctx (&ctx->ctx.base32, in, inlen, out, outlen);
static void
-base32hex_encode (const char *restrict in, size_t inlen,
+base32hex_encode (char const *restrict in, size_t inlen,
char *restrict out, size_t outlen)
{
base32_encode (in, inlen, out, outlen);
static bool
base32hex_decode_ctx_wrapper (struct base_decode_context *ctx,
- const char *restrict in, size_t inlen,
+ char const *restrict in, size_t inlen,
char *restrict out, size_t *outlen)
{
prepare_inbuf (ctx, inlen);
static const char base16[16] = "0123456789ABCDEF";
static void
-base16_encode (const char *restrict in, size_t inlen,
+base16_encode (char const *restrict in, size_t inlen,
char *restrict out, size_t outlen)
{
while (inlen--)
static bool
base16_decode_ctx (struct base_decode_context *ctx,
- const char *restrict in, size_t inlen,
+ char const *restrict in, size_t inlen,
char *restrict out, size_t *outlen)
{
bool ignore_lines = true; /* for now, always ignore them */
".-:+=^!/*?&<>()[]{}@%$#";
static void
-z85_encode (const char *restrict in, size_t inlen,
+z85_encode (char const *restrict in, size_t inlen,
char *restrict out, size_t outlen)
{
int i = 0;
static bool
z85_decode_ctx (struct base_decode_context *ctx,
- const char *restrict in, size_t inlen,
+ char const *restrict in, size_t inlen,
char *restrict out, size_t *outlen)
{
bool ignore_lines = true; /* for now, always ignore them */
inline static void
-base2msbf_encode (const char *restrict in, size_t inlen,
+base2msbf_encode (char const *restrict in, size_t inlen,
char *restrict out, size_t outlen)
{
while (inlen--)
}
inline static void
-base2lsbf_encode (const char *restrict in, size_t inlen,
+base2lsbf_encode (char const *restrict in, size_t inlen,
char *restrict out, size_t outlen)
{
while (inlen--)
static bool
base2lsbf_decode_ctx (struct base_decode_context *ctx,
- const char *restrict in, size_t inlen,
+ char const *restrict in, size_t inlen,
char *restrict out, size_t *outlen)
{
bool ignore_lines = true; /* for now, always ignore them */
static bool
base2msbf_decode_ctx (struct base_decode_context *ctx,
- const char *restrict in, size_t inlen,
+ char const *restrict in, size_t inlen,
char *restrict out, size_t *outlen)
{
bool ignore_lines = true; /* for now, always ignore them */
static void
-wrap_write (const char *buffer, size_t len,
+wrap_write (char const *buffer, size_t len,
uintmax_t wrap_column, size_t *current_column, FILE *out)
{
size_t written;
{
int opt;
FILE *input_fh;
- const char *infile;
+ char const *infile;
/* True if --decode has been given and we should decode data. */
bool decode = false;
/* Return the group ID of NAME, or -1 if no name was specified. */
static gid_t
-parse_group (const char *name)
+parse_group (char const *name)
{
gid_t gid = -1;
CHANGED describes what (if anything) has happened. */
static void
-describe_change (const char *file, mode_t old_mode, mode_t mode,
+describe_change (char const *file, mode_t old_mode, mode_t mode,
enum Change_status changed)
{
char perms[12]; /* "-rwxrwxrwx" ls-style modes. */
char old_perms[12];
- const char *fmt;
+ char const *fmt;
if (changed == CH_NOT_APPLIED)
{
CHANGED describes what (if anything) has happened. */
static void
-describe_change (const char *file, enum Change_status changed,
+describe_change (char const *file, enum Change_status changed,
char const *old_user, char const *old_group,
char const *user, char const *group)
{
- const char *fmt;
+ char const *fmt;
char *old_spec;
char *spec;
case FROM_OPTION:
{
- const char *e = parse_user_spec (optarg,
+ char const *e = parse_user_spec (optarg,
&required_uid, &required_gid,
NULL, NULL);
if (e)
}
else
{
- const char *e = parse_user_spec (argv[optind], &uid, &gid,
+ char const *e = parse_user_spec (argv[optind], &uid, &gid,
&chopt.user_name, &chopt.group_name);
if (e)
die (EXIT_FAILURE, 0, "%s: %s", e, quote (argv[optind]));
static bool have_read_stdin;
static bool
-cksum_slice8 (FILE *fp, const char *file, uint_fast32_t *crc_out,
+cksum_slice8 (FILE *fp, char const *file, uint_fast32_t *crc_out,
uintmax_t *length_out);
static bool
- (*cksum_fp)(FILE *, const char *, uint_fast32_t *,
+ (*cksum_fp)(FILE *, char const *, uint_fast32_t *,
uintmax_t *) = cksum_slice8;
# if USE_PCLMUL_CRC32
# endif /* USE_PCLMUL_CRC32 */
static bool
-cksum_slice8 (FILE *fp, const char *file, uint_fast32_t *crc_out,
+cksum_slice8 (FILE *fp, char const *file, uint_fast32_t *crc_out,
uintmax_t *length_out)
{
uint32_t buf[BUFLEN/sizeof (uint32_t)];
Return true if successful. */
static bool
-cksum (const char *file, bool print_name)
+cksum (char const *file, bool print_name)
{
uint_fast32_t crc = 0;
uintmax_t length = 0;
# define __CKSUM_H__
extern bool
-cksum_pclmul (FILE *fp, const char *file, uint_fast32_t *crc_out,
+cksum_pclmul (FILE *fp, char const *file, uint_fast32_t *crc_out,
uintmax_t *length_out);
extern uint_fast32_t const crctab[8][256];
extern uint_fast32_t const crctab[8][256];
extern bool
-cksum_pclmul (FILE *fp, const char *file, uint_fast32_t *crc_out,
+cksum_pclmul (FILE *fp, char const *file, uint_fast32_t *crc_out,
uintmax_t *length_out);
/* Calculate CRC32 using PCLMULQDQ CPU instruction found in x86/x64 CPUs */
bool
-cksum_pclmul (FILE *fp, const char *file, uint_fast32_t *crc_out,
+cksum_pclmul (FILE *fp, char const *file, uint_fast32_t *crc_out,
uintmax_t *length_out)
{
__m128i buf[BUFLEN / sizeof (__m128i)];
FIXME: Should we handle POSIX ACLs similarly?
Return zero to skip. */
static int
-check_selinux_attr (const char *name, struct error_context *ctx)
+check_selinux_attr (char const *name, struct error_context *ctx)
{
return STRNCMP_LIT (name, "security.selinux")
&& attr_copy_check_permissions (name, ctx);
DEST_NAME if defined. */
static void
-set_author (const char *dst_name, int dest_desc, const struct stat *src_sb)
+set_author (char const *dst_name, int dest_desc, const struct stat *src_sb)
{
#if HAVE_STRUCT_STAT_ST_AUTHOR
/* FIXME: Modify the following code so that it does not
if (x->backup_type != numbered_backups
&& source_is_dst_backup (srcbase, &src_sb, dst_name))
{
- const char *fmt;
+ char const *fmt;
fmt = (x->move_mode
? _("backing up %s might destroy source; %s not moved")
: _("backing up %s might destroy source; %s not copied"));
on systems with a rename function that fails for a source file name
specified with a trailing slash. */
# if RENAME_TRAILING_SLASH_BUG
-int rpl_rename (const char *, const char *);
+int rpl_rename (char const *, char const *);
# undef rename
# define rename rpl_rename
# endif
}
static void
-launch_program (const char *prog_name, int prog_argc, char **prog_argv)
+launch_program (char const *prog_name, int prog_argc, char **prog_argv)
{
int (*prog_main) (int, char **) = NULL;
Return NULL if inserted, otherwise non-NULL. */
extern char *
-remember_copied (const char *name, ino_t ino, dev_t dev)
+remember_copied (char const *name, ino_t ino, dev_t dev)
{
struct Src_to_dest *ent;
struct Src_to_dest *ent_from_table;
void hash_init (void);
void forget_all (void);
void forget_created (ino_t ino, dev_t dev);
-char *remember_copied (const char *node, ino_t ino, dev_t dev);
+char *remember_copied (char const *node, ino_t ino, dev_t dev);
char *src_to_dest_lookup (ino_t ino, dev_t dev);
Return true if successful. */
static bool
-do_copy (int n_files, char **file, const char *target_directory,
+do_copy (int n_files, char **file, char const *target_directory,
bool no_target_directory, struct cp_options *x)
{
struct stat sb;
/* Open NAME as standard input. */
static void
-set_input_file (const char *name)
+set_input_file (char const *name)
{
if (! STREQ (name, "-") && fd_reopen (STDIN_FILENO, name, O_RDONLY, 0) < 0)
die (EXIT_FAILURE, errno, _("cannot open %s for reading"),
for (unsigned int i = 0; i < files_created; i++)
{
- const char *name = make_filename (i);
+ char const *name = make_filename (i);
if (unlink (name) != 0 && !in_signal_handler)
error (0, errno, "%s", quotef (name));
}
NUM is the numeric part of STR. */
static void
-check_for_offset (struct control *p, const char *str, const char *num)
+check_for_offset (struct control *p, char const *str, char const *num)
{
if (xstrtoimax (num, NULL, 10, &p->offset, "") != LONGINT_OK)
die (EXIT_FAILURE, 0, _("%s: integer expected after delimiter"),
char delim = *str;
char const *closing_delim;
struct control *p;
- const char *err;
+ char const *err;
closing_delim = strrchr (str + 1, delim);
if (closing_delim == NULL)
#define AUTHORS proper_name ("David MacKenzie")
-static bool show_date (const char *, struct timespec, timezone_t);
+static bool show_date (char const *, struct timespec, timezone_t);
enum Time_spec
{
Return true if successful. */
static bool
-batch_convert (const char *input_filename, const char *format,
+batch_convert (char const *input_filename, char const *format,
timezone_t tz, char const *tzstring)
{
bool ok;
main (int argc, char **argv)
{
int optc;
- const char *datestr = NULL;
- const char *set_datestr = NULL;
+ char const *datestr = NULL;
+ char const *set_datestr = NULL;
struct timespec when;
bool set_date = false;
char const *format = NULL;
in FORMAT, followed by a newline. Return true if successful. */
static bool
-show_date (const char *format, struct timespec when, timezone_t tz)
+show_date (char const *format, struct timespec when, timezone_t tz)
{
struct tm tm;
/* Like the 'error' function but handle any pending newline. */
static void _GL_ATTRIBUTE_FORMAT ((__printf__, 3, 4))
-nl_error (int status, int errnum, const char *fmt, ...)
+nl_error (int status, int errnum, char const *fmt, ...)
{
if (0 < progress_len)
{
number in this format. */
static uintmax_t
-parse_integer (const char *str, strtol_error *invalid)
+parse_integer (char const *str, strtol_error *invalid)
{
uintmax_t n;
char *suffix;
static void
copy_simple (char const *buf, size_t nread)
{
- const char *start = buf; /* First uncopied char in BUF. */
+ char const *start = buf; /* First uncopied char in BUF. */
do
{
display_field_t field;
char const *arg;
field_type_t field_type;
- const char *caption;/* NULL means to use the default header of this field. */
+ char const *caption;/* NULL means to use the 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;
can then be accessed with standard array notation. */
static void
-alloc_field (int f, const char *c)
+alloc_field (int f, char const *c)
{
ncolumns++;
columns = xnrealloc (columns, ncolumns, sizeof (struct field_data_t *));
/* Is FSTYPE a type of file system that should be listed? */
static bool _GL_ATTRIBUTE_PURE
-selected_fstype (const char *fstype)
+selected_fstype (char const *fstype)
{
const struct fs_type_list *fsp;
/* Is FSTYPE a type of file system that should be omitted? */
static bool _GL_ATTRIBUTE_PURE
-excluded_fstype (const char *fstype)
+excluded_fstype (char const *fstype)
{
const struct fs_type_list *fsp;
and show its disk usage.
STATP must be the result of 'stat (POINT, STATP)'. */
static void
-get_point (const char *point, const struct stat *statp)
+get_point (char const *point, const struct stat *statp)
{
struct stat disk_stats;
struct mount_entry *me;
/* Add FSTYPE to the list of file system types to display. */
static void
-add_fs_type (const char *fstype)
+add_fs_type (char const *fstype)
{
struct fs_type_list *fsp;
/* Add FSTYPE to the list of file system types to be omitted. */
static void
-add_excluded_fs_type (const char *fstype)
+add_excluded_fs_type (char const *fstype)
{
struct fs_type_list *fsp;
/* If true, use the POSIX output format. */
bool posix_format = false;
- const char *msg_mut_excl = _("options %s and %s are mutually exclusive");
+ char const *msg_mut_excl = _("options %s and %s are mutually exclusive");
while (true)
{
{
status = EXIT_FAILURE;
}
- const char *warning = (status == 0 ? _("Warning: ") : "");
+ char const *warning = (status == 0 ? _("Warning: ") : "");
error (status, errno, "%s%s", warning,
_("cannot read table of mounted file systems"));
}
variable. */
static struct obstack lsc_obstack;
-static const char *const slack_codes[] =
+static char const *const slack_codes[] =
{
"NORMAL", "NORM", "FILE", "RESET", "DIR", "LNK", "LINK",
"SYMLINK", "ORPHAN", "MISSING", "FIFO", "PIPE", "SOCK", "BLK", "BLOCK",
"MULTIHARDLINK", "CLRTOEOL", NULL
};
-static const char *const ls_codes[] =
+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",
sequences like unescaped : and = characters. */
static void
-append_quoted (const char *str)
+append_quoted (char const *str)
{
bool need_backslash = true;
Return true if successful. */
static bool
-dc_parse_stream (FILE *fp, const char *filename)
+dc_parse_stream (FILE *fp, char const *filename)
{
size_t line_number = 0;
char const *next_G_line = G_line;
}
static bool
-dc_parse_file (const char *filename)
+dc_parse_file (char const *filename)
{
bool ok;
{
size_t len = obstack_object_size (&lsc_obstack);
char *s = obstack_finish (&lsc_obstack);
- const char *prefix;
- const char *suffix;
+ char const *prefix;
+ char const *suffix;
if (syntax == SHELL_SYNTAX_BOURNE)
{
in FORMAT. */
static void
-show_date (const char *format, struct timespec when, timezone_t tz)
+show_date (char const *format, struct timespec when, timezone_t tz)
{
struct tm tm;
if (localtime_rz (tz, &when.tv_sec, &tm))
/* Print size (and optionally time) indicated by *PDUI, followed by STRING. */
static void
-print_size (const struct duinfo *pdui, const char *string)
+print_size (const struct duinfo *pdui, char const *string)
{
print_only_size (opt_inodes
? pdui->inodes
directory at the specified level. */
static struct dulevel *dulvl;
- const char *file = ent->fts_path;
+ char const *file = ent->fts_path;
const struct stat *sb = ent->fts_statp;
int info = ent->fts_info;
proper_name ("Assaf Gordon")
/* Array of envvars to unset. */
-static const char **usvars;
+static char const **usvars;
static size_t usvars_alloc;
static idx_t usvars_used;
}
static void
-append_unset_var (const char *var)
+append_unset_var (char const *var)
{
if (usvars_used == usvars_alloc)
usvars = x2nrealloc (usvars, &usvars_alloc, sizeof *usvars);
First letter in VARNAME must be alpha or underscore,
rest of letters are alnum or underscore.
Any other character is an error. */
-static const char * _GL_ATTRIBUTE_PURE
-scan_varname (const char *str)
+static char const * _GL_ATTRIBUTE_PURE
+scan_varname (char const *str)
{
if (str[1] == '{' && (c_isalpha (str[2]) || str[2] == '_'))
{
- const char *end = str + 3;
+ char const *end = str + 3;
while (c_isalnum (*end) || *end == '_')
++end;
if (*end == '}')
The returned pointer should not be freed.
Return NULL if not a valid ${VARNAME} syntax. */
static char *
-extract_varname (const char *str)
+extract_varname (char const *str)
{
idx_t i;
- const char *p;
+ char const *p;
p = scan_varname (str);
if (!p)
and the complexity of keeping track of the storage that may have been
allocated via multiple calls to build_argv is not worth the hassle. */
static char **
-build_argv (const char *str, int extra_argc, int *argc)
+build_argv (char const *str, int extra_argc, int *argc)
{
bool dq = false, sq = false;
struct splitbuf ss;
argc will be updated from 4 to 6.
optind will be reset to 0 to force getopt_long to rescan all arguments. */
static void
-parse_split_string (const char *str, int *orig_optind,
+parse_split_string (char const *str, int *orig_optind,
int *orig_argc, char ***orig_argv)
{
int extra_argc = *orig_argc - *orig_optind, newargc;
}
static void
-parse_signal_action_params (const char *optarg, bool set_default)
+parse_signal_action_params (char const *optarg, bool set_default)
{
char signame[SIG2STR_MAX];
char *opt_sig;
static void
-parse_block_signal_params (const char *optarg, bool block)
+parse_block_signal_params (char const *optarg, bool block)
{
char signame[SIG2STR_MAX];
char *opt_sig;
{
/* Get the existing signal mask */
sigset_t set;
- const char *debug_act;
+ char const *debug_act;
sigemptyset (&set);
mbs_logical_cspn ('\xCE\xB1bc','\xCE\xB1') => 1
mbs_logical_cspn ('\xCE\xB1bc','c') => 3 */
static size_t
-mbs_logical_cspn (const char *s, const char *accept)
+mbs_logical_cspn (char const *s, char const *accept)
{
size_t idx = 0;
Upon exit, sets v->s to the new string.
The new string might be empty if POS/LEN are invalid. */
static char *
-mbs_logical_substr (const char *s, size_t pos, size_t len)
+mbs_logical_substr (char const *s, size_t pos, size_t len)
{
char *v, *vlim;
up to the first 4 bytes (The U+2767 which occupies 3 bytes and 'x'):
mbs_count_to_offset ("\xE2\x9D\xA7xyz", 4) => 2 */
static size_t
-mbs_offset_to_chars (const char *s, size_t ofs)
+mbs_offset_to_chars (char const *s, size_t ofs)
{
mbui_iterator_t iter;
size_t c = 0;
docolon (VALUE *sv, VALUE *pv)
{
VALUE *v IF_LINT ( = NULL);
- const char *errmsg;
+ char const *errmsg;
struct re_pattern_buffer re_buffer;
char fastmap[UCHAR_MAX + 1];
struct re_registers re_regs;
}
static strtol_error
-strto2uintmax (uintmax_t *hip, uintmax_t *lop, const char *s)
+strto2uintmax (uintmax_t *hip, uintmax_t *lop, char const *s)
{
unsigned int lo_carry;
uintmax_t hi = 0, lo = 0;
strtol_error err = LONGINT_INVALID;
/* Initial scan for invalid digits. */
- const char *p = s;
+ char const *p = s;
for (;;)
{
unsigned int c = *p++;
has enough digits, because the algorithm is better. The turnover point
depends on the value. */
static bool
-print_factors (const char *input)
+print_factors (char const *input)
{
/* Skip initial spaces and '+'. */
char const *str = input;
/* Static attributes determined during input. */
- const char *text; /* the text of the word */
+ char const *text; /* the text of the word */
int length; /* length of this word */
int space; /* the size of the following space */
unsigned int paren:1; /* starts with open paren */
static bool uniform;
/* Prefix minus leading and trailing spaces (default ""). */
-static const char *prefix;
+static char const *prefix;
/* User-supplied maximum line width (default WIDTH). The only output
lines longer than this will each comprise a single word. */
static int
copy_rest (FILE *f, int c)
{
- const char *s;
+ char const *s;
out_column = 0;
if (in_column > next_prefix_indent || (c != '\n' && c != EOF))
prefix_lead_space : in_column;
else
{
- const char *p;
+ char const *p;
next_prefix_indent = in_column;
for (p = prefix; *p != '\0'; p++)
{
static void
put_word (WORD *w)
{
- const char *s;
+ char const *s;
int n;
s = w->text;
/* Print all of the distinct groups the user is in. */
extern bool
-print_group_list (const char *username,
+print_group_list (char const *username,
uid_t ruid, gid_t rgid, gid_t egid,
bool use_names, char delim)
{
along with this program. If not, see <https://www.gnu.org/licenses/>. */
bool print_group (gid_t, bool);
-bool print_group_list (const char *, uid_t, gid_t, gid_t, bool, char);
+bool print_group_list (char const *, uid_t, gid_t, gid_t, bool, char);
}
static void
-write_header (const char *filename)
+write_header (char const *filename)
{
static bool first_file = true;
Return true upon success.
Give a diagnostic and return false upon error. */
static bool
-elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t n_elide_0,
+elide_tail_bytes_pipe (char const *filename, int fd, uintmax_t n_elide_0,
off_t current_pos)
{
size_t n_elide = n_elide_0;
the length determination and the actual reading, then head fails. */
static bool
-elide_tail_bytes_file (const char *filename, int fd, uintmax_t n_elide,
+elide_tail_bytes_file (char const *filename, int fd, uintmax_t n_elide,
struct stat const *st, off_t current_pos)
{
off_t size = st->st_size;
adding them as needed. Return true if successful. */
static bool
-elide_tail_lines_pipe (const char *filename, int fd, uintmax_t n_elide,
+elide_tail_lines_pipe (char const *filename, int fd, uintmax_t n_elide,
off_t current_pos)
{
struct linebuffer
Unfortunately, factoring out some common core looks like it'd result
in a less efficient implementation or a messy interface. */
static bool
-elide_tail_lines_seekable (const char *pretty_filename, int fd,
+elide_tail_lines_seekable (char const *pretty_filename, int fd,
uintmax_t n_lines,
off_t start_pos, off_t size)
{
Give a diagnostic and return nonzero upon error. */
static bool
-elide_tail_lines_file (const char *filename, int fd, uintmax_t n_elide,
+elide_tail_lines_file (char const *filename, int fd, uintmax_t n_elide,
struct stat const *st, off_t current_pos)
{
off_t size = st->st_size;
}
static bool
-head_bytes (const char *filename, int fd, uintmax_t bytes_to_write)
+head_bytes (char const *filename, int fd, uintmax_t bytes_to_write)
{
char buffer[BUFSIZ];
size_t bytes_to_read = BUFSIZ;
}
static bool
-head_lines (const char *filename, int fd, uintmax_t lines_to_write)
+head_lines (char const *filename, int fd, uintmax_t lines_to_write)
{
char buffer[BUFSIZ];
}
static bool
-head (const char *filename, int fd, uintmax_t n_units, bool count_lines,
+head (char const *filename, int fd, uintmax_t n_units, bool count_lines,
bool elide_from_end)
{
if (print_headers)
}
static bool
-head_file (const char *filename, uintmax_t n_units, bool count_lines,
+head_file (char const *filename, uintmax_t n_units, bool count_lines,
bool elide_from_end)
{
int fd;
of lines. It is used solely to give a more specific diagnostic. */
static uintmax_t
-string_to_integer (bool count_lines, const char *n_string)
+string_to_integer (bool count_lines, char const *n_string)
{
return xdectoumax (n_string, 0, UINTMAX_MAX, "bkKmMGTPEZY0",
count_lines ? _("invalid number of lines")
static char *context = NULL;
static void print_user (uid_t uid);
-static void print_full_info (const char *username);
-static void print_stuff (const char *pw_name);
+static void print_full_info (char const *username);
+static void print_stuff (char const *pw_name);
static struct option const longopts[] =
{
for (; optind < n_ids; optind++)
{
struct passwd *pwd = NULL;
- const char *spec = argv[optind];
+ 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. */
/* Print all of the info about the user's user and group IDs. */
static void
-print_full_info (const char *username)
+print_full_info (char const *username)
{
struct passwd *pwd;
struct group *grp;
/* Print information about the user based on the arguments passed. */
static void
-print_stuff (const char *pw_name)
+print_stuff (char const *pw_name)
{
if (just_user)
print_user (use_real ? ruid : euid);
/* Return true if copy of file SRC_NAME to file DEST_NAME is necessary. */
static bool
-need_copy (const char *src_name, const char *dest_name,
+need_copy (char const *src_name, char const *dest_name,
const struct cp_options *x)
{
struct stat src_sb, dest_sb;
Return true if successful. */
static bool
-copy_file (const char *from, const char *to, const struct cp_options *x)
+copy_file (char const *from, char const *to, const struct cp_options *x)
{
bool copy_into_self;
Return true if successful. */
static bool
-install_file_in_file (const char *from, const char *to,
+install_file_in_file (char const *from, char const *to,
const struct cp_options *x)
{
struct stat from_sb;
Return true if successful. */
static bool
-install_file_in_dir (const char *from, const char *to_dir,
+install_file_in_dir (char const *from, char const *to_dir,
const struct cp_options *x, bool mkdir_and_install)
{
- const char *from_base = last_component (from);
+ char const *from_base = last_component (from);
char *to = file_name_concat (to_dir, from_base, NULL);
bool ret = true;
{
int optc;
int exit_status = EXIT_SUCCESS;
- const char *specified_mode = NULL;
+ char const *specified_mode = NULL;
bool make_backups = false;
char const *backup_suffix = NULL;
char *version_control_string = NULL;
If S is valid, return true. Otherwise, give a diagnostic and exit. */
static void
-decode_field_spec (const char *s, int *file_index, size_t *field_index)
+decode_field_spec (char const *s, int *file_index, size_t *field_index)
{
/* The first character must be 0, 1, or 2. */
switch (s[0])
However I think it's just a buggy implementation due to the various
inconsistencies with write sizes and subsequent writes. */
-static const char *
+static char const *
fileno_to_name (const int fd)
{
- const char *ret = NULL;
+ char const *ret = NULL;
switch (fd)
{
}
static void
-apply_mode (FILE *stream, const char *mode)
+apply_mode (FILE *stream, char const *mode)
{
char *buf = NULL;
int setvbuf_mode;
The result is malloced. */
static char *
-convert_abs_rel (const char *from, const char *target)
+convert_abs_rel (char const *from, char const *target)
{
/* Get dirname to generate paths relative to. We don't resolve
the full TARGET as the last component could be an existing symlink. */
struct bin_str
{
size_t len; /* Number of bytes */
- const char *string; /* Pointer to the same */
+ char const *string; /* Pointer to the same */
};
#if ! HAVE_TCGETPGRP
bool symlink_target);
static bool print_color_indicator (const struct bin_str *ind);
static void put_indicator (const struct bin_str *ind);
-static void add_ignore_pattern (const char *pattern);
-static void attach (char *dest, const char *dirname, const char *name);
+static void add_ignore_pattern (char const *pattern);
+static void attach (char *dest, char const *dirname, char const *name);
static void clear_files (void);
static void extract_dirs_from_files (char const *dirname,
bool command_line_arg);
static void getenv_quoting_style (void);
-static size_t quote_name_width (const char *name,
+static size_t quote_name_width (char const *name,
struct quoting_options const *options,
int needs_general_quoting);
C_CLR_TO_EOL
};
-static const char *const indicator_name[]=
+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",
struct ignore_pattern
{
- const char *pattern;
+ char const *pattern;
struct ignore_pattern *next;
};
a space-separated list of the integers stored in OS all on one line. */
static void
-dired_dump_obstack (const char *prefix, struct obstack *os)
+dired_dump_obstack (char const *prefix, struct obstack *os)
{
size_t n_pos;
}
static int
-do_statx (int fd, const char *name, struct stat *st, int flags,
+do_statx (int fd, char const *name, struct stat *st, int flags,
unsigned int mask)
{
struct statx stx;
}
static inline int
-do_stat (const char *name, struct stat *st)
+do_stat (char const *name, struct stat *st)
{
return do_statx (AT_FDCWD, name, st, 0, calc_req_mask ());
}
static inline int
-do_lstat (const char *name, struct stat *st)
+do_lstat (char const *name, struct stat *st)
{
return do_statx (AT_FDCWD, name, st, AT_SYMLINK_NOFOLLOW, calc_req_mask ());
}
static inline int
-stat_for_mode (const char *name, struct stat *st)
+stat_for_mode (char const *name, struct stat *st)
{
return do_statx (AT_FDCWD, name, st, 0, STATX_MODE);
}
/* dev+ino should be static, so no need to sync with backing store */
static inline int
-stat_for_ino (const char *name, struct stat *st)
+stat_for_ino (char const *name, struct stat *st)
{
return do_statx (AT_FDCWD, name, st, 0, STATX_INO);
}
}
#else
static inline int
-do_stat (const char *name, struct stat *st)
+do_stat (char const *name, struct stat *st)
{
return stat (name, st);
}
static inline int
-do_lstat (const char *name, struct stat *st)
+do_lstat (char const *name, struct stat *st)
{
return lstat (name, st);
}
static inline int
-stat_for_mode (const char *name, struct stat *st)
+stat_for_mode (char const *name, struct stat *st)
{
return stat (name, st);
}
static inline int
-stat_for_ino (const char *name, struct stat *st)
+stat_for_ino (char const *name, struct stat *st)
{
return stat (name, st);
}
the input string, respectively. */
static bool
-get_funky_string (char **dest, const char **src, bool equals_end,
+get_funky_string (char **dest, char const **src, bool equals_end,
size_t *output_count)
{
char num; /* For numerical codes */
enum {
ST_GND, ST_BACKSLASH, ST_OCTAL, ST_HEX, ST_CARET, ST_END, ST_ERROR
} state;
- const char *p;
+ char const *p;
char *q;
p = *src; /* We don't want to double-indirect */
static void
parse_ls_color (void)
{
- const char *p; /* Pointer to character being parsed */
+ char const *p; /* Pointer to character being parsed */
char *buf; /* color_buf buffer pointer */
int ind_no; /* Indicator number */
char label[3]; /* Indicator label */
if (format == long_format || print_block_size)
{
- const char *p;
+ char const *p;
char buf[LONGEST_HUMAN_READABLE + 1];
DIRED_INDENT ();
not listed. */
static void
-add_ignore_pattern (const char *pattern)
+add_ignore_pattern (char const *pattern)
{
struct ignore_pattern *ignore;
This is so we don't try to recurse on '././././. ...' */
static bool
-basename_is_dot_or_dotdot (const char *name)
+basename_is_dot_or_dotdot (char const *name)
{
char const *base = last_component (name);
return dot_or_dotdot (base);
}
static size_t
-quote_name_width (const char *name, struct quoting_options const *options,
+quote_name_width (char const *name, struct quoting_options const *options,
int needs_general_quoting)
{
char smallbuf[BUFSIZ];
/* %XX escape any input out of range as defined in RFC3986,
and also if PATH, convert all path separators to '/'. */
static char *
-file_escape (const char *str, bool path)
+file_escape (char const *str, bool path)
{
char *esc = xnmalloc (3, strlen (str) + 1);
char *p = esc;
non-malloc'ing version of file_name_concat. */
static void
-attach (char *dest, const char *dirname, const char *name)
+attach (char *dest, char const *dirname, char const *name)
{
- const char *dirnamep = dirname;
+ char const *dirnamep = dirname;
/* Copy dirname if it is not ".". */
if (dirname[0] != '.' || dirname[1] != 0)
Return true if successful. */
static bool
-digest_file (const char *filename, int *binary, unsigned char *bin_result,
+digest_file (char const *filename, int *binary, unsigned char *bin_result,
bool *missing)
{
FILE *fp;
}
static bool
-digest_check (const char *checkfile_name)
+digest_check (char const *checkfile_name)
{
FILE *checkfile_stream;
uintmax_t n_misformatted_lines = 0;
int
main (int argc, char **argv)
{
- const char *specified_mode = NULL;
+ char const *specified_mode = NULL;
int optc;
char const *scontext = NULL;
struct mkdir_options options;
proper_name ("Jim Meyering"), \
proper_name ("Eric Blake")
-static const char *default_template = "tmp.XXXXXXXXXX";
+static char const *default_template = "tmp.XXXXXXXXXX";
/* For long options that have no equivalent short option, use a
non-character as a pseudo short option, starting with CHAR_MAX + 1. */
}
static size_t
-count_consecutive_X_s (const char *s, size_t len)
+count_consecutive_X_s (char const *s, size_t len)
{
size_t n = 0;
for ( ; len && s[len-1] == 'X'; len--)
Return true if successful. */
static bool
-do_move (const char *source, const char *dest, const struct cp_options *x)
+do_move (char const *source, char const *dest, const struct cp_options *x)
{
bool copy_into_self;
bool rename_succeeded;
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 const char *suffix = NULL;
+static char const *suffix = NULL;
static uintmax_t from_unit_size = 1;
static uintmax_t to_unit_size = 1;
static int grouping = 0;
static long int padding_width = 0;
static long int zero_padding_width = 0;
static long int user_precision = -1;
-static const char *format_str = NULL;
+static char const *format_str = NULL;
static char *format_str_prefix = NULL;
static char *format_str_suffix = NULL;
static bool debug;
/* will be set according to the current locale. */
-static const char *decimal_point;
+static char const *decimal_point;
static int decimal_point_length;
/* debugging for developers. Enables devmsg(). */
static inline int
valid_suffix (const char suf)
{
- static const char *valid_suffixes = "KMGTPEZY";
+ static char const *valid_suffixes = "KMGTPEZY";
return (strchr (valid_suffixes, suf) != NULL);
}
}
}
-static inline const char *
+static inline char const *
suffix_power_char (unsigned int power)
{
switch (power)
SSE_OVERFLOW - if more than 27 digits (999Y) were used.
SSE_INVALID_NUMBER - if no digits were found. */
static enum simple_strtod_error
-simple_strtod_int (const char *input_str,
+simple_strtod_int (char const *input_str,
char **endptr, long double *value, bool *negative)
{
enum simple_strtod_error e = SSE_OK;
SSE_OVERFLOW - if more than 27 digits (999Y) were used.
SSE_INVALID_NUMBER - if no digits were found. */
static enum simple_strtod_error
-simple_strtod_float (const char *input_str,
+simple_strtod_float (char const *input_str,
char **endptr,
long double *value,
size_t *precision)
SSE_INVALID_SUFFIX
SSE_MISSING_I_SUFFIX */
static enum simple_strtod_error
-simple_strtod_human (const char *input_str,
+simple_strtod_human (char const *input_str,
char **endptr, long double *value, size_t *precision,
enum scale_type allowed_scaling)
{
Upon successful conversion, return that value.
If it cannot be converted, give a diagnostic and exit. */
static uintmax_t
-unit_to_umax (const char *n_string)
+unit_to_umax (char const *n_string)
{
strtol_error s_err;
- const char *c_string = n_string;
+ char const *c_string = n_string;
char *t_string = NULL;
size_t n_len = strlen (n_string);
char *end = NULL;
uintmax_t n;
- const char *suffixes = "KMGTPEZY";
+ char const *suffixes = "KMGTPEZY";
/* Adjust suffixes so K=1000, Ki=1024, KiB=invalid. */
if (n_len && ! c_isdigit (n_string[n_len - 1]))
If there are any trailing characters after the number
(besides a valid suffix) - exits with an error. */
static enum simple_strtod_error
-parse_human_number (const char *str, long double /*output */ *value,
+parse_human_number (char const *str, long double /*output */ *value,
size_t *precision)
{
char *ptr = NULL;
char b[sizeof (T)]; \
} u; \
for (j = 0; j < sizeof (T); j++) \
- u.b[j] = ((const char *) p)[sizeof (T) - 1 - j]; \
+ u.b[j] = ((char const *) p)[sizeof (T) - 1 - j]; \
x = u.x; \
} \
else \
#undef PRINT_FLOATTYPE
static void
-dump_hexl_mode_trailer (size_t n_bytes, const char *block)
+dump_hexl_mode_trailer (size_t n_bytes, char const *block)
{
fputs (" >", stdout);
for (size_t i = n_bytes; i > 0; i--)
static void
print_named_ascii (size_t fields, size_t blank, void const *block,
- const char *unused_fmt_string _GL_UNUSED,
+ char const *unused_fmt_string _GL_UNUSED,
int width, int pad)
{
unsigned char const *p = block;
{
int next_pad = pad * (i - 1) / fields;
int masked_c = *p++ & 0x7f;
- const char *s;
+ char const *s;
char buf[2];
if (masked_c == 127)
static void
print_ascii (size_t fields, size_t blank, void const *block,
- const char *unused_fmt_string _GL_UNUSED, int width,
+ char const *unused_fmt_string _GL_UNUSED, int width,
int pad)
{
unsigned char const *p = block;
{
int next_pad = pad * (i - 1) / fields;
unsigned char c = *p++;
- const char *s;
+ char const *s;
char buf[4];
switch (c)
the result of the conversion and return true. */
static bool
-simple_strtoul (const char *s, const char **p, unsigned long int *val)
+simple_strtoul (char const *s, char const **p, unsigned long int *val)
{
unsigned long int sum;
*/
static bool
-decode_one_format (const char *s_orig, const char *s, const char **next,
+decode_one_format (char const *s_orig, char const *s, char const **next,
struct tspec *tspec)
{
enum size_spec size_spec;
enum output_format fmt;
void (*print_function) (size_t, size_t, void const *, char const *,
int, int);
- const char *p;
+ char const *p;
char c;
int field_width;
necessary. Return true if S is valid. */
static bool
-decode_format_string (const char *s)
+decode_format_string (char const *s)
{
- const char *s_orig = s;
+ char const *s_orig = s;
assert (s != NULL);
while (*s != '\0')
{
- const char *next;
+ char const *next;
if (n_specs_allocated <= n_specs)
spec = X2NREALLOC (spec, &n_specs_allocated);
static void
write_block (uintmax_t current_offset, size_t n_bytes,
- const char *prev_block, const char *curr_block)
+ char const *prev_block, char const *curr_block)
{
static bool first = true;
static bool prev_pair_equal = false;
leading '+' return true and set *OFFSET to the offset it denotes. */
static bool
-parse_old_offset (const char *s, uintmax_t *offset)
+parse_old_offset (char const *s, uintmax_t *offset)
{
int radix;
/* Count and return the number of ampersands in STR. */
static size_t _GL_ATTRIBUTE_PURE
-count_ampersands (const char *str)
+count_ampersands (char const *str)
{
size_t count = 0;
do
this function. */
static char *
-create_fullname (const char *gecos_name, const char *user_name)
+create_fullname (char const *gecos_name, char const *user_name)
{
size_t rsize = strlen (gecos_name) + 1;
char *result;
{
if (*gecos_name == '&')
{
- const char *uname = user_name;
+ char const *uname = user_name;
if (islower (to_uchar (*uname)))
*r++ = toupper (to_uchar (*uname++));
while (*uname)
/* Return a string representing the time between WHEN and the time
that this function is first run. */
-static const char *
+static char const *
idle_string (time_t when)
{
static time_t now = 0;
}
/* Return a time string. */
-static const char *
+static char const *
time_string (const STRUCT_UTMP *utmp_ent)
{
static char buf[INT_STRLEN_BOUND (intmax_t) + sizeof "-%m-%d %H:%M"];
{
FILE *stream;
char buf[1024];
- const char *const baseproject = "/.project";
+ char const *const baseproject = "/.project";
char *const project =
xmalloc (strlen (pw->pw_dir) + strlen (baseproject) + 1);
stpcpy (stpcpy (project, pw->pw_dir), baseproject);
{
FILE *stream;
char buf[1024];
- const char *const baseplan = "/.plan";
+ char const *const baseplan = "/.plan";
char *const plan =
xmalloc (strlen (pw->pw_dir) + strlen (baseplan) + 1);
stpcpy (stpcpy (plan, pw->pw_dir), baseplan);
/* Display a list of who is on the system, according to utmp file FILENAME. */
static void
-short_pinky (const char *filename,
+short_pinky (char const *filename,
const int argc_names, char *const argv_names[])
{
size_t n_users;
static void print_header (void);
static void pad_across_to (int position);
static void add_line_number (COLUMN *p);
-static void getoptnum (const char *n_str, int min, int *num,
- const char *errfmt);
+static void getoptnum (char const *n_str, int min, int *num,
+ char const *errfmt);
static void getoptarg (char *arg, char switch_char, char *character,
int *number);
static void print_files (int number_of_files, char **av);
static void print_char (char c);
static void cleanup (void);
static void print_sep_string (void);
-static void separator_string (const char *optarg_S);
+static void separator_string (char const *optarg_S);
/* All of the columns to print. */
static COLUMN *column_vector;
/* Estimate length of col_sep_string with option -S. */
static void
-separator_string (const char *optarg_S)
+separator_string (char const *optarg_S)
{
size_t len = strlen (optarg_S);
if (INT_MAX < len)
/* Parse numeric arguments, ensuring MIN <= number <= INT_MAX. */
static void
-getoptnum (const char *n_str, int min, int *num, const char *err)
+getoptnum (char const *n_str, int min, int *num, char const *err)
{
intmax_t tnum = xdectoimax (n_str, min, INT_MAX, "", err, 0);
*num = tnum;
}
static void
-verify_numeric (const char *s, const char *end)
+verify_numeric (char const *s, char const *end)
{
if (errno)
{
is an octal digit; otherwise they are of the form \ooo. */
static int
-print_esc (const char *escstart, bool octal_0)
+print_esc (char const *escstart, bool octal_0)
{
- const char *p = escstart + 1;
+ char const *p = escstart + 1;
int esc_value = 0; /* Value of \nnn escape. */
int esc_length; /* Length of \nnn escape. */
/* Print string STR, evaluating \ escapes. */
static void
-print_esc_string (const char *str)
+print_esc_string (char const *str)
{
for (; *str; str++)
if (*str == '\\')
be formatted. */
static void
-print_direc (const char *start, size_t length, char conversion,
+print_direc (char const *start, size_t length, char conversion,
bool have_field_width, int field_width,
bool have_precision, int precision,
char const *argument)
Return the number of elements of ARGV used. */
static int
-print_formatted (const char *format, int argc, char **argv)
+print_formatted (char const *format, int argc, char **argv)
{
int save_argc = argc; /* Preserve original value. */
- const char *f; /* Pointer into 'format'. */
- const char *direc_start; /* Start of % directive. */
+ char const *f; /* Pointer into 'format'. */
+ char const *direc_start; /* Start of % directive. */
size_t direc_length; /* Length of % directive. */
bool have_field_width; /* True if FIELD_WIDTH is valid. */
int field_width = 0; /* Arg to first '*'. */
static bool right_reference = false; /* output refs after right context */
static ptrdiff_t line_width = 72; /* output line width in characters */
static ptrdiff_t gap_size = 3; /* number of spaces between output fields */
-static const char *truncation_string = "/";
+static char const *truncation_string = "/";
/* string used to mark line truncations */
-static const char *macro_name = "xx"; /* macro name for roff or TeX output */
+static char const *macro_name = "xx"; /* macro name for roff or TeX output */
static enum Format output_format = UNKNOWN_FORMAT;
/* output format */
static bool ignore_case = false; /* fold lower to upper for sorting */
-static const char *break_file = NULL; /* name of the 'Break chars' file */
-static const char *only_file = NULL; /* name of the 'Only words' file */
-static const char *ignore_file = NULL; /* name of the 'Ignore words' file */
+static char const *break_file = NULL; /* name of the 'Break chars' file */
+static char const *only_file = NULL; /* name of the 'Only words' file */
+static char const *ignore_file = NULL; /* name of the 'Ignore words' file */
/* Options that use regular expressions. */
struct regex_data
static int number_input_files; /* number of text input files */
static intmax_t total_line_count; /* total number of lines seen so far */
-static const char **input_file_name; /* array of text input file names */
+static char const **input_file_name; /* array of text input file names */
static intmax_t *file_line_count; /* array of line count values at end */
static BLOCK *text_buffers; /* files to study */
/* Loosely adapted from GNU sh-utils printf.c code. */
static char *
-copy_unescaped_string (const char *string)
+copy_unescaped_string (char const *string)
{
char *result; /* allocated result */
char *cursor; /* cursor in result */
`------------------------------------------------------------------------*/
static void
-swallow_file_in_memory (const char *file_name, BLOCK *block)
+swallow_file_in_memory (char const *file_name, BLOCK *block)
{
size_t used_length; /* used length in memory buffer */
`----------------------------------------------------------------------*/
static void
-digest_break_file (const char *file_name)
+digest_break_file (char const *file_name)
{
BLOCK file_contents; /* to receive a copy of the file */
char *cursor; /* cursor in file copy */
`-----------------------------------------------------------------------*/
static void
-digest_word_file (const char *file_name, WORD_TABLE *table)
+digest_word_file (char const *file_name, WORD_TABLE *table)
{
BLOCK file_contents; /* to receive a copy of the file */
char *cursor; /* cursor in file copy */
intmax_t line_ordinal; /* line ordinal value for reference */
ptrdiff_t reference_width; /* width for the whole reference */
int character; /* character ordinal */
- const char *cursor; /* cursor in some constant strings */
+ char const *cursor; /* cursor in some constant strings */
/* In auto reference mode, the maximum width of this field is
precomputed and subtracted from the overall line width. Add one for
char *left_context_start; /* start of left context */
char *right_context_end; /* end of right context */
char *left_field_start; /* conservative start for 'head'/'before' */
- const char *file_name; /* file name for reference */
+ char const *file_name; /* file name for reference */
intmax_t line_ordinal; /* line ordinal for reference */
- const char *buffer_start; /* start of buffered file for this occurs */
- const char *buffer_end; /* end of buffered file for this occurs */
+ char const *buffer_start; /* start of buffered file for this occurs */
+ char const *buffer_end; /* end of buffered file for this occurs */
/* Define 'keyafter', start of left context and end of right context.
'keyafter' starts at the saved position for keyword and extend to the
for (; optind < argc; ++optind)
{
- const char *fname = argv[optind];
+ char const *fname = argv[optind];
char *value = (can_mode != -1
? canonicalize_filename_mode (fname, can_mode)
: areadlink_with_size (fname, 63));
static bool verbose = true;
static bool logical;
static bool use_nuls;
-static const char *can_relative_to;
-static const char *can_relative_base;
+static char const *can_relative_to;
+static char const *can_relative_base;
static struct option const longopts[] =
{
/* A wrapper around canonicalize_filename_mode(),
to call it twice when in LOGICAL mode. */
static char *
-realpath_canon (const char *fname, int can_mode)
+realpath_canon (char const *fname, int can_mode)
{
char *can_fname = canonicalize_filename_mode (fname, can_mode);
if (logical && can_fname) /* canonicalize again to resolve symlinks. */
/* Test whether canonical prefix is parent or match of path. */
static bool _GL_ATTRIBUTE_PURE
-path_prefix (const char *prefix, const char *path)
+path_prefix (char const *prefix, char const *path)
{
/* We already know prefix[0] and path[0] are '/'. */
prefix++;
}
static bool
-isdir (const char *path)
+isdir (char const *path)
{
struct stat sb;
if (stat (path, &sb) != 0)
}
static bool
-process_path (const char *fname, int can_mode)
+process_path (char const *fname, int can_mode)
{
char *can_fname = realpath_canon (fname, can_mode);
if (!can_fname)
{
bool ok = true;
int can_mode = CAN_ALL_BUT_LAST;
- const char *relative_to = NULL;
- const char *relative_base = NULL;
+ char const *relative_to = NULL;
+ char const *relative_base = NULL;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
of canonical PATH1 and PATH2, ensuring only full path components
are matched. Return 0 on no match. */
static int _GL_ATTRIBUTE_PURE
-path_common_prefix (const char *path1, const char *path2)
+path_common_prefix (char const *path1, char const *path2)
{
int i = 0;
int ret = 0;
/* Output the relative representation if possible.
If BUF is non-NULL, write to that buffer rather than to stdout. */
bool
-relpath (const char *can_fname, const char *can_reldir, char *buf, size_t len)
+relpath (char const *can_fname, char const *can_reldir, char *buf, size_t len)
{
bool buf_err = false;
if (!common_index)
return false;
- const char *relto_suffix = can_reldir + common_index;
- const char *fname_suffix = can_fname + common_index;
+ char const *relto_suffix = can_reldir + common_index;
+ char const *fname_suffix = can_fname + common_index;
/* Skip over extraneous '/'. */
if (*relto_suffix == '/')
# define _RELPATH_H
extern bool
-relpath (const char *can_fname, const char *can_reldir, char *buf, size_t len);
+relpath (char const *can_fname, char const *can_reldir, char *buf, size_t len);
#endif
char *scon = NULL;
char *tcon = NULL;
context_t scontext = 0, tcontext = 0;
- const char *contype;
+ char const *contype;
char *constr;
char *newpath = NULL;
char *scon = NULL;
char *tcon = NULL;
context_t scontext = 0, tcontext = 0;
- const char *contype;
+ char const *contype;
char *constr;
int fd;
Return if the string is correct else signal error. */
static operand
-scan_arg (const char *arg)
+scan_arg (char const *arg)
{
operand ret;
{ .lo = UINTMAX_MAX, .hi = UINTMAX_MAX } ];
*/
void
-set_fields (const char *fieldstr, unsigned int options)
+set_fields (char const *fieldstr, unsigned int options)
{
uintmax_t initial = 1; /* Value of first number in a range. */
uintmax_t value = 0; /* If nonzero, a number being accumulated. */
};
/* allocates and initializes the FRP array and N_FRP count */
-extern void set_fields (const char *fieldstr, unsigned int options);
+extern void set_fields (char const *fieldstr, unsigned int options);
/* frees memory allocated by set_fields() */
extern void reset_fields (void);
for (int i = optind; i < argc; i++)
{
double s;
- const char *p;
+ char const *p;
if (! (xstrtod (argv[i], &p, &s, cl_strtod) || errno == ERANGE)
/* Nonnegative interval. */
|| ! (0 <= s)
This can be used safely from signal handlers,
and between fork and exec of multithreaded processes. */
-static void async_safe_die (int, const char *) ATTRIBUTE_NORETURN;
+static void async_safe_die (int, char const *) ATTRIBUTE_NORETURN;
static void
-async_safe_die (int errnum, const char *errstr)
+async_safe_die (int errnum, char const *errstr)
{
ignore_value (write (STDERR_FILENO, errstr, strlen (errstr)));
static char const *suffix_alphabet = "abcdefghijklmnopqrstuvwxyz";
/* Numerical suffix start value. */
-static const char *numeric_suffix_start;
+static char const *numeric_suffix_start;
/* Additional suffix to append to output file names. */
static char const *additional_suffix;
/* Create or truncate a file. */
static int
-create (const char *name)
+create (char const *name)
{
if (!filter_command)
{
Return true if successful. */
static bool
-cwrite (bool new_file_flag, const char *bp, size_t bytes)
+cwrite (bool new_file_flag, char const *bp, size_t bytes)
{
if (new_file_flag)
{
int flags = 0;
struct stat st;
struct statx stx = { 0, };
- const char *pathname = filename;
+ char const *pathname = filename;
struct print_args pa;
pa.st = &st;
pa.btime = (struct timespec) {-1, -1};
dladdr(), pstat_getpathname(), etc. */
static void
-set_program_path (const char *arg)
+set_program_path (char const *arg)
{
if (strchr (arg, '/')) /* Use absolute or relative paths directly. */
{
/* Each mode. */
struct mode_info
{
- const char *name; /* Name given on command line. */
+ char const *name; /* Name given on command line. */
enum mode_type type; /* Which structure element to change. */
char flags; /* Setting and display options. */
unsigned long bits; /* Bits to set for this mode. */
/* Control character settings. */
struct control_info
{
- const char *name; /* Name given on command line. */
+ char const *name; /* Name given on command line. */
cc_t saneval; /* Value to set for 'stty sane'. */
size_t offset; /* Offset in c_cc. */
};
static int screen_columns (void);
static bool set_mode (struct mode_info const *info, bool reversed,
struct termios *mode);
-static unsigned long int integer_arg (const char *s, unsigned long int max);
-static speed_t string_to_baud (const char *arg);
+static unsigned long int integer_arg (char const *s, unsigned long int max);
+static speed_t string_to_baud (char const *arg);
static tcflag_t *mode_type_flag (enum mode_type type, struct termios *mode);
static void display_all (struct termios *mode, char const *device_name);
static void display_changed (struct termios *mode);
static void display_recoverable (struct termios *mode);
static void display_settings (enum output_type output_type,
struct termios *mode,
- const char *device_name);
+ char const *device_name);
static void display_speed (struct termios *mode, bool fancy);
static void display_window_size (bool fancy, char const *device_name);
static void sane_mode (struct termios *mode);
static void set_control_char (struct control_info const *info,
- const char *arg,
+ char const *arg,
struct termios *mode);
-static void set_speed (enum speed_setting type, const char *arg,
+static void set_speed (enum speed_setting type, char const *arg,
struct termios *mode);
static void set_window_size (int rows, int cols, char const *device_name);
{NULL, 0, NULL, 0}
};
-static void wrapf (const char *message, ...)
+static void wrapf (char const *message, ...)
__attribute__ ((__format__ (__printf__, 1, 2)));
/* Print format string MESSAGE and optional args.
Print a space first unless MESSAGE will start a new line. */
static void
-wrapf (const char *message,...)
+wrapf (char const *message,...)
{
va_list args;
char *buf;
with a device, and only validates specified settings. */
static void
-apply_settings (bool checking, const char *device_name,
+apply_settings (bool checking, char const *device_name,
char * const *settings, int n_settings,
struct termios *mode, bool *speed_was_set,
bool *require_set_attr)
bool recoverable_output;
bool noargs = true;
char *file_name = NULL;
- const char *device_name;
+ char const *device_name;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
}
static void
-set_control_char (struct control_info const *info, const char *arg,
+set_control_char (struct control_info const *info, char const *arg,
struct termios *mode)
{
unsigned long int value;
}
static void
-set_speed (enum speed_setting type, const char *arg, struct termios *mode)
+set_speed (enum speed_setting type, char const *arg, struct termios *mode)
{
speed_t baud;
struct speed_map
{
- const char *string; /* ASCII representation. */
+ char const *string; /* ASCII representation. */
speed_t speed; /* Internal form. */
unsigned long int value; /* Numeric value. */
};
};
static speed_t _GL_ATTRIBUTE_PURE
-string_to_baud (const char *arg)
+string_to_baud (char const *arg)
{
for (int i = 0; speeds[i].string != NULL; ++i)
if (STREQ (arg, speeds[i].string))
/* Return a string that is the printable representation of character CH. */
/* Adapted from 'cat' by Torbjorn Granlund. */
-static const char *
+static char const *
visible (cc_t ch)
{
static char buf[10];
*bpout++ = ch + 64;
}
*bpout = '\0';
- return (const char *) buf;
+ return (char const *) buf;
}
/* Parse string S as an integer, using decimal radix by default,
larger than MAXVAL. */
static unsigned long int
-integer_arg (const char *s, unsigned long int maxval)
+integer_arg (char const *s, unsigned long int maxval)
{
return xnumtoumax (s, 0, 0, maxval, "bB", _("invalid integer argument"), 0);
}
Return true if successful. */
static bool
-bsd_sum_file (const char *file, int print_name)
+bsd_sum_file (char const *file, int print_name)
{
FILE *fp;
int checksum = 0; /* The checksum mod 2^16. */
Return true if successful. */
static bool
-sysv_sum_file (const char *file, int print_name)
+sysv_sum_file (char const *file, int print_name)
{
int fd;
unsigned char buf[8192];
bool ok;
int optc;
int files_given;
- bool (*sum_func) (const char *, int) = bsd_sum_file;
+ bool (*sum_func) (char const *, int) = bsd_sum_file;
initialize_main (&argc, &argv);
set_program_name (argv[0]);
# define ASSIGN_STRDUPA(DEST, S) \
do \
{ \
- const char *s_ = (S); \
+ char const *s_ = (S); \
size_t len_ = strlen (s_) + 1; \
char *tmp_dest_ = alloca (len_); \
DEST = memcpy (tmp_dest_, s_, len_); \
/* Don't output this redundant message for English locales.
Note we still output for 'C' so that it gets included in the man page. */
- const char *lc_messages = setlocale (LC_MESSAGES, NULL);
+ char const *lc_messages = setlocale (LC_MESSAGES, NULL);
if (lc_messages && STRNCMP_LIT (lc_messages, "en_"))
{
/* TRANSLATORS: Replace LANG_CODE in this URL with your language code
If START is NULL, just flush the buffer. */
static void
-output (const char *start, const char *past_end)
+output (char const *start, char const *past_end)
{
static char buffer[WRITESIZE];
static size_t bytes_in_buffer = 0;
Return true if successful. */
static bool
-tac_seekable (int input_fd, const char *file, off_t file_pos)
+tac_seekable (int input_fd, char const *file, off_t file_pos)
{
/* Pointer to the location in 'G_buffer' where the search for
the next separator will begin. */
But this isn't a big deal, since the code is used only on WOE/DOS
systems, and few people invoke tac on that many nonseekable files. */
-static const char *file_to_remove;
+static char const *file_to_remove;
static FILE *fp_to_close;
static void
Return true if successful. */
static bool
-tac_nonseekable (int input_fd, const char *file)
+tac_nonseekable (int input_fd, char const *file)
{
FILE *tmp_stream;
char *tmp_file;
Return true if successful. */
static bool
-tac_file (const char *filename)
+tac_file (char const *filename)
{
bool ok;
off_t file_size;
int
main (int argc, char **argv)
{
- const char *error_message; /* Return value from re_compile_pattern. */
+ char const *error_message; /* Return value from re_compile_pattern. */
int optc;
bool ok;
size_t half_buffer_size;
/* Close the file with descriptor FD and name FILENAME. */
static void
-close_fd (int fd, const char *filename)
+close_fd (int fd, char const *filename)
{
if (fd != -1 && fd != STDIN_FILENO && close (fd))
{
}
static void
-write_header (const char *pretty_filename)
+write_header (char const *pretty_filename)
{
static bool first_file = true;
Return the number of bytes read from the file. */
static uintmax_t
-dump_remainder (bool want_header, const char *pretty_filename, int fd,
+dump_remainder (bool want_header, char const *pretty_filename, int fd,
uintmax_t n_bytes)
{
uintmax_t n_written;
Return true if successful. */
static bool
-file_lines (const char *pretty_filename, int fd, uintmax_t n_lines,
+file_lines (char const *pretty_filename, int fd, uintmax_t n_lines,
off_t start_pos, off_t end_pos, uintmax_t *read_pos)
{
char buffer[BUFSIZ];
Return true if successful. */
static bool
-pipe_lines (const char *pretty_filename, int fd, uintmax_t n_lines,
+pipe_lines (char const *pretty_filename, int fd, uintmax_t n_lines,
uintmax_t *read_pos)
{
struct linebuffer
Return true if successful. */
static bool
-pipe_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes,
+pipe_bytes (char const *pretty_filename, int fd, uintmax_t n_bytes,
uintmax_t *read_pos)
{
struct charbuffer
Return 1 on error, 0 if ok, -1 if EOF. */
static int
-start_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes,
+start_bytes (char const *pretty_filename, int fd, uintmax_t n_bytes,
uintmax_t *read_pos)
{
char buffer[BUFSIZ];
Return 1 on error, 0 if ok, -1 if EOF. */
static int
-start_lines (const char *pretty_filename, int fd, uintmax_t n_lines,
+start_lines (char const *pretty_filename, int fd, uintmax_t n_lines,
uintmax_t *read_pos)
{
if (n_lines == 0)
If fstatfs fails, give a diagnostic and return true.
If fstatfs cannot be called, return true. */
static bool
-fremote (int fd, const char *name)
+fremote (int fd, char const *name)
{
bool remote = true; /* be conservative (poll by default). */
Return true if successful. */
static bool
-tail_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes,
+tail_bytes (char const *pretty_filename, int fd, uintmax_t n_bytes,
uintmax_t *read_pos)
{
struct stat stats;
Return true if successful. */
static bool
-tail_lines (const char *pretty_filename, int fd, uintmax_t n_lines,
+tail_lines (char const *pretty_filename, int fd, uintmax_t n_lines,
uintmax_t *read_pos)
{
struct stat stats;
Return true if successful. */
static bool
-tail (const char *filename, int fd, uintmax_t n_units,
+tail (char const *filename, int fd, uintmax_t n_units,
uintmax_t *read_pos)
{
*read_pos = 0;
static bool
parse_obsolete_option (int argc, char * const *argv, uintmax_t *n_units)
{
- const char *p;
- const char *n_string;
- const char *n_string_end;
+ char const *p;
+ char const *n_string;
+ char const *n_string_end;
int default_count = DEFAULT_N_LINES;
bool t_from_start;
bool t_count_lines = true;
}
static double
-parse_duration (const char *str)
+parse_duration (char const *str)
{
double duration;
- const char *ep;
+ char const *ep;
if (! (xstrtod (str, &ep, &duration, cl_strtod) || errno == ERANGE)
/* Nonnegative interval. */
Return true if successful. */
static bool
-touch (const char *file)
+touch (char const *file)
{
bool ok;
int fd = -1;
/* Each string is held in core as the head of a list of successors. */
struct item
{
- const char *str;
+ char const *str;
struct item *left, *right;
int balance; /* -1, 0, or +1 */
size_t count;
/* Create a new item/node for STR. */
static struct item *
-new_item (const char *str)
+new_item (char const *str)
{
struct item *k = xmalloc (sizeof *k);
Volume 3/Searching and Sorting, pages 455--457. */
static struct item *
-search_item (struct item *root, const char *str)
+search_item (struct item *root, char const *str)
{
struct item *p, *q, *r, *s, *t;
int a;
/* Do a topological sort on FILE. Return true if successful. */
static bool
-tsort (const char *file)
+tsort (char const *file)
{
bool ok = true;
struct item *root;
If either is "-", use the standard I/O stream for it instead. */
static void
-check_file (const char *infile, const char *outfile, char delimiter)
+check_file (char const *infile, char const *outfile, char delimiter)
{
struct linebuffer lb1, lb2;
struct linebuffer *thisline, *prevline;
utmp file. */
static void
-uptime (const char *filename, int options)
+uptime (char const *filename, int options)
{
size_t n_users;
STRUCT_UTMP *utmp_buf = NULL;
Use read_utmp OPTIONS to read FILENAME. */
static void
-users (const char *filename, int options)
+users (char const *filename, int options)
{
size_t n_users;
STRUCT_UTMP *utmp_buf;
uintmax_t chars,
uintmax_t bytes,
uintmax_t linelength,
- const char *file)
+ char const *file)
{
static char const format_sp_int[] = " %*s";
char const *format_int = format_sp_int + 1;
while ((bytes_read = safe_read (fd, buf + prev, BUFFER_SIZE - prev)) > 0)
{
- const char *p;
+ char const *p;
# if SUPPORT_OLD_MBRTOWC
mbstate_t backup_state;
# endif
while ((bytes_read = safe_read (fd, buf, BUFFER_SIZE)) > 0)
{
- const char *p = buf;
+ char const *p = buf;
if (bytes_read == SAFE_READ_ERROR)
{
error (0, errno, "%s", quotef (file));
sprintf (Var, "%ld", (long int) (Utmp_ent->ut_pid))
#else
# define PIDSTR_DECL_AND_INIT(Var, Utmp_ent) \
- const char *Var = ""
+ char const *Var = ""
#endif
#if HAVE_STRUCT_XTMP_UT_ID
/* Return a string representing the time between WHEN and now.
BOOTTIME is the time of last reboot.
FIXME: locale? */
-static const char *
+static char const *
idle_string (time_t when, time_t boottime)
{
static time_t now = TYPE_MINIMUM (time_t);
}
/* Return a time string. */
-static const char *
+static char const *
time_string (const STRUCT_UTMP *utmp_ent)
{
static char buf[INT_STRLEN_BOUND (intmax_t) + sizeof "-%m-%d %H:%M"];
will need tweaking if any of the localization stuff is done, or for 64 bit
pids, etc. */
static void
-print_line (int userlen, const char *user, const char state,
- int linelen, const char *line,
- const char *time_str, const char *idle, const char *pid,
- const char *comment, const char *exitstr)
+print_line (int userlen, char const *user, const char state,
+ int linelen, char const *line,
+ char const *time_str, char const *idle, char const *pid,
+ char const *comment, char const *exitstr)
{
static char mesg[3] = { ' ', 'x', '\0' };
char *buf;
/* Display a list of who is on the system, according to utmp file FILENAME.
Use read_utmp OPTIONS to read the file. */
static void
-who (const char *filename, int options)
+who (char const *filename, int options)
{
size_t n_users;
STRUCT_UTMP *utmp_buf;