commit 54af3e6987f380e29a1475fa434cb7daa2efd124 parent 0bbb647213314c0ff6977636a70422ecbd249a49 Author: Jacob R. Edwards <jacobouno@protonmail.com> Date: Sat, 28 Aug 2021 13:39:06 -0700 Add C function definition printing script It's not pretty and only works with a limited subset of valid function definitions so I hesitated to add it, but seeing as I use it often it's worth adding, even with it's faults. Diffstat:
| A | local/bin/.local/bin/cdef | | | 38 | ++++++++++++++++++++++++++++++++++++++ |
1 file changed, 38 insertions(+), 0 deletions(-)
diff --git a/local/bin/.local/bin/cdef b/local/bin/.local/bin/cdef @@ -0,0 +1,38 @@ +#!/usr/bin/awk -f +# Copyright 2021 Jacob R. Edwards +# License: GPLv3 +# cdef -- Print C function definitions +# +# Functions must be of the form: +# +# type +# name(...) { +# ... +# } +# + +BEGIN { + if (ARGV[1] == null) + exit(1); + name = "^" ARGV[1] "\\("; + delete ARGV[1]; +} + +match($0, name) { + indef = 1; + print last; +} + +indef { + print; + if (match($0, "^}$")) + exit(0); +} + +!indef { + last = $0; +} + +END { + exit(!indef); +}