]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
grepc, grepc.1: -tu: Search also within enum and type definitions
authorAlejandro Colomar <alx.manpages@gmail.com>
Sat, 14 May 2022 23:20:39 +0000 (01:20 +0200)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:29:02 +0000 (21:29 +0100)
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
bin/grepc
share/man/man1/grepc.1

index 173cf2b93d4efc12739f432ecae5f806cb87151c..32b1dd3d5a07b5a7ab7da85159e7d64151ed69e9 100755 (executable)
--- a/bin/grepc
+++ b/bin/grepc
@@ -268,6 +268,15 @@ grepc_type()
 }
 
 
+grepc_use_enum()
+{
+       grepc_helper \
+         '\benum\b' \
+         "\b$1\b" \
+         "(?s)^([\w[]+[\w\s]*)?\benum\b\s*([\w\s[\]]|::)*\s*{[^}]*^\s*\w+[\w\s[\]=]*\b$1\b.*?^}.*?;";
+}
+
+
 grepc_use_func_def()
 {
        grepc_helper \
@@ -308,10 +317,47 @@ grepc_use_macro()
 }
 
 
+grepc_use_type_struct_union()
+{
+       grepc_helper \
+         "\b(struct|union)\b" \
+         "\b$1\b" \
+         "(?s)^(?!^[ \t]*typedef\b)([\w[]([\w\s\(,\)[\]*]|::)*[\w\s\)*\]]\s+)?\b(struct|union)\s+\w+\s*[\w\s[\]]*{(?:(?!^}).)*?\b$1\b.*?^}.*?;";
+}
+
+
+grepc_use_type_typedef_simple()
+{
+       grepc_helper \
+         '^[ \t]*typedef\s' \
+         "\b$1\b" \
+         "(?s)^[ \t]*typedef\s+[^{};]*\b$1\b[^{};]+;";
+}
+
+
+grepc_use_type_typedef_struct_union()
+{
+       grepc_helper \
+         '^[ \t]*typedef\s+(struct|union)\b[^;]*$' \
+         "\b$1\b" \
+         "(?s)^[ \t]*typedef\s+(struct|union)\s+[\w\s[\]]*{(?:(?!^(  )?}|^\s*typedef).)*\b$1\b(?:(?!^(  )?}|^\s*typedef).)*^(  )?}\s*\w+;";
+}
+
+
+grepc_use_type()
+{
+       grepc_use_type_struct_union "$1";
+       grepc_use_type_typedef_simple "$1";
+       grepc_use_type_typedef_struct_union "$1";
+}
+
+
 grepc_use()
 {
+       grepc_use_enum "$1";
        grepc_use_func "$1";
        grepc_use_macro "$1";
+       grepc_use_type "$1";
 }
 
 
index d860ce473e074fbdce47c35651d400b63fa11da4..e504f5dc31a912a7055330378cff88956ed51b54 100644 (file)
@@ -55,8 +55,11 @@ Type definitions.
 Uses.
 Searches occurences of
 .BI \eb identifier \eb
-within function bodies and macro replacements,
-and prints the whole functions and/or macros.
+within enums (except as an enum constant),
+function bodies,
+macro replacements,
+and type definitions,
+and prints the whole enum, function, macro, and/or type definitions.
 .SH OPTIONS
 .TP
 .B \-g