summaryrefslogtreecommitdiffstats
path: root/check-manpages.sh
blob: 776365c534035c516866d6a794ac6f90abcf5916 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# SPDX-License-Identifier: LGPL-2.1
# Copyright (C) 2022, Google Inc, Steven Rostedt <rostedt@goodmis.org>
#
# This checks if any function is listed in a man page that is not listed
# in the main man page.

if [ $# -lt 1 ]; then
	echo "usage: check-manpages man-page-path"
	exit 1
fi

cd $1

MAIN=libtracefs
MAIN_FILE=${MAIN}.txt

PROCESSED=""

# Ignore man pages that do not contain functions
IGNORE="libtracefs-options.txt"

for man in ${MAIN}-*.txt; do

	for a in `sed -ne '/^NAME/,/^SYNOP/{/^[a-z]/{s/, *$//;s/,/\n/g;s/ //g;s/-.*$/-/;/-/{s/-//p;q};p}}' $man`; do
		if [ "${PROCESSED/:${a} /}" != "${PROCESSED}" ]; then
			P="${PROCESSED/:${a} */}"
			echo "Found ${a} in ${man} and in ${P/* /}"
		fi
		PROCESSED="${man}:${a} ${PROCESSED}"
		if [ "${IGNORE/$man/}" != "${IGNORE}" ]; then
			continue
		fi
		if ! grep -q '\*'${a}'\*' $MAIN_FILE; then
			if [ "$last" == "" ]; then
				echo
			fi
			if [ "$last" != "$man" ]; then
				echo "Missing functions from $MAIN_FILE that are in $man"
				last=$man
			fi
			echo "   ${a}"
		fi
	done
done

DEPRECATED="*tracefs_event_append_filter* *tracefs_event_verify_filter*"

sed -ne 's/^[a-z].*[ \*]\([a-z_][a-z_]*\)(.*/\1/p' -e 's/^\([a-z_][a-z_]*\)(.*/\1/p' ../include/tracefs.h | while read f; do
	if ! grep -q '\*'${f}'\*' $MAIN_FILE; then
		if [ "${DEPRECATED/\*$f\*/}" != "${DEPRECATED}" ]; then
			continue;
		fi
		if [ "$last" == "" ]; then
			echo
			echo "Missing functions from $MAIN_FILE that are in tracefs.h"
			last=$f
		fi
		echo "   ${f}"
	fi
done