summaryrefslogtreecommitdiff
path: root/tools/notsd-find-includes
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-09-10 19:15:49 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-09-10 19:15:49 -0400
commit151b9b1d3524b565e7d3a7fa43b86e6bf66ac0e9 (patch)
tree436492f8f63543feb0ec0483bd05195d255137d0 /tools/notsd-find-includes
parent12e3360f833dbc83e995aed1ba67b74fc95e3ec3 (diff)
clean up tools/
Diffstat (limited to 'tools/notsd-find-includes')
-rwxr-xr-xtools/notsd-find-includes52
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 "$@"