public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/9] Add a target to check example programs
@ 2022-01-07 16:46 Stephen Kitt
  2022-01-07 16:46 ` [PATCH 2/9] seccomp.2: Use syscall() in the example code Stephen Kitt
                   ` (9 more replies)
  0 siblings, 10 replies; 31+ messages in thread
From: Stephen Kitt @ 2022-01-07 16:46 UTC (permalink / raw)
  To: Alejandro Colomar, Michael Kerrisk; +Cc: linux-man, Stephen Kitt

This is a first step to automating example program checks. It extracts
source snippets introduced by "Program source", assuming it's C, and
attempts to compile it.

For now, only man pages with a single "Program source" entry are
processed. The compiled code isn't linked to avoid having to handle
library requirements (e.g. -ldl).

Signed-off-by: Stephen Kitt <steve@sk2.org>
---
 Makefile | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/Makefile b/Makefile
index 0da0328d8..3f597d7c3 100644
--- a/Makefile
+++ b/Makefile
@@ -266,6 +266,23 @@ check-groff-warnings:
 	done; \
 	rm -f "$$GROFF_LOG"
 
+# Check that man pages' examples programs (for now, only pages with a
+# single program) actually compile
+.PHONY: check-example-programs
+check-example-programs:
+	GCC_LOG="$$(mktemp --tmpdir manpages-checksXXXX)" || exit $$?; \
+	for manpage in $$(grep -rc 'Program source' man?/* | grep ':1$$' | cut -d: -f1); \
+	do \
+		(man -Tutf8 $$manpage | \
+			col -bx | \
+			sed -n '/Program source/,/^[[:space:]]\{0,3\}[^[:space:]]/p' | \
+			tail -n+2 | \
+			head -n-1 | \
+			gcc -xc -c -o/dev/null -) 2>| "$$GCC_LOG"; \
+		[ -s "$$GCC_LOG" ] && { echo "$$manpage: "; cat "$$GCC_LOG"; echo; }; \
+	done; \
+	rm -f "$$GCC_LOG"
+
 # someone might also want to look at /var/catman/cat2 or so ...
 # a problem is that the location of cat pages varies a lot
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2022-01-08 19:38 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-07 16:46 [PATCH 1/9] Add a target to check example programs Stephen Kitt
2022-01-07 16:46 ` [PATCH 2/9] seccomp.2: Use syscall() in the example code Stephen Kitt
2022-01-08  1:18   ` Alejandro Colomar (man-pages)
2022-01-07 16:46 ` [PATCH 3/9] inet.3: Switch to _DEFAULT_SOURCE in the example Stephen Kitt
2022-01-08  1:26   ` Alejandro Colomar (man-pages)
2022-01-08  9:06     ` Stephen Kitt
2022-01-07 16:46 ` [PATCH 4/9] matherr.3: Exclude the example from analysis Stephen Kitt
2022-01-08  1:31   ` Alejandro Colomar (man-pages)
2022-01-08  9:12     ` Stephen Kitt
2022-01-07 16:46 ` [PATCH 5/9] mq_notify.3: Add signal.h for SIGEV_THREAD Stephen Kitt
2022-01-08  1:38   ` Alejandro Colomar (man-pages)
2022-01-07 16:46 ` [PATCH 6/9] newlocale.3: Use LC_GLOBAL_LOCALE, not ..._HANDLE Stephen Kitt
2022-01-08  1:41   ` Alejandro Colomar (man-pages)
2022-01-08  9:13     ` Jakub Wilk
2022-01-08 17:58       ` Alejandro Colomar (man-pages)
2022-01-07 16:46 ` [PATCH 7/9] pkeys.7: Update the example to match glibc Stephen Kitt
2022-01-08  1:59   ` Alejandro Colomar (man-pages)
2022-01-08 14:18     ` Stephen Kitt
2022-01-08 19:20       ` Alejandro Colomar (man-pages)
2022-01-07 16:46 ` [PATCH 8/9] strtok.3: Enable example analysis, fix declaration Stephen Kitt
2022-01-08  2:04   ` Alejandro Colomar (man-pages)
2022-01-07 16:46 ` [PATCH 9/9] malloc_info.3: Use intptr_t to store pointers Stephen Kitt
2022-01-08  2:25   ` Alejandro Colomar (man-pages)
2022-01-08 10:30     ` Jakub Wilk
2022-01-08 17:09       ` Stephen Kitt
2022-01-08 19:17       ` Alejandro Colomar (man-pages)
2022-01-08  1:15 ` [PATCH 1/9] Add a target to check example programs Alejandro Colomar (man-pages)
2022-01-08  9:22   ` Stephen Kitt
2022-01-08 19:05     ` Alejandro Colomar (man-pages)
2022-01-08 19:38       ` Alejandro Colomar (man-pages)
2022-01-08  2:02 ` Alejandro Colomar (man-pages)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox