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

[libvirt] [PATCH 5/6] syntax-check: Don't include duplicate header



---
 cfg.mk | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/cfg.mk b/cfg.mk
index 394521e..9cf4cff 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -722,6 +722,20 @@ sc_prohibit_exit_in_tests:
 	halt='use return, not exit(), in tests'				\
 	  $(_sc_search_regexp)
 
+# Don't include duplidate header in the source (either *.c or *.h)
+sc_prohibit_duplicate_header:
+	@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then	\
+	  for i in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do		\
+	    for j in $$(grep '^# *include.*\.h' $$i			\
+	      | awk -F' ' '{print $$NF}'); do				\
+	      test $$(grep "^# *include $$j" $$i | wc -l) -gt 1 &&	\
+		{ echo '$(ME): Duplidate header '$$j' in '$$i'' 1>&2;	\
+		  exit 1; } || :;					\
+	    done;							\
+	  done;								\
+	else :;								\
+	fi
+
 # We don't use this feature of maint.mk.
 prev_version_file = /dev/null
 
-- 
1.8.1.4


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