]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
grepc: grepc_enum_constant: Find enumeration constant definitions
authorAlejandro Colomar <alx.manpages@gmail.com>
Sun, 8 May 2022 20:04:55 +0000 (22:04 +0200)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:28:46 +0000 (21:28 +0100)
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
bin/grepc

index 107fae3602e241e03682de09e4a39e6db6905376..dd33a16976442df49737ccb47518c0bc0b0ec045 100755 (executable)
--- 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";