summaryrefslogtreecommitdiffstats
path: root/bin/grepc
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2022-05-08 22:04:55 +0200
committerAlejandro Colomar <alx.manpages@gmail.com>2022-05-08 22:44:24 +0200
commitcc589772ab8f77996a070928291f47002cee09b0 (patch)
treeaf4e1385dd72c161901707de1ce68259303f02b4 /bin/grepc
parent3df50d106af5de5adca5e8b6a21c6d34cdac8c73 (diff)
grepc: grepc_enum_constant: Find enumeration constant definitions
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Diffstat (limited to 'bin/grepc')
-rwxr-xr-xbin/grepc13
1 files changed, 13 insertions, 0 deletions
diff --git a/bin/grepc b/bin/grepc
index 107fae3..dd33a16 100755
--- a/bin/grepc
+++ b/bin/grepc
@@ -36,6 +36,18 @@ function grepc_macro()
}
+function grepc_enum_constant()
+{
+ find . -type f \
+ | grep '\.[ch]$' \
+ | xargs grep -l "\b$1\s*=" \
+ | sort \
+ | xargs pcregrep -Mn \
+ "(?s)\benum\b\s*[\w\s[\]]*{[^}]*\b$1\s*[=,].*?^}.*?;" /dev/null \
+ | sed -E 's/^[^: ]+:[0-9]+:/\n\n&\n\n/';
+}
+
+
function grepc_func_decl()
{
find . -type f \
@@ -168,6 +180,7 @@ function grepc_type()
function main()
{
grepc_macro "$1";
+ grepc_enum_constant "$1";
grepc_func "$1";
grepc_syscall "$1";
grepc_type "$1";