]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
grepc: grepc_type_struct_union_enum: Increase robustness of regex
authorAlejandro Colomar <alx.manpages@gmail.com>
Fri, 6 May 2022 08:31:52 +0000 (10:31 +0200)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:28:45 +0000 (21:28 +0100)
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
bin/grepc

index a819cc4f550d9e5b33f6d1503d1ab8b18ecfbd1a..f223afaa7f9cbbc98794aede4265c69a1058ed8c 100755 (executable)
--- a/bin/grepc
+++ b/bin/grepc
@@ -72,8 +72,9 @@ function grepc_type_struct_union_enum()
        | grep '\.[ch]$' \
        | xargs grep -l "\b$1\b" \
        | sort \
-       | xargs pcregrep -Mn "(?s)^[\w\s]*?\b$1\b\s*[\w\s[\]]*{.*?^}.*?;" /dev/null \
-       | sed -E 's/^[^: ]+:[0-9]+:/\n\n&/';
+       | xargs pcregrep -Mn \
+         "(?s)^(struct|union|enum)\s+$1\b\s*[\w\s[\]]*{.*?^}.*?;" /dev/null \
+       | sed -E 's/^[^: ]+:[0-9]+:/\n\n&\n\n/';
 }
 
 
@@ -111,6 +112,7 @@ function grepc_type_typedef_underlying_struct_union_enum()
        | grep '\.[ch]$' \
        | xargs grep -h "^typedef .* *\b$1;" \
        | sed -e 's/^typedef //' -e "s/ *\b$1;.*//" \
+       | sed -e 's/^struct //' -e 's/^union //' -e 's/^enum //' \
        | while read t; do
                grepc_type_struct_union_enum "$t";
        done;