]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
grepc, grepc.1: -tu: Allow searching special characters
authorAlejandro Colomar <alx.manpages@gmail.com>
Fri, 20 May 2022 02:00:04 +0000 (04:00 +0200)
committerAlejandro Colomar <alx@kernel.org>
Wed, 29 Oct 2025 20:29:04 +0000 (21:29 +0100)
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
bin/grepc
share/man/man1/grepc.1

index 1563815c733a7a947c9eabe44066300813652ff7..7b7aa61a78f42071dfbc34716f4cb6fbefc89181 100755 (executable)
--- a/bin/grepc
+++ b/bin/grepc
@@ -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";
 }
 
index b23e5d9e59cc599cbe7726a99875dd1ffc4b9944..e2d2279353d97f7349c4f431ae7ad8388e5ab42f 100644 (file)
@@ -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