]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
grepc, grepc.1: Add -tu to search for uses
authorAlejandro Colomar <alx.manpages@gmail.com>
Fri, 13 May 2022 15:17:45 +0000 (17:17 +0200)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:29:00 +0000 (21:29 +0100)
Reported-by: наб <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
bin/grepc
share/man/man1/grepc.1

index 0687095c5704c832ceb9524f77863b2747593b1c..97346c95925e9bb6701b956ad20e2ca04d70e4af 100755 (executable)
--- 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;
 }
 
index 8bae0ee1476a0a0e62bfe1d2ed316c2a9c649f26..b54b0208644fddae25cdac2c7adb98347c84bb94 100644 (file)
@@ -50,6 +50,13 @@ Macro definitions.
 .TP
 .B t
 Type definitions.
+.TP
+.B u
+Uses.
+Searches occurences of
+.BI \eb identifier \eb
+within function bodies and macro replacements,
+and prints the whole functions and/or macros.
 .SH OPTIONS
 .TP
 .B \-g
@@ -70,7 +77,7 @@ of code (see Types of code under DESCRIPTION).
 This option can be passed multiple times
 to search for various types of code.
 Default:
-.BR "e f m t" .
+.BR "e f m t u" .
 .TP
 .BI \-x " extension"
 Restrict the search to files ending with