summaryrefslogtreecommitdiffstats
path: root/share/man/man1/grepc.1
blob: cabad95c767c96326ab4eefb408e3449a25a54ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
.TH GREPC 1 2022-05-09 grepc "User commands"
.SH NAME
grepc \- find C declarations, definitions, and uses in source code
.SH SYNOPSIS
.B grepc
.RI [ option\~ .\|.\|.\&]
.I pattern
.RI [ file\~ .\|.\|.\&]
.SH DESCRIPTION
.MR grepc 1
searches for C declarations, definitions, and/or uses of
.I pattern
in each
.IR file .
.PP
.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 no
.I file
is given,
this program reads standard input.
Otherwise,
it reads all files specified,
and searches under any specified directories, recursively,
without following symbolic links.
.SS Types of code
This program can search for several types of code.
The following arguments can be passed to the
.B \-t
option
to select the types of code that will be searched.
.TP
.B e
enum constant definitions.
.TP
.B f
Function prototypes and definitions.
This can be further subdivided into:
.RS
.TP
.B fp
Function prototypes.
.TP
.B fd
Function definitions.
.TP
.B fl
Linux kernel system calls.
This can be further subdivided into:
.RS
.TP
.B flp
Linux kernel system call prototypes.
.TP
.B fld
Linux kernel system call definitions.
.RE
.TP
.B fg
Glibc internal names of libc functions.
This can be further subdivided into:
.RS
.TP
.B fgp
Glibc prototypes.
.TP
.B fgd
Glibc definitions.
.RE
.RE
.TP
.B m
Macro definitions.
.RS
.TP
.B mf
Function-like macro definitions.
.TP
.B mo
Other macro definitions.
.RE
.TP
.B t
Type definitions.
.TP
.B u
Uses.
Searches occurences of
.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
.TP
.B ue
Uses within enum definitions (except as an enum constant).
.TP
.B uf
Uses within function definition bodies.
.TP
.B um
Uses within macro replacements.
.TP
.B ut
Uses within type definitions
(except enum; that is: typedef, struct, or union).
.RE
.SH OPTIONS
.TP
.BI \-A \~n
Print
.I n
lines of trailing context after a match.
.TP
.BI \-B \~n
Print
.I n
lines of leading context before a match.
.TP
.BI \-C \~n
Print
.I n
lines of context surrounding a match.
.TP
.B \-c
Surround the matched strings
with escape sequences to display them in color on the terminal.
Only uses
.RB ( u\fI*\fP )
are highlighted.
.TP
.B \-h
Suppress the prefixing of file names on output.
.TP
.B \-i
Ignore case distinctions in
.IR pattern .
.TP
.B \-k
Compact (kurz) output.
Don't print extra newlines
(the header is printed in the same line as the first line of a match).
.TP
.B \-l
Suppress normal output;
instead print the name of each input file
from which output would normally have been printed.
Each file is only printed once.
.TP
.B \-n
Prefix each line of output with the
1-based line number within its input file.
.TP
.BI \-t " type"
Restrict the search to a specific
.I type
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" .
.SH CAVEATS
.SS Crashes
In some cases,
internal calls to
.MR pcre2grep 1
may fail after consuming too much resources.
To solve that,
restrict the "types of code" of your search.
.SS Seekable files
Files specified in the command line
must be seekable and able to be opened twice.
If you need to read a non-seekable file,
redirect it to the standard input.
.SH EXAMPLES
.EX
.RB \(ti/src/nginx/unit$ " grepc \-n nxt_sprintf .;"
\&
\&
\&./src/nxt_sprintf.h:15:
NXT_EXPORT u_char *nxt_cdecl nxt_sprintf(u_char *buf, u_char *end,
    const char *fmt, ...);
\&
\&
\&./src/nxt_sprintf.c:58:
u_char * nxt_cdecl
nxt_sprintf(u_char *buf, u_char *end, const char *fmt, ...)
{
    u_char   *p;
    va_list  args;

    va_start(args, fmt);
    p = nxt_vsprintf(buf, end, fmt, args);
    va_end(args);

    return p;
}
.EE
.SH AUTHORS
Originally written by
.MT alx.manpages@gmail.com
Alejandro Colomar
.ME .
.SH SEE ALSO
.MR pcre2grep 1 ,
.MR pcresyntax 3 ,
.MR pcrepattern 3
.PP
Homepage:
.UR http://www.alejandro-colomar.es/\:src/\:alx/\:alx/\:grepc.git
.UE