bug-coreutils
[Top][All Lists]
Advanced

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

[PATCH] maint: enforce one small aspect of formatting style: space-befor


From: Jim Meyering
Subject: [PATCH] maint: enforce one small aspect of formatting style: space-before-"("
Date: Sat, 20 Mar 2010 12:24:17 +0100

FYI, I've just pushed this to coreutils.
Note that I've embedded both a default exemption regexp,
as well as the one I'm using in coreutils.
Obviously only the default would go into gnulib's maint.mk

Eric suggested that I put this in gnulib's maint.mk.
This is a pretty fundamental axiom of formatting in gnu projects,
so I suspect few would object outright, especially since it's
such an easy matter to conform or to disable the check:

   To disable, add to the "local-checks-to-skip" definition
   you probably already have in cfg.mk:

     local-checks-to-skip += sc_space_before_open_paren

Any objections?

An alternative, if this is deemed too invasive,
[In any project of nontrivial size, the exemption regexp will
 have to be derived if this check is not turned off. ]
is to create a new class of syntax checks:
ones that are provided, but that are turned off by default,
and put this test in that new category.

Jim

>From 773d15a70207b5c3389f3b8272553d7e3d4a272e Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 20 Mar 2010 12:11:50 +0100
Subject: [PATCH 1/2] maint: code formatting nit

* src/system.h (ST_NBLOCKS): Add space before paren.
---
 src/system.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/system.h b/src/system.h
index bf6c9ce..859b663 100644
--- a/src/system.h
+++ b/src/system.h
@@ -182,7 +182,7 @@ enum
 #    define ST_NBLOCKS(statbuf) \
   (S_ISREG ((statbuf).st_mode) \
    || S_ISDIR ((statbuf).st_mode) \
-   ? (statbuf).st_blocks * ST_BLKSIZE(statbuf)/ST_NBLOCKSIZE : 0)
+   ? (statbuf).st_blocks * ST_BLKSIZE (statbuf) / ST_NBLOCKSIZE : 0)
 #   endif /* _CRAY */
 #  endif /* not AIX PS/2 */
 # endif /* !hpux */
--
1.7.0.2.455.g91132


>From 628a5e16ddd28110c506f34667ef993d9be7b837 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 20 Mar 2010 12:14:46 +0100
Subject: [PATCH 2/2] maint: enforce one small aspect of formatting style: 
space-before-"("

* cfg.mk (sc_space_before_open_paren): New rule.
---
 cfg.mk |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/cfg.mk b/cfg.mk
index 71f3d85..8a6adc2 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -261,6 +261,29 @@ sc_prohibit_sleep:
        msg='prefer xnanosleep over other sleep interfaces'             \
          $(_prohibit_regexp)

+_space_before_paren_exempt =? \\n\\$$
+_space_before_paren_exempt = \
+  (\\n\\$$|%s\(to %s|delimit-method|(date|group|character)\(s\))
+# Ensure that there is a space before each open parenthesis in C code.
+sc_space_before_open_paren:
+       @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then    \
+         if (cpp -fpreprocessed < /dev/null > /dev/null 2>&1); then    \
+           fail=0;                                                     \
+           for c in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do        \
+             cpp -fpreprocessed $$c 2>/dev/null                        \
+               | grep -ni '[[:alnum:]]('                               \
+               | grep -vE '$(_space_before_paren_exempt)'              \
+               | grep . && { fail=1; echo "*** $$c"; };                \
+           done;                                                       \
+           test $$fail = 1 &&                                          \
+             { echo '$(ME): the above files lack a space-before-open-paren' \
+                 1>&2; exit 1; } || :;                                 \
+         else                                                          \
+           echo '$(ME): skipping test $@: cppi not installed' 1>&2;    \
+         fi;                                                           \
+       else :;                                                         \
+       fi
+
 include $(srcdir)/dist-check.mk

 update-copyright-env = \
--
1.7.0.2.455.g91132




reply via email to

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