From ef772bf97f7ec577754cbb5b278504d83cf41a43 Mon Sep 17 00:00:00 2001 From: =?utf8?q?P=C3=A1draig=20Brady?= Date: Sun, 11 Apr 2021 18:23:21 +0100 Subject: [PATCH] maint: use "char const *" rather than "const char *" * cfg.mk (sc_prohibit-const-char): Add a new syntax-check to enforce this style. * *.[ch]: sed -i 's/const char \*/char const */g' --- cfg.mk | 7 +++++++ gl/lib/mbsalign.c | 6 +++--- gl/lib/mbsalign.h | 4 ++-- gl/lib/smack.h | 2 +- gl/lib/xdectoint.c | 8 +++---- gl/lib/xdectoint.h | 8 +++---- src/basename.c | 8 +++---- src/basenc.c | 36 ++++++++++++++++---------------- src/chgrp.c | 2 +- src/chmod.c | 4 ++-- src/chown-core.c | 4 ++-- src/chown.c | 4 ++-- src/cksum.c | 8 +++---- src/cksum.h | 2 +- src/cksum_pclmul.c | 4 ++-- src/copy.c | 6 +++--- src/copy.h | 2 +- src/coreutils.c | 2 +- src/cp-hash.c | 2 +- src/cp-hash.h | 2 +- src/cp.c | 2 +- src/csplit.c | 8 +++---- src/date.c | 10 ++++----- src/dd.c | 6 +++--- src/df.c | 18 ++++++++-------- src/dircolors.c | 14 ++++++------- src/du.c | 6 +++--- src/env.c | 24 ++++++++++----------- src/expr.c | 8 +++---- src/factor.c | 6 +++--- src/fmt.c | 10 ++++----- src/group-list.c | 2 +- src/group-list.h | 2 +- src/head.c | 22 ++++++++++---------- src/id.c | 10 ++++----- src/install.c | 12 +++++------ src/join.c | 2 +- src/libstdbuf.c | 6 +++--- src/ln.c | 2 +- src/ls.c | 52 +++++++++++++++++++++++----------------------- src/md5sum.c | 4 ++-- src/mkdir.c | 2 +- src/mktemp.c | 4 ++-- src/mv.c | 2 +- src/numfmt.c | 24 ++++++++++----------- src/od.c | 28 ++++++++++++------------- src/pinky.c | 16 +++++++------- src/pr.c | 10 ++++----- src/printf.c | 16 +++++++------- src/ptx.c | 28 ++++++++++++------------- src/readlink.c | 2 +- src/realpath.c | 16 +++++++------- src/relpath.c | 8 +++---- src/relpath.h | 2 +- src/selinux.c | 4 ++-- src/seq.c | 2 +- src/set-fields.c | 2 +- src/set-fields.h | 2 +- src/sleep.c | 2 +- src/sort.c | 4 ++-- src/split.c | 6 +++--- src/stat.c | 2 +- src/stdbuf.c | 2 +- src/stty.c | 36 ++++++++++++++++---------------- src/sum.c | 6 +++--- src/system.h | 4 ++-- src/tac.c | 12 +++++------ src/tail.c | 30 +++++++++++++------------- src/timeout.c | 4 ++-- src/touch.c | 2 +- src/tsort.c | 8 +++---- src/uniq.c | 2 +- src/uptime.c | 2 +- src/users.c | 2 +- src/wc.c | 6 +++--- src/who.c | 16 +++++++------- 76 files changed, 334 insertions(+), 327 deletions(-) diff --git a/cfg.mk b/cfg.mk index d65bda2fde..01bc42c7c7 100644 --- a/cfg.mk +++ b/cfg.mk @@ -325,6 +325,13 @@ sc_prohibit-gl-attributes: 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, diff --git a/gl/lib/mbsalign.c b/gl/lib/mbsalign.c index f23bc31601..74e28ca1b6 100644 --- a/gl/lib/mbsalign.c +++ b/gl/lib/mbsalign.c @@ -109,14 +109,14 @@ mbs_align_pad (char *dest, const char* dest_end, size_t n_spaces) 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; @@ -245,7 +245,7 @@ mbsalign_cleanup: 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. */ diff --git a/gl/lib/mbsalign.h b/gl/lib/mbsalign.h index 05fe302268..4fdcac4191 100644 --- a/gl/lib/mbsalign.h +++ b/gl/lib/mbsalign.h @@ -52,8 +52,8 @@ enum { }; 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); diff --git a/gl/lib/smack.h b/gl/lib/smack.h index b7bbc349d0..92c257a833 100644 --- a/gl/lib/smack.h +++ b/gl/lib/smack.h @@ -29,7 +29,7 @@ smack_new_label_from_self (char **label) } static inline int -smack_set_label_for_self (const char *label) +smack_set_label_for_self (char const *label) { return -1; } diff --git a/gl/lib/xdectoint.c b/gl/lib/xdectoint.c index 95f6c1359d..04f5c7035a 100644 --- a/gl/lib/xdectoint.c +++ b/gl/lib/xdectoint.c @@ -33,8 +33,8 @@ 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; @@ -79,8 +79,8 @@ __xnumtoint (const char *n_str, int base, __xdectoint_t min, __xdectoint_t max, 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); } diff --git a/gl/lib/xdectoint.h b/gl/lib/xdectoint.h index 278af885a6..a1a381240f 100644 --- a/gl/lib/xdectoint.h +++ b/gl/lib/xdectoint.h @@ -21,11 +21,11 @@ # include # 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) diff --git a/src/basename.c b/src/basename.c index a83e3e6e9f..0299af822f 100644 --- a/src/basename.c +++ b/src/basename.c @@ -82,10 +82,10 @@ Examples:\n\ 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); @@ -101,7 +101,7 @@ remove_suffix (char *name, const char *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); @@ -125,7 +125,7 @@ main (int argc, char **argv) { 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]); diff --git a/src/basenc.c b/src/basenc.c index 39299f02c2..7e22363bf4 100644 --- a/src/basenc.c +++ b/src/basenc.c @@ -217,7 +217,7 @@ verify (DEC_BLOCKSIZE % 12 == 0); /* So complete encoded blocks are used. */ 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 @@ -252,7 +252,7 @@ struct base_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 @@ -275,7 +275,7 @@ base64_decode_ctx_init_wrapper (struct base_decode_context *ctx) 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); @@ -302,7 +302,7 @@ prepare_inbuf (struct base_decode_context *ctx, size_t inlen) 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); @@ -335,7 +335,7 @@ base64url_decode_ctx_init_wrapper (struct base_decode_context *ctx) 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); @@ -381,7 +381,7 @@ base32_decode_ctx_init_wrapper (struct base_decode_context *ctx) 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); @@ -439,7 +439,7 @@ isbase32hex (char ch) 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); @@ -462,7 +462,7 @@ base32hex_decode_ctx_init_wrapper (struct base_decode_context *ctx) 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); @@ -502,7 +502,7 @@ base16_length (int len) 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--) @@ -526,7 +526,7 @@ base16_decode_ctx_init (struct base_decode_context *ctx) 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 */ @@ -597,7 +597,7 @@ static char const z85_encoding[85] = ".-:+=^!/*?&<>()[]{}@%$#"; 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; @@ -697,7 +697,7 @@ static unsigned char z85_decoding[93] = { 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 */ @@ -794,7 +794,7 @@ base2_length (int len) 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--) @@ -811,7 +811,7 @@ base2msbf_encode (const char *restrict in, size_t 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--) @@ -839,7 +839,7 @@ base2_decode_ctx_init (struct base_decode_context *ctx) 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 */ @@ -883,7 +883,7 @@ base2lsbf_decode_ctx (struct base_decode_context *ctx, 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 */ @@ -932,7 +932,7 @@ base2msbf_decode_ctx (struct base_decode_context *ctx, 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; @@ -1087,7 +1087,7 @@ main (int argc, char **argv) { 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; diff --git a/src/chgrp.c b/src/chgrp.c index 84f829db21..dae8ebcd21 100644 --- a/src/chgrp.c +++ b/src/chgrp.c @@ -76,7 +76,7 @@ static struct option const long_options[] = /* 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; diff --git a/src/chmod.c b/src/chmod.c index 6bd2ee4a5d..78d9c9cba4 100644 --- a/src/chmod.c +++ b/src/chmod.c @@ -139,12 +139,12 @@ mode_changed (int dir_fd, char const *file, char const *file_full_name, 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) { diff --git a/src/chown-core.c b/src/chown-core.c index b4e6011f26..a0b2f670f6 100644 --- a/src/chown-core.c +++ b/src/chown-core.c @@ -133,11 +133,11 @@ user_group_str (char const *user, char const *group) 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; diff --git a/src/chown.c b/src/chown.c index 407d2770e3..91760ec44d 100644 --- a/src/chown.c +++ b/src/chown.c @@ -227,7 +227,7 @@ main (int argc, char **argv) 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) @@ -297,7 +297,7 @@ main (int argc, char **argv) } 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])); diff --git a/src/cksum.c b/src/cksum.c index f463cd6bb2..c3416f8668 100644 --- a/src/cksum.c +++ b/src/cksum.c @@ -172,10 +172,10 @@ static struct option const longopts[] = 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 @@ -209,7 +209,7 @@ pclmul_supported (void) # 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)]; @@ -269,7 +269,7 @@ cksum_slice8 (FILE *fp, const char *file, uint_fast32_t *crc_out, 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; diff --git a/src/cksum.h b/src/cksum.h index b3174722fa..7309b15a08 100644 --- a/src/cksum.h +++ b/src/cksum.h @@ -2,7 +2,7 @@ # 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]; diff --git a/src/cksum_pclmul.c b/src/cksum_pclmul.c index e18f17ae77..6aa6a609cc 100644 --- a/src/cksum_pclmul.c +++ b/src/cksum_pclmul.c @@ -29,13 +29,13 @@ 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)]; diff --git a/src/copy.c b/src/copy.c index 159556d052..9dbc694ebe 100644 --- a/src/copy.c +++ b/src/copy.c @@ -855,7 +855,7 @@ copy_attr_free (struct error_context *ctx _GL_UNUSED, 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); @@ -1062,7 +1062,7 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc, 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 @@ -2382,7 +2382,7 @@ copy_internal (char const *src_name, char const *dst_name, 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")); diff --git a/src/copy.h b/src/copy.h index 7acb4908cb..0265305183 100644 --- a/src/copy.h +++ b/src/copy.h @@ -282,7 +282,7 @@ struct cp_options 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 diff --git a/src/coreutils.c b/src/coreutils.c index 7700618621..6db5a8f05c 100644 --- a/src/coreutils.c +++ b/src/coreutils.c @@ -93,7 +93,7 @@ Use: '%s --coreutils-prog=PROGRAM_NAME --help' for individual program help.\n"), } 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; diff --git a/src/cp-hash.c b/src/cp-hash.c index e1ee964bff..423fcda239 100644 --- a/src/cp-hash.c +++ b/src/cp-hash.c @@ -112,7 +112,7 @@ src_to_dest_lookup (ino_t ino, dev_t dev) 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; diff --git a/src/cp-hash.h b/src/cp-hash.h index c2c5085ab6..afd9d780af 100644 --- a/src/cp-hash.h +++ b/src/cp-hash.h @@ -1,5 +1,5 @@ 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); diff --git a/src/cp.c b/src/cp.c index 59d9c0e325..a420c592b8 100644 --- a/src/cp.c +++ b/src/cp.c @@ -590,7 +590,7 @@ target_directory_operand (char const *file, struct stat *st, 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; diff --git a/src/csplit.c b/src/csplit.c index 07306cb405..ee9aa65032 100644 --- a/src/csplit.c +++ b/src/csplit.c @@ -649,7 +649,7 @@ no_more_lines (void) /* 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"), @@ -986,7 +986,7 @@ delete_all_files (bool in_signal_handler) 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)); } @@ -1083,7 +1083,7 @@ new_control_record (void) 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"), @@ -1136,7 +1136,7 @@ extract_regexp (int argnum, bool ignore, char const *str) 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) diff --git a/src/date.c b/src/date.c index 86b878fb33..d5eebaf253 100644 --- a/src/date.c +++ b/src/date.c @@ -39,7 +39,7 @@ #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 { @@ -287,7 +287,7 @@ Show the local time for 9AM next Friday on the west coast of the US\n\ 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; @@ -348,8 +348,8 @@ int 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; @@ -580,7 +580,7 @@ main (int argc, char **argv) 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; diff --git a/src/dd.c b/src/dd.c index 9152a25500..d284357a47 100644 --- a/src/dd.c +++ b/src/dd.c @@ -536,7 +536,7 @@ maybe_close_stdout (void) /* 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) { @@ -1445,7 +1445,7 @@ parse_symbols (char const *str, struct symbol_value const *table, 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; @@ -1961,7 +1961,7 @@ advance_input_after_read_error (size_t nbytes) 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 { diff --git a/src/df.c b/src/df.c index 42cfeed2c3..aadc3483f2 100644 --- a/src/df.c +++ b/src/df.c @@ -170,7 +170,7 @@ struct field_data_t 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; @@ -395,7 +395,7 @@ print_table (void) 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 *)); @@ -632,7 +632,7 @@ get_header (void) /* 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; @@ -647,7 +647,7 @@ selected_fstype (const char *fstype) /* 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; @@ -1353,7 +1353,7 @@ get_disk (char const *disk) 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; @@ -1478,7 +1478,7 @@ get_all_entries (void) /* 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; @@ -1491,7 +1491,7 @@ add_fs_type (const char *fstype) /* 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; @@ -1590,7 +1590,7 @@ main (int argc, char **argv) /* 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) { @@ -1799,7 +1799,7 @@ main (int argc, char **argv) { 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")); } diff --git a/src/dircolors.c b/src/dircolors.c index fc586e91a1..a1ab81bc8e 100644 --- a/src/dircolors.c +++ b/src/dircolors.c @@ -59,7 +59,7 @@ enum Shell_syntax 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", @@ -69,7 +69,7 @@ static const char *const slack_codes[] = "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", @@ -192,7 +192,7 @@ parse_line (char const *line, char **keyword, char **arg) sequences like unescaped : and = characters. */ static void -append_quoted (const char *str) +append_quoted (char const *str) { bool need_backslash = true; @@ -236,7 +236,7 @@ append_quoted (const char *str) 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; @@ -371,7 +371,7 @@ dc_parse_stream (FILE *fp, const char *filename) } static bool -dc_parse_file (const char *filename) +dc_parse_file (char const *filename) { bool ok; @@ -486,8 +486,8 @@ main (int argc, char **argv) { 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) { diff --git a/src/du.c b/src/du.c index 742e4cc5c9..d4760a36c8 100644 --- a/src/du.c +++ b/src/du.c @@ -377,7 +377,7 @@ hash_ins (struct di_set *di_set, ino_t ino, dev_t dev) 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)) @@ -407,7 +407,7 @@ print_only_size (uintmax_t n_bytes) /* 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 @@ -503,7 +503,7 @@ process_file (FTS *fts, FTSENT *ent) 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; diff --git a/src/env.c b/src/env.c index e2ab39fd57..5a30696d94 100644 --- a/src/env.c +++ b/src/env.c @@ -41,7 +41,7 @@ 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; @@ -167,7 +167,7 @@ comma-separated.\n\ } 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); @@ -197,12 +197,12 @@ unset_envvars (void) 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 == '}') @@ -218,10 +218,10 @@ scan_varname (const char *str) 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) @@ -353,7 +353,7 @@ splitbuf_finishup (struct splitbuf *ss) 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; @@ -512,7 +512,7 @@ build_argv (const char *str, int extra_argc, int *argc) 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; @@ -542,7 +542,7 @@ parse_split_string (const char *str, int *orig_optind, } 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; @@ -624,7 +624,7 @@ reset_signal_handlers (void) 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; @@ -674,7 +674,7 @@ set_signal_proc_mask (void) { /* Get the existing signal mask */ sigset_t set; - const char *debug_act; + char const *debug_act; sigemptyset (&set); diff --git a/src/expr.c b/src/expr.c index 4893d948f3..ec76f7607b 100644 --- a/src/expr.c +++ b/src/expr.c @@ -114,7 +114,7 @@ static void printv (VALUE *v); 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; @@ -166,7 +166,7 @@ mbs_logical_cspn (const char *s, const char *accept) 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; @@ -221,7 +221,7 @@ mbs_logical_substr (const char *s, size_t pos, size_t len) 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; @@ -584,7 +584,7 @@ static VALUE * 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; diff --git a/src/factor.c b/src/factor.c index f77d6d057a..d1a6bb8e7f 100644 --- a/src/factor.c +++ b/src/factor.c @@ -2256,7 +2256,7 @@ mp_factor (mpz_t t, struct mp_factors *factors) } 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; @@ -2264,7 +2264,7 @@ strto2uintmax (uintmax_t *hip, uintmax_t *lop, const char *s) strtol_error err = LONGINT_INVALID; /* Initial scan for invalid digits. */ - const char *p = s; + char const *p = s; for (;;) { unsigned int c = *p++; @@ -2461,7 +2461,7 @@ print_factors_single (uintmax_t t1, uintmax_t t0) 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; diff --git a/src/fmt.c b/src/fmt.c index 995a092998..ca9231b991 100644 --- a/src/fmt.c +++ b/src/fmt.c @@ -133,7 +133,7 @@ struct Word /* 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 */ @@ -183,7 +183,7 @@ static bool split; 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. */ @@ -618,7 +618,7 @@ get_paragraph (FILE *f) 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)) @@ -725,7 +725,7 @@ get_prefix (FILE *f) prefix_lead_space : in_column; else { - const char *p; + char const *p; next_prefix_indent = in_column; for (p = prefix; *p != '\0'; p++) { @@ -994,7 +994,7 @@ put_line (WORD *w, int indent) static void put_word (WORD *w) { - const char *s; + char const *s; int n; s = w->text; diff --git a/src/group-list.c b/src/group-list.c index cbb4865c72..54cec245b5 100644 --- a/src/group-list.c +++ b/src/group-list.c @@ -33,7 +33,7 @@ /* 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) { diff --git a/src/group-list.h b/src/group-list.h index cb4d480eb5..f888618103 100644 --- a/src/group-list.h +++ b/src/group-list.h @@ -16,4 +16,4 @@ along with this program. If not, see . */ 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); diff --git a/src/head.c b/src/head.c index 14f0330240..844c5636a1 100644 --- a/src/head.c +++ b/src/head.c @@ -165,7 +165,7 @@ diagnose_copy_fd_failure (enum Copy_fd_status err, char const *filename) } static void -write_header (const char *filename) +write_header (char const *filename) { static bool first_file = true; @@ -245,7 +245,7 @@ elseek (int fd, off_t offset, int whence, char const *filename) 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; @@ -462,7 +462,7 @@ elide_tail_bytes_pipe (const char *filename, int fd, uintmax_t 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; @@ -495,7 +495,7 @@ elide_tail_bytes_file (const char *filename, int fd, uintmax_t n_elide, 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 @@ -644,7 +644,7 @@ free_lbuffers: 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) { @@ -751,7 +751,7 @@ elide_tail_lines_seekable (const char *pretty_filename, int fd, 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; @@ -771,7 +771,7 @@ elide_tail_lines_file (const char *filename, int fd, uintmax_t n_elide, } 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; @@ -796,7 +796,7 @@ head_bytes (const char *filename, int fd, uintmax_t bytes_to_write) } 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]; @@ -833,7 +833,7 @@ head_lines (const char *filename, int fd, uintmax_t lines_to_write) } 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) @@ -867,7 +867,7 @@ head (const char *filename, int fd, uintmax_t n_units, bool count_lines, } 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; @@ -907,7 +907,7 @@ head_file (const char *filename, uintmax_t n_units, bool count_lines, 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") diff --git a/src/id.c b/src/id.c index 8706481752..a6c48cd50c 100644 --- a/src/id.c +++ b/src/id.c @@ -69,8 +69,8 @@ static gid_t rgid, egid; 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[] = { @@ -236,7 +236,7 @@ main (int argc, char **argv) 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. */ @@ -354,7 +354,7 @@ print_user (uid_t uid) /* 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; @@ -429,7 +429,7 @@ print_full_info (const char *username) /* 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); diff --git a/src/install.c b/src/install.c index f3c30b6897..8edf00f936 100644 --- a/src/install.c +++ b/src/install.c @@ -167,7 +167,7 @@ extra_mode (mode_t input) /* 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; @@ -435,7 +435,7 @@ process_dir (char *dir, struct savewd *wd, void *options) 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; @@ -658,7 +658,7 @@ In the 4th form, create all components of the given DIRECTORY(ies).\n\ 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; @@ -739,10 +739,10 @@ install_file_in_file_parents (char const *from, char *to, 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; @@ -759,7 +759,7 @@ main (int argc, char **argv) { 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; diff --git a/src/join.c b/src/join.c index 4aeffb6d31..57f4665bcb 100644 --- a/src/join.c +++ b/src/join.c @@ -857,7 +857,7 @@ string_to_join_field (char const *str) 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]) diff --git a/src/libstdbuf.c b/src/libstdbuf.c index 3cb74260af..4350b4655c 100644 --- a/src/libstdbuf.c +++ b/src/libstdbuf.c @@ -65,10 +65,10 @@ 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) { @@ -90,7 +90,7 @@ fileno_to_name (const int fd) } static void -apply_mode (FILE *stream, const char *mode) +apply_mode (FILE *stream, char const *mode) { char *buf = NULL; int setvbuf_mode; diff --git a/src/ln.c b/src/ln.c index d0319ef4e6..e6abd2244a 100644 --- a/src/ln.c +++ b/src/ln.c @@ -129,7 +129,7 @@ errnoize (int status) 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. */ diff --git a/src/ls.c b/src/ls.c index 2db7241738..4586b5eccd 100644 --- a/src/ls.c +++ b/src/ls.c @@ -249,7 +249,7 @@ struct fileinfo 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 @@ -276,8 +276,8 @@ static const struct bin_str * get_color_indicator (const struct fileinfo *f, 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); @@ -310,7 +310,7 @@ static void parse_ls_color (void); 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); @@ -602,7 +602,7 @@ enum indicator_no 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", @@ -700,7 +700,7 @@ static enum struct ignore_pattern { - const char *pattern; + char const *pattern; struct ignore_pattern *next; }; @@ -1064,7 +1064,7 @@ dev_ino_pop (void) 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; @@ -1158,7 +1158,7 @@ calc_req_mask (void) } 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; @@ -1182,26 +1182,26 @@ do_statx (int fd, const char *name, struct stat *st, int flags, } 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); } @@ -1213,25 +1213,25 @@ fstat_for_ino (int fd, struct stat *st) } #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); } @@ -2468,7 +2468,7 @@ decode_switches (int argc, char **argv) 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 */ @@ -2476,7 +2476,7 @@ get_funky_string (char **dest, const char **src, bool equals_end, 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 */ @@ -2699,7 +2699,7 @@ known_term_type (void) 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 */ @@ -3059,7 +3059,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg) if (format == long_format || print_block_size) { - const char *p; + char const *p; char buf[LONGEST_HUMAN_READABLE + 1]; DIRED_INDENT (); @@ -3080,7 +3080,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg) not listed. */ static void -add_ignore_pattern (const char *pattern) +add_ignore_pattern (char const *pattern) { struct ignore_pattern *ignore; @@ -3687,7 +3687,7 @@ make_link_name (char const *name, char const *linkname) 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); @@ -4681,7 +4681,7 @@ quote_name_buf (char **inbuf, size_t bufsize, char *name, } 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]; @@ -4703,7 +4703,7 @@ quote_name_width (const char *name, struct quoting_options const *options, /* %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; @@ -5235,9 +5235,9 @@ indent (size_t from, size_t to) 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) diff --git a/src/md5sum.c b/src/md5sum.c index 781052753b..cbfdc3ab22 100644 --- a/src/md5sum.c +++ b/src/md5sum.c @@ -588,7 +588,7 @@ print_filename (char const *file, bool escape) 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; @@ -649,7 +649,7 @@ digest_file (const char *filename, int *binary, unsigned char *bin_result, } static bool -digest_check (const char *checkfile_name) +digest_check (char const *checkfile_name) { FILE *checkfile_stream; uintmax_t n_misformatted_lines = 0; diff --git a/src/mkdir.c b/src/mkdir.c index b266cee8cb..1556b54a39 100644 --- a/src/mkdir.c +++ b/src/mkdir.c @@ -192,7 +192,7 @@ process_dir (char *dir, struct savewd *wd, void *options) 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; diff --git a/src/mktemp.c b/src/mktemp.c index 52a97ebc46..c1344ca7cb 100644 --- a/src/mktemp.c +++ b/src/mktemp.c @@ -36,7 +36,7 @@ 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. */ @@ -104,7 +104,7 @@ Files are created u+rw, and directories u+rwx, minus umask restrictions.\n\ } 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--) diff --git a/src/mv.c b/src/mv.c index e82cc09721..3db5cc48dd 100644 --- a/src/mv.c +++ b/src/mv.c @@ -166,7 +166,7 @@ target_directory_operand (char const *file) 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; diff --git a/src/numfmt.c b/src/numfmt.c index 0ffeda1846..c54f96d27b 100644 --- a/src/numfmt.c +++ b/src/numfmt.c @@ -171,7 +171,7 @@ 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 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; @@ -180,7 +180,7 @@ 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 const char *format_str = NULL; +static char const *format_str = NULL; static char *format_str_prefix = NULL; static char *format_str_suffix = NULL; @@ -206,7 +206,7 @@ static uintmax_t header = 0; 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(). */ @@ -233,7 +233,7 @@ default_scale_base (enum scale_type scale) 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); } @@ -271,7 +271,7 @@ suffix_power (const char suf) } } -static inline const char * +static inline char const * suffix_power_char (unsigned int power) { switch (power) @@ -463,7 +463,7 @@ enum simple_strtod_error 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; @@ -528,7 +528,7 @@ simple_strtod_int (const char *input_str, 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) @@ -604,7 +604,7 @@ simple_strtod_float (const char *input_str, 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) { @@ -821,15 +821,15 @@ double_to_human (long double val, int precision, 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])) @@ -1164,7 +1164,7 @@ parse_format_string (char const *fmt) 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; diff --git a/src/od.c b/src/od.c index da392eaee3..5b2d507a12 100644 --- a/src/od.c +++ b/src/od.c @@ -448,7 +448,7 @@ N (size_t fields, size_t blank, void const *block, \ 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 \ @@ -484,7 +484,7 @@ PRINT_FLOATTYPE (print_long_double, long double, ldtoastr, LDBL_BUFSIZE_BOUND) #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--) @@ -498,7 +498,7 @@ dump_hexl_mode_trailer (size_t n_bytes, const char *block) 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; @@ -508,7 +508,7 @@ print_named_ascii (size_t fields, size_t blank, void const *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) @@ -529,7 +529,7 @@ print_named_ascii (size_t fields, size_t blank, void const *block, 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; @@ -539,7 +539,7 @@ print_ascii (size_t fields, size_t blank, void const *block, { int next_pad = pad * (i - 1) / fields; unsigned char c = *p++; - const char *s; + char const *s; char buf[4]; switch (c) @@ -595,7 +595,7 @@ print_ascii (size_t fields, size_t blank, void const *block, 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; @@ -632,7 +632,7 @@ simple_strtoul (const char *s, const char **p, unsigned long int *val) */ 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; @@ -640,7 +640,7 @@ decode_one_format (const char *s_orig, const char *s, const char **next, 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; @@ -979,14 +979,14 @@ check_and_close (int in_errno) 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); @@ -1186,7 +1186,7 @@ format_address_label (uintmax_t address, char c) 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; @@ -1332,7 +1332,7 @@ get_lcm (void) 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; diff --git a/src/pinky.c b/src/pinky.c index 3dcdc13f6f..23a43f5e4f 100644 --- a/src/pinky.c +++ b/src/pinky.c @@ -82,7 +82,7 @@ static struct option const longopts[] = /* 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 @@ -100,7 +100,7 @@ count_ampersands (const char *str) 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; @@ -122,7 +122,7 @@ create_fullname (const char *gecos_name, const char *user_name) { 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) @@ -143,7 +143,7 @@ create_fullname (const char *gecos_name, const char *user_name) /* 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; @@ -171,7 +171,7 @@ idle_string (time_t when) } /* 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"]; @@ -348,7 +348,7 @@ print_long_entry (const char name[]) { 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); @@ -372,7 +372,7 @@ print_long_entry (const char name[]) { 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); @@ -458,7 +458,7 @@ scan_entries (size_t n, const STRUCT_UTMP *utmp_buf, /* 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; diff --git a/src/pr.c b/src/pr.c index 5b003cb9a7..da57955544 100644 --- a/src/pr.c +++ b/src/pr.c @@ -426,8 +426,8 @@ static bool skip_to_page (uintmax_t page); 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); @@ -445,7 +445,7 @@ static void skip_read (COLUMN *p, int column_number); 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; @@ -845,7 +845,7 @@ parse_column_count (char const *s) /* 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) @@ -1153,7 +1153,7 @@ main (int argc, char **argv) /* 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; diff --git a/src/printf.c b/src/printf.c index 95bd26f2e5..a23b5a8b1c 100644 --- a/src/printf.c +++ b/src/printf.c @@ -142,7 +142,7 @@ ARGUMENTs converted to proper type first. Variable widths are handled.\n\ } static void -verify_numeric (const char *s, const char *end) +verify_numeric (char const *s, char const *end) { if (errno) { @@ -237,9 +237,9 @@ print_esc_char (char c) 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. */ @@ -310,7 +310,7 @@ print_esc (const char *escstart, bool octal_0) /* Print string STR, evaluating \ escapes. */ static void -print_esc_string (const char *str) +print_esc_string (char const *str) { for (; *str; str++) if (*str == '\\') @@ -328,7 +328,7 @@ print_esc_string (const char *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) @@ -475,11 +475,11 @@ print_direc (const char *start, size_t length, char conversion, 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 '*'. */ diff --git a/src/ptx.c b/src/ptx.c index 5d3c2c087b..fc4d0912fa 100644 --- a/src/ptx.c +++ b/src/ptx.c @@ -78,16 +78,16 @@ static bool input_reference = false; /* refs at beginning of input lines */ 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 @@ -162,7 +162,7 @@ static WORD_TABLE only_table; /* table of words to select */ 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 */ @@ -295,7 +295,7 @@ matcher_error (void) /* 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 */ @@ -510,7 +510,7 @@ initialize_regex (void) `------------------------------------------------------------------------*/ 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 */ @@ -648,7 +648,7 @@ sort_found_occurs (void) `----------------------------------------------------------------------*/ 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 */ @@ -688,7 +688,7 @@ digest_break_file (const char *file_name) `-----------------------------------------------------------------------*/ 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 */ @@ -1099,7 +1099,7 @@ fix_output_parameters (void) 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 @@ -1250,10 +1250,10 @@ define_all_fields (OCCURS *occurs) 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 diff --git a/src/readlink.c b/src/readlink.c index 01be376745..601cea9a7b 100644 --- a/src/readlink.c +++ b/src/readlink.c @@ -155,7 +155,7 @@ main (int argc, char **argv) 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)); diff --git a/src/realpath.c b/src/realpath.c index f67c41c931..4c9ffbcb4b 100644 --- a/src/realpath.c +++ b/src/realpath.c @@ -41,8 +41,8 @@ enum 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[] = { @@ -96,7 +96,7 @@ all but the last component must exist\n\ /* 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. */ @@ -111,7 +111,7 @@ realpath_canon (const char *fname, int can_mode) /* 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++; @@ -138,7 +138,7 @@ path_prefix (const char *prefix, const char *path) } static bool -isdir (const char *path) +isdir (char const *path) { struct stat sb; if (stat (path, &sb) != 0) @@ -147,7 +147,7 @@ isdir (const char *path) } 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) @@ -174,8 +174,8 @@ main (int argc, char **argv) { 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]); diff --git a/src/relpath.c b/src/relpath.c index 87776161d1..a1ec5737ee 100644 --- a/src/relpath.c +++ b/src/relpath.c @@ -27,7 +27,7 @@ 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; @@ -85,7 +85,7 @@ buffer_or_output (const char* 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. */ 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; @@ -94,8 +94,8 @@ relpath (const char *can_fname, const char *can_reldir, char *buf, size_t len) 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 == '/') diff --git a/src/relpath.h b/src/relpath.h index 0a1080ddca..05645cd391 100644 --- a/src/relpath.h +++ b/src/relpath.h @@ -20,6 +20,6 @@ # 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 diff --git a/src/selinux.c b/src/selinux.c index dafd471373..053fcc9938 100644 --- a/src/selinux.c +++ b/src/selinux.c @@ -114,7 +114,7 @@ defaultcon (struct selabel_handle *selabel_handle, char *scon = NULL; char *tcon = NULL; context_t scontext = 0, tcontext = 0; - const char *contype; + char const *contype; char *constr; char *newpath = NULL; @@ -182,7 +182,7 @@ restorecon_private (struct selabel_handle *selabel_handle, char const *path) char *scon = NULL; char *tcon = NULL; context_t scontext = 0, tcontext = 0; - const char *contype; + char const *contype; char *constr; int fd; diff --git a/src/seq.c b/src/seq.c index f11d756699..d9946da30b 100644 --- a/src/seq.c +++ b/src/seq.c @@ -146,7 +146,7 @@ struct layout Return if the string is correct else signal error. */ static operand -scan_arg (const char *arg) +scan_arg (char const *arg) { operand ret; diff --git a/src/set-fields.c b/src/set-fields.c index 322a92a48a..320a16ba89 100644 --- a/src/set-fields.c +++ b/src/set-fields.c @@ -135,7 +135,7 @@ complement_rp (void) { .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. */ diff --git a/src/set-fields.h b/src/set-fields.h index 85cdb8dcf7..61d465f60e 100644 --- a/src/set-fields.h +++ b/src/set-fields.h @@ -39,7 +39,7 @@ enum }; /* 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); diff --git a/src/sleep.c b/src/sleep.c index faa486c121..2d3e26bbaa 100644 --- a/src/sleep.c +++ b/src/sleep.c @@ -120,7 +120,7 @@ main (int argc, char **argv) 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) diff --git a/src/sort.c b/src/sort.c index 5aa4ffcbbd..d98796b967 100644 --- a/src/sort.c +++ b/src/sort.c @@ -370,9 +370,9 @@ static unsigned int nmerge = NMERGE_DEFAULT; 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))); diff --git a/src/split.c b/src/split.c index 59c234c12c..f653e1b85b 100644 --- a/src/split.c +++ b/src/split.c @@ -84,7 +84,7 @@ static size_t suffix_length; 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; @@ -454,7 +454,7 @@ new_name: /* Create or truncate a file. */ static int -create (const char *name) +create (char const *name) { if (!filter_command) { @@ -594,7 +594,7 @@ closeout (FILE *fp, int fd, pid_t pid, char const *name) 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) { diff --git a/src/stat.c b/src/stat.c index 7bd1044cb4..56e4867b92 100644 --- a/src/stat.c +++ b/src/stat.c @@ -1343,7 +1343,7 @@ do_stat (char const *filename, char const *format, char const *format2) 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}; diff --git a/src/stdbuf.c b/src/stdbuf.c index da877fdf08..dd39bd0868 100644 --- a/src/stdbuf.c +++ b/src/stdbuf.c @@ -133,7 +133,7 @@ and are thus unaffected by 'stdbuf' settings.\n\ 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. */ { diff --git a/src/stty.c b/src/stty.c index 1ed765ecb1..1bf7f6328d 100644 --- a/src/stty.c +++ b/src/stty.c @@ -197,7 +197,7 @@ enum mode_type /* 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. */ @@ -383,7 +383,7 @@ static struct mode_info const mode_info[] = /* 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. */ }; @@ -443,22 +443,22 @@ static bool recover_mode (char const *arg, struct termios *mode); 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); @@ -481,7 +481,7 @@ static struct option const longopts[] = {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. @@ -489,7 +489,7 @@ static void wrapf (const char *message, ...) 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; @@ -1084,7 +1084,7 @@ settings, CHAR is taken literally, or coded as in ^c, 0x37, 0177 or\n\ 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) @@ -1281,7 +1281,7 @@ main (int argc, char **argv) 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]); @@ -1672,7 +1672,7 @@ set_mode (struct mode_info const *info, bool reversed, struct termios *mode) } 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; @@ -1696,7 +1696,7 @@ set_control_char (struct control_info const *info, const char *arg, } 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; @@ -2133,7 +2133,7 @@ recover_mode (char const *arg, struct termios *mode) struct speed_map { - const char *string; /* ASCII representation. */ + char const *string; /* ASCII representation. */ speed_t speed; /* Internal form. */ unsigned long int value; /* Numeric value. */ }; @@ -2208,7 +2208,7 @@ static struct speed_map const speeds[] = }; 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)) @@ -2263,7 +2263,7 @@ sane_mode (struct termios *mode) /* 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]; @@ -2308,7 +2308,7 @@ visible (cc_t ch) *bpout++ = ch + 64; } *bpout = '\0'; - return (const char *) buf; + return (char const *) buf; } /* Parse string S as an integer, using decimal radix by default, @@ -2316,7 +2316,7 @@ visible (cc_t ch) 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); } diff --git a/src/sum.c b/src/sum.c index dd7bfb144b..218db808d5 100644 --- a/src/sum.c +++ b/src/sum.c @@ -85,7 +85,7 @@ Print checksum and block counts for each FILE.\n\ 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. */ @@ -149,7 +149,7 @@ bsd_sum_file (const char *file, int print_name) 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]; @@ -223,7 +223,7 @@ main (int argc, char **argv) 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]); diff --git a/src/system.h b/src/system.h index 6d564ef445..676f5f562b 100644 --- a/src/system.h +++ b/src/system.h @@ -453,7 +453,7 @@ enum # 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_); \ @@ -656,7 +656,7 @@ emit_ancillary_info (char const *program) /* Don't output this redundant message for English locales. Note we still output for 'C' so that it gets included in the man page. */ - 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 diff --git a/src/tac.c b/src/tac.c index 1aadcd8311..1a01c005e9 100644 --- a/src/tac.c +++ b/src/tac.c @@ -156,7 +156,7 @@ Write each FILE to standard output, last line first.\n\ 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; @@ -190,7 +190,7 @@ output (const char *start, const char *past_end) 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. */ @@ -393,7 +393,7 @@ tac_seekable (int input_fd, const char *file, off_t file_pos) 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 @@ -543,7 +543,7 @@ copy_to_temp (FILE **g_tmp, char **g_tempfile, int input_fd, char const *file) 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; @@ -560,7 +560,7 @@ tac_nonseekable (int input_fd, const char *file) Return true if successful. */ static bool -tac_file (const char *filename) +tac_file (char const *filename) { bool ok; off_t file_size; @@ -602,7 +602,7 @@ tac_file (const char *filename) 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; diff --git a/src/tail.c b/src/tail.c index 35a76594c2..9095a18d89 100644 --- a/src/tail.c +++ b/src/tail.c @@ -409,7 +409,7 @@ record_open_fd (struct File_spec *f, int fd, /* 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)) { @@ -418,7 +418,7 @@ close_fd (int fd, const char *filename) } static void -write_header (const char *pretty_filename) +write_header (char const *pretty_filename) { static bool first_file = true; @@ -446,7 +446,7 @@ xwrite_stdout (char const *buffer, size_t n_bytes) 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; @@ -532,7 +532,7 @@ xlseek (int fd, off_t offset, int whence, char const *filename) 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]; @@ -620,7 +620,7 @@ file_lines (const char *pretty_filename, int fd, uintmax_t n_lines, 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 @@ -759,7 +759,7 @@ free_lbuffers: 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 @@ -860,7 +860,7 @@ free_cbuffers: 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]; @@ -895,7 +895,7 @@ start_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, 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) @@ -935,7 +935,7 @@ start_lines (const char *pretty_filename, int fd, uintmax_t n_lines, 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). */ @@ -1841,7 +1841,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t n_files, 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; @@ -1904,7 +1904,7 @@ tail_bytes (const char *pretty_filename, int fd, uintmax_t n_bytes, 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; @@ -1966,7 +1966,7 @@ tail_lines (const char *pretty_filename, int fd, uintmax_t n_lines, 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; @@ -2089,9 +2089,9 @@ tail_file (struct File_spec *f, uintmax_t n_units) 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; diff --git a/src/timeout.c b/src/timeout.c index 6c1723ec31..34d7926408 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -349,10 +349,10 @@ apply_time_suffix (double *x, char suffix_char) } 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. */ diff --git a/src/touch.c b/src/touch.c index 136e246bc9..653fd313bb 100644 --- a/src/touch.c +++ b/src/touch.c @@ -120,7 +120,7 @@ get_reldate (struct timespec *result, Return true if successful. */ static bool -touch (const char *file) +touch (char const *file) { bool ok; int fd = -1; diff --git a/src/tsort.c b/src/tsort.c index b388819bb9..92bd1b2afe 100644 --- a/src/tsort.c +++ b/src/tsort.c @@ -52,7 +52,7 @@ struct successor /* 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; @@ -99,7 +99,7 @@ Write totally ordered list consistent with the partial ordering in FILE.\n\ /* 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); @@ -124,7 +124,7 @@ new_item (const char *str) 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; @@ -433,7 +433,7 @@ walk_tree (struct item *root, bool (*action) (struct item *)) /* 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; diff --git a/src/uniq.c b/src/uniq.c index 6dceedb30c..8963e94b91 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -317,7 +317,7 @@ writeline (struct linebuffer const *line, 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; diff --git a/src/uptime.c b/src/uptime.c index 4d196ea819..3238d25eb1 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -174,7 +174,7 @@ print_uptime (size_t n, const STRUCT_UTMP *this) 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; diff --git a/src/users.c b/src/users.c index b7d6562115..e08aeaf370 100644 --- a/src/users.c +++ b/src/users.c @@ -82,7 +82,7 @@ list_entries_users (size_t n, const STRUCT_UTMP *this) 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; diff --git a/src/wc.c b/src/wc.c index 5216db1899..a122bde807 100644 --- a/src/wc.c +++ b/src/wc.c @@ -173,7 +173,7 @@ write_counts (uintmax_t lines, 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; @@ -379,7 +379,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos) 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 @@ -519,7 +519,7 @@ wc (int fd, char const *file_x, struct fstatus *fstatus, off_t current_pos) 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)); diff --git a/src/who.c b/src/who.c index ebd140914a..ac360c6bae 100644 --- a/src/who.c +++ b/src/who.c @@ -89,7 +89,7 @@ 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 @@ -184,7 +184,7 @@ static struct option const longopts[] = /* 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); @@ -214,7 +214,7 @@ idle_string (time_t when, time_t boottime) } /* 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"]; @@ -241,10 +241,10 @@ time_string (const STRUCT_UTMP *utmp_ent) 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; @@ -618,7 +618,7 @@ scan_entries (size_t n, const STRUCT_UTMP *utmp_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; -- 2.47.2