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";
}
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";
}
grepc_helper \
"SYSCALL_DEFINE.\(" \
"\b$1\b" \
- '(?s)^(COMPAT_)?SYSCALL_DEFINE.\(\w+\b(?:(?!^}).)*\b'"$1"'\b.?^}' \
+ '(?s)^(COMPAT_)?SYSCALL_DEFINE.\(\w+\b(?:(?!^}).)*'"$1"'.?^}' \
<"$files";
}
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";
}
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";
}
grepc_helper \
'^[ \t]*typedef\s' \
"\b$1\b" \
- '(?s)^[ \t]*typedef\s+[^{};]*\b'"$1"'\b[^{};]+;' \
+ '(?s)^[ \t]*typedef\s+[^{};]*'"$1"'[^{};]+;' \
<"$files";
}
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";
}
.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
.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