summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2022-05-24 23:50:09 +0200
committerAlejandro Colomar <alx.manpages@gmail.com>2022-05-24 23:50:09 +0200
commitb8d34e9013e9091f2b3fc7e6c35f9d986126bc95 (patch)
tree2d8d135f9402bfe4674892ab5ca1d042982ad0d9
parent56fcdb34f28f1b697ef96b583ed6dd997d85649b (diff)
grepc: Fix some typedef corner cases
- Typedefs to arrays of structures. - Typedefs to structures of the same name. Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
-rwxr-xr-xbin/grepc6
1 files changed, 3 insertions, 3 deletions
diff --git a/bin/grepc b/bin/grepc
index 51a638f..c60e587 100755
--- 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";
}