summaryrefslogtreecommitdiff
path: root/tools/find_includes
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-09-10 18:59:03 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-09-10 18:59:03 -0400
commit12e3360f833dbc83e995aed1ba67b74fc95e3ec3 (patch)
treebed8d2ce2309e2bab18cdab0931fb60d290c3fa9 /tools/find_includes
parent2a5c8b237b1b0303bf6d0f6cc762bb9cafac35c9 (diff)
sync other tools from master
Diffstat (limited to 'tools/find_includes')
-rwxr-xr-xtools/find_includes52
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/find_includes b/tools/find_includes
new file mode 100755
index 0000000000..6dfb406fa3
--- /dev/null
+++ b/tools/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 "$@"