13e696dfbSEd Maste#!/bin/sh -u 23e696dfbSEd Maste 33e696dfbSEd Maste# Copyright (c) 2022 Yubico AB. All rights reserved. 43e696dfbSEd Maste# Use of this source code is governed by a BSD-style 53e696dfbSEd Maste# license that can be found in the LICENSE file. 6*2ccfa855SEd Maste# SPDX-License-Identifier: BSD-2-Clause 73e696dfbSEd Maste 83e696dfbSEd MasteT=$(mktemp -d) || exit 1 93e696dfbSEd Mastefind . -maxdepth 1 -type f -name '*.3' -print0 > "$T/files" 103e696dfbSEd Maste 113e696dfbSEd Mastexargs -0 awk '/^.Sh NAME/,/^.Nd/' < "$T/files" | \ 123e696dfbSEd Maste awk '/^.Nm/ { print $2 }' | sort -u > "$T/Nm" 133e696dfbSEd Mastexargs -0 awk '/^.Fn/ { print $2 }' < "$T/files" | sort -u > "$T/Fn" 143e696dfbSEd Maste(cd "$T" && diff -u Nm Fn) 153e696dfbSEd Maste 163e696dfbSEd Mastecut -c2- ../src/export.llvm | sort > "$T/exports" 173e696dfbSEd Maste(cd "$T" && diff -u Nm exports) 183e696dfbSEd Maste 193e696dfbSEd Masteawk '/^list\(APPEND MAN_SOURCES/,/^\)/' CMakeLists.txt | \ 203e696dfbSEd Maste awk '/.3$/ { print $1 }' | sort > "$T/listed_sources" 213e696dfbSEd Mastexargs -0 -n1 basename < "$T/files" | sort > "$T/actual_sources" 223e696dfbSEd Maste(cd "$T" && diff -u listed_sources actual_sources) 233e696dfbSEd Maste 243e696dfbSEd Masteawk '/^list\(APPEND MAN_ALIAS/,/^\)/' CMakeLists.txt | \ 253e696dfbSEd Maste sed '1d;$d' | awk '{ print $1, $2 }' | sort > "$T/listed_aliases" 263e696dfbSEd Mastexargs -0 grep -o "^.Fn [A-Za-z0-9_]* \"" < "$T/files" | \ 273e696dfbSEd Maste cut -c3- | sed 's/\.3:\.Fn//;s/ "//' | awk '$1 != $2' | \ 283e696dfbSEd Maste sort > "$T/actual_aliases" 293e696dfbSEd Maste(cd "$T" && diff -u listed_aliases actual_aliases) 303e696dfbSEd Maste 313e696dfbSEd Mastexargs -0 grep -hB1 "^.Fn [A-Za-z0-9_]* \"" < "$T/files" | \ 323e696dfbSEd Maste sed -E 's/^.F[tn] //;s/\*[^"\*]+"/\*"/g;s/ [^" \*]+"/"/g;/^--$/d' | \ 333e696dfbSEd Maste paste -d " " - - | sed 's/\* /\*/' | sort > "$T/documented_prototypes" 343e696dfbSEd Mastewhile read -r f; do 353e696dfbSEd Maste awk "/\/\*/ { next } /$f\(/,/;/" ../src/fido.h ../src/fido/*.h | \ 363e696dfbSEd Maste sed -E 's/^[ ]+//;s/[ ]+/ /' | tr '\n' ' ' | \ 373e696dfbSEd Maste sed 's/(/ "/;s/, /" "/g;s/);/"/;s/ $/\n/' 383e696dfbSEd Mastedone < "$T/exports" | sort > "$T/actual_prototypes" 393e696dfbSEd Maste(cd "$T" && diff -u documented_prototypes actual_prototypes) 403e696dfbSEd Maste 413e696dfbSEd Maste(cd "$T" && rm files Nm Fn exports listed_sources actual_sources \ 423e696dfbSEd Maste listed_aliases actual_aliases documented_prototypes actual_prototypes) 433e696dfbSEd Mastermdir -- "$T" 44