On 08/18/2015 04:39 PM, Pádraig Brady wrote:
> I see that `grep -L` is already used in maint.mk, and is widely
> available as FreeBSD and OS X use GNU grep or a compat replacement.
Even better!
> Therefore it could be simplified to avoid temp files like:
>
> awk ... | xargs grep -L 'Copy...' | grep . && { echo err; exit 1; }
Almost - because if "grep ." fails (because all necessary Copyright notices
are in place), then the SC rule would fail, too.
Attached v2.
Thanks & have a nice day,
Berny
>From 4ec9ccad7981e7c098125fc967a5bdb3a56a1d25 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <[email protected]>
Date: Tue, 18 Aug 2015 20:27:48 +0200
Subject: [PATCH] maint: add syntax check to ensure larger man/*.x files have a
Copyright
* cfg.mk (sc_man_check_x_copyright): Add rule to ensure that non-trivial
.x files in the 'man/' subdirectory, i.e., files exceeding a line count
of 20 or a byte count of 1000, contain a proper Copyright notice.
---
cfg.mk | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/cfg.mk b/cfg.mk
index dedb7ac..ace3f5a 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -293,6 +293,20 @@ check-x-vs-1:
| $(ASSORT) -u | diff - $$t || { rm $$t; exit 1; }; \
rm $$t
+# Ensure that non-trivial .x files in the 'man/' subdirectory,
+# i.e., files exceeding a line count of 20 or a byte count of 1000,
+# contain a Copyright notice.
+.PHONY: sc_man_check_x_copyright
+sc_man_check_x_copyright:
+ @status=0; \
+ cd $(srcdir) && wc -cl man/*.x | head -n-1 \
+ | awk '$$1 >= 20 || $$2 >= 1000 {print $$3}' \
+ | xargs grep -L 'Copyright .* Free Software Foundation' \
+ | grep . \
+ && { echo 1>&2 '$@: exceeding file size/line count limit' \
+ '- please add a copyright note'; status=1; }; \
+ exit $$status
+
# Writing a portable rule to generate a manpage like '[.1' would be
# a nightmare, so filter that out.
all-progs-but-lbracket = $(filter-out [,$(patsubst src/%,%,$(all_programs)))
--
2.1.4