diff options
Diffstat (limited to 'tools/notsd-find-includes')
-rwxr-xr-x | tools/notsd-find-includes | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/notsd-find-includes b/tools/notsd-find-includes new file mode 100755 index 0000000000..6dfb406fa3 --- /dev/null +++ b/tools/notsd-find-includes @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +phase=phase0 + +phase0() { + phase=phase0 + local line="$1" + case "$line" in + '#include'*|'typedef '*';') + phase1 "$line" + ;; + *) + ;; + esac +} + +phase1() { + phase=phase1 + local line="$1" + case "$line" in + '') + ;; + '#include'*) + ;; + 'typedef '*';') + ;; + *) + phase2 "$line" + ;; + esac +} + +phase2() { + phase=phase2 + local line="$1" + printf '%s\n' "$line" + cat +} + +main() { + current_file="$1" + set -o pipefail + { + IFS='' + while read -r line; do + "$phase" "$line" + IFS='' + done + } < "$current_file" | grep '^#include' | ifne printf '%s\n' "$current_file" +} + +main "$@" |