summaryrefslogtreecommitdiff
path: root/mk.sh
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2019-02-07 19:00:39 -0500
committerJakob Kaivo <jkk@ung.org>2019-02-07 19:00:39 -0500
commit716b33a7a9ee156f56fbb70de42a0adfb1e208a5 (patch)
tree468e910db5405847eb4bfacb0657538a163eaab4 /mk.sh
parentdf54a68c5ad145a0edbfbbb32261dc45c49b7bcb (diff)
fix multi-line macros by looking for ^{tab}
Diffstat (limited to 'mk.sh')
-rw-r--r--mk.sh48
1 files changed, 48 insertions, 0 deletions
diff --git a/mk.sh b/mk.sh
index 9f71b941..35345bcc 100644
--- a/mk.sh
+++ b/mk.sh
@@ -49,3 +49,51 @@ version_guard () {
rm -f $parsed
}
+
+get_declaration () {
+ case ${2:-$(classify_source $1)} in
+
+ REFERENCE)
+ ref="$(grep -F 'REFERENCE(' $1 | m4 -DREFERENCE='$1')"
+ if (echo "$ref" | grep -q '<.*>'); then
+ echo "$ref"
+ else
+ get_declaration "src/${ref}"
+ fi
+ ;;
+
+ MACRO)
+ grep -E '^(#(if|def|undef|el|end)| )' $1
+ ;;
+
+ TYPE|TYPE_LONG|RECORD|FNTYPE)
+ if grep -q '^#if' $1; then
+ sed -ne '/^#if/,/#endif/p' $1
+ elif grep -qE '^(typedef|struct|union) .*{' $1; then
+ sed -ne '/{$/,/^}/p' $1
+ else
+ grep -E '^(typedef|struct|union) ' $1
+ fi
+ ;;
+
+ EXTERN)
+ echo "extern $(grep '^[a-zA-Z_].*;$' $1)"
+ ;;
+
+ FUNCTION)
+ echo "$(grep '^[a-zA-Z_].*)' $1 | head -n1);"
+ ;;
+
+ TGFN)
+ echo "$(grep TGFN $1 | m4 -DTGFN='$1' -DTYPE='double');"
+ echo "$(grep TGFN $1 | m4 -DTGFN='$1f' -DTYPE='float');"
+ echo "$(grep TGFN $1 | m4 -DTGFN='$1l' -DTYPE='long double');"
+ ;;
+
+ *)
+ # unknown type, so try guessing
+ get_declaration $1
+ ;;
+
+ esac
+}