summary refs log tree commit diff
path: root/home/.local/bin/def
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-02-01 00:53:05 -0500
committerJune McEnroe <june@causal.agency>2019-02-01 00:53:05 -0500
commit23f1902a07c792fe10c1649259eaf4b80a6f6c43 (patch)
treef2b6e5cc3e9f66d777faabd3129d084ae735832d /home/.local/bin/def
parentAdd beef to README (diff)
downloadsrc-23f1902a07c792fe10c1649259eaf4b80a6f6c43.tar.gz
src-23f1902a07c792fe10c1649259eaf4b80a6f6c43.zip
Add def script
Diffstat (limited to '')
-rwxr-xr-xhome/.local/bin/def47
1 files changed, 47 insertions, 0 deletions
diff --git a/home/.local/bin/def b/home/.local/bin/def
new file mode 100755
index 00000000..ea8b9536
--- /dev/null
+++ b/home/.local/bin/def
@@ -0,0 +1,47 @@
+#!/bin/sh
+set -eu
+
+macro=$1
+headers='
+assert.h
+complex.h
+ctype.h
+errno.h
+fenv.h
+float.h
+inttypes.h
+iso646.h
+limits.h
+locale.h
+math.h
+setjmp.h
+signal.h
+stdalign.h
+stdarg.h
+stdatomic.h
+stdbool.h
+stddef.h
+stdint.h
+stdio.h
+stdlib.h
+stdnoreturn.h
+string.h
+tgmath.h
+threads.h
+time.h
+uchar.h
+wchar.h
+wctype.h
+'
+
+for header in $headers; do
+	defined=$(
+		echo "$macro" \
+		| cc -E -x c -include "$header" - \
+		2> /dev/null \
+		| tail -n 1
+	)
+	[ $? -ne 0 -o "$defined" = "$macro" ] && continue
+	echo "#include <$header>"
+	echo "$defined"
+done