diff options
author | Alejandro Colomar <alx.manpages@gmail.com> | 2022-05-20 04:00:04 +0200 |
---|---|---|
committer | Alejandro Colomar <alx.manpages@gmail.com> | 2022-05-20 04:00:04 +0200 |
commit | e3e43645b2333c8f3bc4297c0e6ce5b491641823 (patch) | |
tree | 6218c246fa895fb8c7f6eda243ba10e1e5c2d57f | |
parent | 52fe165923565b402e1ac7ffb52a134c294a1c8f (diff) |
grepc, grepc.1: -tu: Allow searching special characters
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
-rwxr-xr-x | bin/grepc | 14 | ||||
-rw-r--r-- | share/man/man1/grepc.1 | 22 |
2 files changed, 22 insertions, 14 deletions
@@ -327,7 +327,7 @@ 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.*?^}.*?;' \ + '(?s)^([\w[]+[\w\s]*)?\benum\b\s*([\w\s[\]]|::)*\s*{[^}]*^\s*\w+[\w\s[\]=]*'"$1"'.*?^}.*?;' \ <"$files"; } @@ -337,7 +337,7 @@ grepc_use_func_def() grepc_helper \ "\b$1\b" \ '.' \ - '(?s)^[\w[]([\w\s\(,\)[\]*]|::)*[\w\s\)*\]]\s+\**\w+\s*\([\w\s\(,\)[\]*]+?(...)?\)\s*{(?:(?!^}).)*\b'"$1"'\b.*?^}' \ + '(?s)^[\w[]([\w\s\(,\)[\]*]|::)*[\w\s\)*\]]\s+\**\w+\s*\([\w\s\(,\)[\]*]+?(...)?\)\s*{(?:(?!^}).)*'"$1"'.*?^}' \ <"$files"; } @@ -347,7 +347,7 @@ grepc_linux_use_func_syscall_def() grepc_helper \ "SYSCALL_DEFINE.\(" \ "\b$1\b" \ - '(?s)^(COMPAT_)?SYSCALL_DEFINE.\(\w+\b(?:(?!^}).)*\b'"$1"'\b.?^}' \ + '(?s)^(COMPAT_)?SYSCALL_DEFINE.\(\w+\b(?:(?!^}).)*'"$1"'.?^}' \ <"$files"; } @@ -370,7 +370,7 @@ grepc_use_macro() grepc_helper \ "\b$1\b" \ 'define' \ - '(?s)^[ \t]*#\s*define\s+\w+\b(\([^\)]*\))?(?:(?![^\\]$).)*\b'"$1"'\b.*?[^\\]$' \ + '(?s)^[ \t]*#\s*define\s+\w+\b(\([^\)]*\))?(?:(?![^\\]$).)*'"$1"'.*?[^\\]$' \ <"$files"; } @@ -380,7 +380,7 @@ 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.*?^}.*?;' \ + '(?s)^(?!^[ \t]*typedef\b)([\w[]([\w\s\(,\)[\]*]|::)*[\w\s\)*\]]\s+)?\b(struct|union)\s+\w+\s*[\w\s[\]]*{(?:(?!^}).)*?'"$1"'.*?^}.*?;' \ <"$files"; } @@ -390,7 +390,7 @@ grepc_use_type_typedef_simple() grepc_helper \ '^[ \t]*typedef\s' \ "\b$1\b" \ - '(?s)^[ \t]*typedef\s+[^{};]*\b'"$1"'\b[^{};]+;' \ + '(?s)^[ \t]*typedef\s+[^{};]*'"$1"'[^{};]+;' \ <"$files"; } @@ -400,7 +400,7 @@ 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+;' \ + '(?s)^[ \t]*typedef\s+(struct|union)\s+[\w\s[\]]*{(?:(?!^( )?}|^\s*typedef).)*'"$1"'(?:(?!^( )?}|^\s*typedef).)*^( )?}\s*\w+;' \ <"$files"; } diff --git a/share/man/man1/grepc.1 b/share/man/man1/grepc.1 index b23e5d9..e2d2279 100644 --- a/share/man/man1/grepc.1 +++ b/share/man/man1/grepc.1 @@ -4,19 +4,19 @@ grepc \- find C declarations, definitions, and uses in source code .SH SYNOPSIS .B grepc .RI [ option\~ .\|.\|.\&] -.I identifier +.I pattern .RI [ file\~ .\|.\|.] .SH DESCRIPTION .MR grepc 1 searches for C declarations, definitions, and uses of -.I identifier +.I pattern in each .IR file . .PP -.I identifier -is normally a C identifier, -but it is actually a PCRE pattern, -so it can be used to find complex patterns. +.I pattern +is a PCRE pattern. +It normally represents a C identifier, +and word boundaries are implicitly added to it in most cases. .PP If .I file @@ -75,12 +75,20 @@ Type definitions. .B u Uses. Searches occurences of -.BI \eb identifier \eb +.I pattern within enums, function bodies, macro replacements, and type definitions, and prints the whole enum, function, macro, and/or type definitions. +In this case there are no word boundaries set by default, +so if +.I pattern +is +.BR open , +.B fopen +will also be found; +that's to allow searching for patterns containing any sequence of characters. .IP This can be further subdivided into: .RS |