]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
ls, od: avoid redundant const
authorEric Blake <ebb9@byu.net>
Tue, 17 Jun 2008 03:16:07 +0000 (21:16 -0600)
committerJim Meyering <meyering@redhat.com>
Tue, 17 Jun 2008 06:17:14 +0000 (08:17 +0200)
* src/ls.c (long_time_format, sort_functions): Avoid redundant const.
* src/od.c (charname): Likewise.
* maint.mk (sc_redundant_const): Add rule to detect this.

maint.mk
src/ls.c
src/od.c

index df6b7f3a6a50a42a6bce2e5268fd41a43cdf503a..5ba7b286c685cd2718c06194891f5f179e3e929c 100644 (file)
--- a/maint.mk
+++ b/maint.mk
@@ -483,6 +483,14 @@ sc_proper_name_utf8_requires_ICONV:
              exit 1; } || :;                                           \
        fi
 
+# Warn about "c0nst struct Foo const foo[]",
+# but not about "char const *const foo" or "#define const const".
+sc_redundant_const:
+       @grep -E '\bconst\b[[:space:][:alnum:]]{2,}\bconst\b'           \
+               $$($(VC_LIST_EXCEPT)) &&                                \
+           { echo 1>&2 '$(ME): redundant "const" in declarations';     \
+             exit 1; } || :
+
 sc_const_long_option:
        @grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT))         \
          | grep -Ev 'const struct option|struct option const' && {     \
index 87f799707f4673db7bab622ecbefa337c29414d6..4e044a93b47b5a9c9cb39e41db7984bbab37e6da 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -672,7 +672,7 @@ enum { TIME_STAMP_LEN_MAXIMUM = MAX (1000, INT_STRLEN_BOUND (time_t)) };
 /* strftime formats for non-recent and recent files, respectively, in
    -l output.  */
 
-static const char const *long_time_format[2] =
+static char const *long_time_format[2] =
   {
     /* strftime format for non-recent files (older than 6 months), in
        -l output.  This should contain the year, month and day (at
@@ -3151,7 +3151,7 @@ static int rev_xstrcoll_df_version (V a, V b)
     }                                                               \
   }
 
-static const qsortFunc const sort_functions[][2][2][2] =
+static qsortFunc const sort_functions[][2][2][2] =
   {
     LIST_SORTFUNCTION_VARIANTS (name),
     LIST_SORTFUNCTION_VARIANTS (extension),
index 70ba59cd2eaa7ac003ee1dbac1c98a862cea69bd..5b4b7bd4a6b6c297aadadab07a827582a05dac17 100644 (file)
--- a/src/od.c
+++ b/src/od.c
@@ -174,7 +174,7 @@ static const int width_bytes[] =
 verify (sizeof width_bytes / sizeof width_bytes[0] == N_SIZE_SPECS);
 
 /* Names for some non-printing characters.  */
-static const char const charname[33][4] =
+static char const charname[33][4] =
 {
   "nul", "soh", "stx", "etx", "eot", "enq", "ack", "bel",
   "bs", "ht", "nl", "vt", "ff", "cr", "so", "si",