]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
grepc: Fix some typedef corner cases
authorAlejandro Colomar <alx.manpages@gmail.com>
Tue, 24 May 2022 21:50:09 +0000 (23:50 +0200)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:29:07 +0000 (21:29 +0100)
- Typedefs to arrays of structures.
- Typedefs to structures of the same name.

Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
bin/grepc

index 51a638fe8bef49f497373f57fc626d26af769124..c60e587eac4776baf36a550f8d99bfc7884a4af2 100755 (executable)
--- a/bin/grepc
+++ b/bin/grepc
@@ -263,7 +263,7 @@ grepc_type_struct_union_enum()
        grepc_helper \
          '\b(struct|union|enum)\b([\w \t[\]]|::)+\b'"$1"'\b' \
          '.' \
-         '(?s)^(?!^[ \t]*typedef\b)([\w[]([\w\s\(,\)[\]*]|::)*[\w\s\)*\]]\s+)?\b(struct|union|enum)\b([\w \t[\]]|::)+\b'"$1"'\b[ \t]*\n*([ \t]*){.*?^\5}.*?;';
+         '(?s)^([\w[]([\w\s\(,\)[\]*]|::)*[\w\s\)*\]]\s+)?\b(struct|union|enum)\b([\w \t[\]]|::)+\b'"$1"'\b[ \t]*\n*([ \t]*){.*?^\5}.*?;';
 }
 
 
@@ -281,8 +281,8 @@ grepc_type_typedef_struct_union_enum()
 {
        grepc_helper \
          '^[ \t]*typedef\s+(struct|union|enum)\b[^;]*$' \
-         "^[ \t]*}\s*$1;" \
-         '(?s)^[ \t]*typedef\s+(struct|union|enum)\b([\w \t[\]]|::)*\n*([ \t]*){(?:(?!^\3}).)*?^\3}\s*'"$1"';' \
+         "^[ \t]*}\s*$1(\[[\w\(,\)]\])*;" \
+         '(?s)^[ \t]*typedef\s+(struct|union|enum)\b(?:(?!\W'"$1"'\W)([\w \t[\]]|::))*\n*([ \t]*){(?:(?!^\3}).)*?^\3}\s*'"$1"'(\[[\w\(,\)]\])*;' \
          <"$files";
 }