summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2022-05-15 01:20:39 +0200
committerAlejandro Colomar <alx.manpages@gmail.com>2022-05-15 01:21:36 +0200
commit9450b556e1bd3da2d9073a970d6f44ccf0b33d36 (patch)
tree34a9a2cd74e7fdd2fdf4f203c5937c302f147b0e /bin
parent44d6c152f776a991fdbe43d39e1bcbf164337b98 (diff)
grepc, grepc.1: -tu: Search also within enum and type definitions
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/grepc46
1 files changed, 46 insertions, 0 deletions
diff --git a/bin/grepc b/bin/grepc
index 173cf2b..32b1dd3 100755
--- 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";
}