bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: recent const churn


From: Jim Meyering
Subject: Re: recent const churn
Date: Tue, 17 Jun 2008 08:39:28 +0200

Eric Blake <address@hidden> wrote:

> According to Jim Meyering on 6/16/2008 9:49 AM:
> |> Sounds like an updated maintainer rule to check for redundant const
> might be
> |> useful?
> |
> | Thanks for keeping watch!
> | Anything to protect me from myself ;-)
> | If you feel like it, a patch would be most welcome.
>
> Attached, or...
> $ git fetch git://repo.or.cz/coreutils/ericb.git const:const
>
> Hopefully the use of "grep '\b'" in maint.mk is acceptable, even though it
> is GNU-specific (at any rate, I'm not the first to use it).  I had to use
> it to avoid a false positive in tr.c (a comment mentioned the word
> contruct twice).
...
> Subject: [PATCH] ls, od: avoid redundant const
>
> * 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.
> (sc_const_long_option): Tweak to avoid tripping new rule.

Yes, I too think using \b is fine.
However, rather than changing sc_const_long_option to avoid
sc_redundant_const triggering on it's regexp, I've chosen to use
a stricter regexp in the new rule so we don't have to twist the
other rule:

  grep -E '\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' ...


>From a7a328af0f7d087d8c664e7803a9f3a7479376c1 Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Mon, 16 Jun 2008 21:16:07 -0600
Subject: [PATCH] ls, od: avoid redundant const

* 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 |    8 ++++++++
 src/ls.c |    4 ++--
 src/od.c |    2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/maint.mk b/maint.mk
index df6b7f3..5ba7b28 100644
--- 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' && {     \
diff --git a/src/ls.c b/src/ls.c
...




reply via email to

[Prev in Thread] Current Thread [Next in Thread]