summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-08-03 10:43:52 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-08-03 10:43:52 -0400
commit09010ac6999db43e39cde92200fc4a10858f5c51 (patch)
treeb34d8ac968b31d8408409dd68094349a10cb589a
parentb4d0dc48d6dcf6a3ed5e8b1412268eaf1cedd1c9 (diff)
stuff
-rwxr-xr-xfind_includes52
-rw-r--r--test-header.c1
-rwxr-xr-xtest-header.sh2
3 files changed, 55 insertions, 0 deletions
diff --git a/find_includes b/find_includes
new file mode 100755
index 0000000000..6dfb406fa3
--- /dev/null
+++ b/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 "$@"
diff --git a/test-header.c b/test-header.c
new file mode 100644
index 0000000000..76e8197013
--- /dev/null
+++ b/test-header.c
@@ -0,0 +1 @@
+int main() { return 0; }
diff --git a/test-header.sh b/test-header.sh
new file mode 100755
index 0000000000..b11285af7d
--- /dev/null
+++ b/test-header.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+gcc -c -o /dev/null -I/usr/include/efi -I/usr/include/efi/x86_64 -I/usr/include/libmount $(find src -type d |sed 's|^|-I&|') -include ./config.h -include "$(realpath -- "$1")" test-header.c