From 71430dd7368a0cec23ff6093163b4ac20e2ea3d7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 29 May 2023 11:38:19 -0700 Subject: [PATCH] =?UTF-8?q?maint:=20prefer=20=E2=80=98*const=E2=80=99=20to?= =?UTF-8?q?=20=E2=80=98*=20const=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prefer declarations like ‘char *const *x;’ to ‘char * const *x;’, for consistency between ‘*const’ and ‘*x’, and to highlight the fact that the ‘const’ belongs to the preceding ‘*’ not to the following ‘*’. Similarly for ‘* volatile’. --- src/cmp.c | 2 +- src/context.c | 8 ++++---- src/diff.c | 2 +- src/diff.h | 7 ++++--- src/diff3.c | 19 ++++++++++--------- src/dir.c | 2 +- src/ifdef.c | 2 +- src/sdiff.c | 4 ++-- src/util.c | 4 ++-- 9 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/cmp.c b/src/cmp.c index c8571d9..1cbd80f 100644 --- a/src/cmp.c +++ b/src/cmp.c @@ -163,7 +163,7 @@ check_stdout (void) die (EXIT_TROUBLE, errno, "%s", _("standard output")); } -static char const * const option_help_msgid[] = { +static char const *const option_help_msgid[] = { N_("-b, --print-bytes print differing bytes"), N_("-i, --ignore-initial=SKIP skip first SKIP bytes of both inputs"), N_("-i, --ignore-initial=SKIP1:SKIP2 skip first SKIP1 bytes of FILE1 and\n" diff --git a/src/context.c b/src/context.c index ada40c4..de91db7 100644 --- a/src/context.c +++ b/src/context.c @@ -23,7 +23,7 @@ #include #include -static char const *find_function (char const * const *, lin); +static char const *find_function (char const *const *, lin); static struct change *find_hunk (struct change *); static void mark_ignorable (struct change *); static void pr_context_hunk (struct change *); @@ -376,7 +376,7 @@ pr_unidiff_hunk (struct change *hunk) while (k--) { - char const * const *line = &files[0].linbuf[i++]; + char const *const *line = &files[0].linbuf[i++]; set_color_context (DELETE_CONTEXT); putc ('-', out); if (initial_tab && ! (suppress_blank_empty && **line == '\n')) @@ -395,7 +395,7 @@ pr_unidiff_hunk (struct change *hunk) while (k--) { - char const * const *line = &files[1].linbuf[j++]; + char const *const *line = &files[1].linbuf[j++]; set_color_context (ADD_CONTEXT); putc ('+', out); if (initial_tab && ! (suppress_blank_empty && **line == '\n')) @@ -482,7 +482,7 @@ mark_ignorable (struct change *script) Return the address of the text, or null if no function-header is found. */ static char const * -find_function (char const * const *linbuf, lin linenum) +find_function (char const *const *linbuf, lin linenum) { lin i = linenum; lin last = find_function_last_search; diff --git a/src/diff.c b/src/diff.c index 8041630..fdec58c 100644 --- a/src/diff.c +++ b/src/diff.c @@ -945,7 +945,7 @@ check_stdout (void) pfatal_with_name (_("standard output")); } -static char const * const option_help_msgid[] = { +static char const *const option_help_msgid[] = { N_(" --normal output a normal diff (the default)"), N_("-q, --brief report only when files differ"), N_("-s, --report-identical-files report when two files are the same"), diff --git a/src/diff.h b/src/diff.h index 10ba572..08babce 100644 --- a/src/diff.h +++ b/src/diff.h @@ -358,7 +358,8 @@ XTERN FILE *outfile; extern int diff_2_files (struct comparison *); /* context.c */ -extern void print_context_header (struct file_data[], char const * const *, bool); +extern void print_context_header (struct file_data[], + char const *const *, bool); extern void print_context_script (struct change *, bool); /* dir.c */ @@ -407,8 +408,8 @@ extern void output_1_line (char const *, char const *, char const *, char const *); extern void perror_with_name (char const *); extern _Noreturn void pfatal_with_name (char const *); -extern void print_1_line (char const *, char const * const *); -extern void print_1_line_nl (char const *, char const * const *, bool); +extern void print_1_line (char const *, char const *const *); +extern void print_1_line_nl (char const *, char const *const *, bool); extern void print_message_queue (void); extern void print_number_range (char, struct file_data *, lin, lin); extern void print_script (struct change *, struct change * (*) (struct change *), diff --git a/src/diff3.c b/src/diff3.c index e87b52a..301d4c9 100644 --- a/src/diff3.c +++ b/src/diff3.c @@ -182,8 +182,9 @@ static bool merge; static char *read_diff (char const *, char const *, char **); static char *scan_diff_line (char *, char **, idx_t *, char *, char); static enum diff_type process_diff_control (char **, struct diff_block *); -static bool compare_line_list (char * const[], idx_t const[], char * const[], idx_t const[], lin); -static bool copy_stringlist (char * const[], idx_t const[], char *[], idx_t[], lin); +static bool compare_line_list (char *const[], idx_t const[], + char *const[], idx_t const[], lin); +static bool copy_stringlist (char *const[], idx_t const[], char *[], idx_t[], lin); static bool output_diff3_edscript (FILE *, struct diff3_block *, int const[3], int const[3], char const *, char const *, char const *); static bool output_diff3_merge (FILE *, FILE *, struct diff3_block *, int const[3], int const[3], char const *, char const *, char const *); static struct diff3_block *create_diff3_block (lin, lin, lin, lin, lin, lin); @@ -468,7 +469,7 @@ check_stdout (void) perror_with_exit (_("standard output")); } -static char const * const option_help_msgid[] = { +static char const *const option_help_msgid[] = { N_("-A, --show-all output all changes, bracketing conflicts"), "", N_("-e, --ed output ed script incorporating changes\n" @@ -835,11 +836,11 @@ using_to_diff3_block (struct diff_block *using[2], incomplete. Upon successful completion of the copy, return true. */ static bool -copy_stringlist (char * const fromptrs[], idx_t const fromlengths[], +copy_stringlist (char *const fromptrs[], idx_t const fromlengths[], char *toptrs[], idx_t tolengths[], lin copynum) { - register char * const *f = fromptrs; + register char *const *f = fromptrs; register char **t = toptrs; idx_t const *fl = fromlengths; idx_t *tl = tolengths; @@ -930,12 +931,12 @@ create_diff3_block (lin low0, lin high0, Return 1 if they are equivalent, 0 if not. */ static bool -compare_line_list (char * const list1[], idx_t const lengths1[], - char * const list2[], idx_t const lengths2[], +compare_line_list (char *const list1[], idx_t const lengths1[], + char *const list2[], idx_t const lengths2[], lin nl) { - char * const *l1 = list1; - char * const *l2 = list2; + char *const *l1 = list1; + char *const *l2 = list2; idx_t const *lgths1 = lengths1; idx_t const *lgths2 = lengths2; diff --git a/src/dir.c b/src/dir.c index 773afeb..a62539a 100644 --- a/src/dir.c +++ b/src/dir.c @@ -323,7 +323,7 @@ char * find_dir_file_pathname (char const *dir, char const *file) { /* IF_LINT due to GCC bug 21161. */ - char const * IF_LINT (volatile) match = file; + char const *IF_LINT (volatile) match = file; struct dirdata dirdata; dirdata.names = nullptr; diff --git a/src/ifdef.c b/src/ifdef.c index 843a5a6..ca24219 100644 --- a/src/ifdef.c +++ b/src/ifdef.c @@ -232,7 +232,7 @@ print_ifdef_lines (register FILE *out, char const *format, return; struct file_data const *file = group->file; - char const * const *linbuf = file->linbuf; + char const *const *linbuf = file->linbuf; lin from = group->from, upto = group->upto; /* If possible, use a single fwrite; it's faster. */ diff --git a/src/sdiff.c b/src/sdiff.c index 86a83a2..95a20c3 100644 --- a/src/sdiff.c +++ b/src/sdiff.c @@ -50,7 +50,7 @@ enum { SDIFF_BUFSIZE = 65536 }; static char const *editor_program = DEFAULT_EDITOR_PROGRAM; static char const **diffargv; -static char * volatile tmpname; +static char *volatile tmpname; static FILE *tmp; #if HAVE_WORKING_FORK @@ -179,7 +179,7 @@ check_stdout (void) perror_fatal (_("standard output")); } -static char const * const option_help_msgid[] = { +static char const *const option_help_msgid[] = { N_("-o, --output=FILE operate interactively, sending output to FILE"), "", N_("-i, --ignore-case consider upper- and lower-case to be the same"), diff --git a/src/util.c b/src/util.c index 743b984..d5167d5 100644 --- a/src/util.c +++ b/src/util.c @@ -1551,8 +1551,8 @@ analyze_hunk (struct change *hunk, bool skip_leading_white_space = skip_white_space && IGNORE_SPACE_CHANGE <= ignore_white_space; - char const * const *linbuf0 = files[0].linbuf; /* Help the compiler. */ - char const * const *linbuf1 = files[1].linbuf; + char const *const *linbuf0 = files[0].linbuf; /* Help the compiler. */ + char const *const *linbuf1 = files[1].linbuf; lin show_from = 0, show_to = 0;