Oops, ignore this please, it's on top of the old commit.
On 17/04/13 18:21, Osier Yang wrote:
gnulib is excluded.
---
cfg.mk | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index 71f7ee4..dd67816 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -724,25 +724,27 @@ sc_prohibit_exit_in_tests:
# Don't include duplicate header in the source (either *.c or *.h)
sc_prohibit_duplicate_header:
- @for i in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do \
- awk 'BEGIN { \
- FS=" "; \
- fail=0; \
- } \
- /^# *include.*\.h[">]$$/ { \
- arr[$$NF]++; \
+ @fail=0; for i in $$($(VC_LIST_EXCEPT) | grep '\.[chx]$$'); do \
+ awk '/# *include.*\.h/ { \
+ match($$0, /[<"][^>"]*[">]/); \
+ arr[substr($$0, RSTART + 1, RLENGTH - 2)]++; \
} \
END { \
for (key in arr) { \
- if (arr[key] > 1) { \
+ if (arr[key] > 1) { \
fail=1; \
printf("%d %s are included\n", arr[key], key); \
} \
} \
- if (fail == 1) \
+ if (fail == 1) { \
+ printf("duplicate header(s) in " FILENAME "\n"); \
exit 1; \
- }' $$i || { echo "Duplicate header(s) in $$i"; exit 1; }; \
- done
+ } \
+ }' $$i || fail=1; \
+ done; \
+ if test $$fail -eq 1; then \
+ { echo "$(ME)": avoid duplicate headers >&2; exit 1; } \
+ fi;
# We don't use this feature of maint.mk.
prev_version_file = /dev/null