summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2022-05-13 17:17:45 +0200
committerAlejandro Colomar <alx.manpages@gmail.com>2022-05-13 17:22:27 +0200
commit3342a8422ba72e4df937262a688ecc174eb9099f (patch)
tree83f23b1f5719260c68a19c515d286f6aa7e984c8 /bin
parent44156f8553271c7b29a3fc02f718a278dd4dc194 (diff)
grepc, grepc.1: Add -tu to search for uses
Reported-by: наб <nabijaczleweli@nabijaczleweli.xyz> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/grepc55
1 files changed, 55 insertions, 0 deletions
diff --git a/bin/grepc b/bin/grepc
index 0687095..97346c9 100755
--- a/bin/grepc
+++ b/bin/grepc
@@ -11,6 +11,7 @@ t_enum='no';
t_func='no';
t_macro='no';
t_type='no';
+t_use='no';
grepc_usage()
@@ -47,6 +48,9 @@ grepc_parse_cmd()
t)
t_type='yes';
;;
+ u)
+ t_use='yes';
+ ;;
*)
grepc_usage;
exit 1;
@@ -259,12 +263,60 @@ grepc_type()
}
+grepc_use_func_def()
+{
+ grepc_helper \
+ "\b$1\b" \
+ '.' \
+ "(?s)^[\w[]([\w\s\(,\)[\]*]|::)*[\w\s\)*\]]\s+\**\w+\s*\([\w\s\(,\)[\]*]+?(...)?\)\s*{(?:(?!^}).)*\b$1\b.*?^}";
+}
+
+
+grepc_linux_use_func_syscall_def()
+{
+ grepc_helper \
+ "SYSCALL_DEFINE.\(" \
+ "\b$1\b" \
+ "(?s)^(COMPAT_)?SYSCALL_DEFINE.\(\w+\b(?:(?!^}).)*\b$1\b.?^}";
+}
+
+
+grepc_linux_use_func()
+{
+ grepc_linux_use_func_syscall_def "$1";
+}
+
+
+grepc_use_func()
+{
+ grepc_use_func_def "$1";
+ grepc_linux_use_func "$1";
+}
+
+
+grepc_use_macro()
+{
+ grepc_helper \
+ "\b$1\b" \
+ 'define' \
+ '(?s)^[ \t]*#\s*define\s+\w+\b(\([^\)]*\))?(?:(?![^\\]$).)*'"$1"'.*?[^\\]$';
+}
+
+
+grepc_use()
+{
+ grepc_use_func "$1";
+ grepc_use_macro "$1";
+}
+
+
grepc_search_default()
{
grepc_enum_constant "$1";
grepc_func "$1";
grepc_macro "$1";
grepc_type "$1";
+ grepc_use "$1";
}
@@ -286,6 +338,9 @@ grepc_search()
if [ "$t_type" = 'yes' ]; then
grepc_type "$1";
fi;
+ if [ "$t_use" = 'yes' ]; then
+ grepc_use "$1";
+ fi;
fi;
}