diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2022-05-09 00:09:03 +0200 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2022-05-09 00:30:23 +0200 |
commit | 1fe3dfd6764de63f6b592c4c7b7dc0b00e880813 (patch) | |
tree | 4463fd0294441a2a60f214c6d4799881ffdbd785 /bin/grepc | |
parent | 28aaec2dae105ed81dcf8bb213b5a7355347a203 (diff) |
grepc: grepc_type*: Simplify finding typedefs
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Diffstat (limited to 'bin/grepc')
-rwxr-xr-x | bin/grepc | 20 |
1 files changed, 7 insertions, 13 deletions
@@ -121,13 +121,13 @@ function grepc_type_struct_union_enum() } -function grepc_type_typedef_oneline() +function grepc_type_typedef_simple() { find . -type f \ | grep '\.[ch]$' \ - | xargs grep -lP "^typedef .* $1;" \ + | xargs grep -lP "\b$1;" \ | sort \ - | xargs grep -nP "^typedef .* $1;" /dev/null \ + | xargs pcregrep -Mn "(?s)^typedef\s+[^;]+$1;" /dev/null \ | sed -E 's/^[^: ]+:[0-9]+:/\n\n&\n\n/'; } @@ -136,16 +136,10 @@ function grepc_type_typedef_struct_union_enum() { find . -type f \ | grep '\.[ch]$' \ - | xargs grep -lP "^} $1;" \ + | xargs grep -lP "^}\s*$1;" \ | sort \ - | while read f; do - grep -nP "^} $1;" $f /dev/null \ - | sed -E 's/^([^: ]+:[0-9]+:).*/\n\n\1\n/'; - - tac <$f \ - | pcregrep -Mh "(?s)^typedef\s.*^}\s*$1;" \ - | tac; - done; + | xargs pcregrep -Mn "(?s)^typedef\s(?:(?!^}).)*^}\s*$1;" /dev/null \ + | sed -E 's/^[^: ]+:[0-9]+:/\n\n&\n\n/'; } @@ -164,7 +158,7 @@ function grepc_type_typedef_underlying_struct_union_enum() function grepc_type_typedef() { - grepc_type_typedef_oneline "$1"; + grepc_type_typedef_simple "$1"; grepc_type_typedef_struct_union_enum "$1"; grepc_type_typedef_underlying_struct_union_enum "$1"; } |