1#!/bin/sh -u 2 3# Copyright (c) 2022 Yubico AB. All rights reserved. 4# Use of this source code is governed by a BSD-style 5# license that can be found in the LICENSE file. 6 7T=$(mktemp -d) || exit 1 8find . -maxdepth 1 -type f -name '*.3' -print0 > "$T/files" 9 10xargs -0 awk '/^.Sh NAME/,/^.Nd/' < "$T/files" | \ 11 awk '/^.Nm/ { print $2 }' | sort -u > "$T/Nm" 12xargs -0 awk '/^.Fn/ { print $2 }' < "$T/files" | sort -u > "$T/Fn" 13(cd "$T" && diff -u Nm Fn) 14 15cut -c2- ../src/export.llvm | sort > "$T/exports" 16(cd "$T" && diff -u Nm exports) 17 18awk '/^list\(APPEND MAN_SOURCES/,/^\)/' CMakeLists.txt | \ 19 awk '/.3$/ { print $1 }' | sort > "$T/listed_sources" 20xargs -0 -n1 basename < "$T/files" | sort > "$T/actual_sources" 21(cd "$T" && diff -u listed_sources actual_sources) 22 23awk '/^list\(APPEND MAN_ALIAS/,/^\)/' CMakeLists.txt | \ 24 sed '1d;$d' | awk '{ print $1, $2 }' | sort > "$T/listed_aliases" 25xargs -0 grep -o "^.Fn [A-Za-z0-9_]* \"" < "$T/files" | \ 26 cut -c3- | sed 's/\.3:\.Fn//;s/ "//' | awk '$1 != $2' | \ 27 sort > "$T/actual_aliases" 28(cd "$T" && diff -u listed_aliases actual_aliases) 29 30xargs -0 grep -hB1 "^.Fn [A-Za-z0-9_]* \"" < "$T/files" | \ 31 sed -E 's/^.F[tn] //;s/\*[^"\*]+"/\*"/g;s/ [^" \*]+"/"/g;/^--$/d' | \ 32 paste -d " " - - | sed 's/\* /\*/' | sort > "$T/documented_prototypes" 33while read -r f; do 34 awk "/\/\*/ { next } /$f\(/,/;/" ../src/fido.h ../src/fido/*.h | \ 35 sed -E 's/^[ ]+//;s/[ ]+/ /' | tr '\n' ' ' | \ 36 sed 's/(/ "/;s/, /" "/g;s/);/"/;s/ $/\n/' 37done < "$T/exports" | sort > "$T/actual_prototypes" 38(cd "$T" && diff -u documented_prototypes actual_prototypes) 39 40(cd "$T" && rm files Nm Fn exports listed_sources actual_sources \ 41 listed_aliases actual_aliases documented_prototypes actual_prototypes) 42rmdir -- "$T" 43