summaryrefslogtreecommitdiffstats
path: root/share/man/man1/grepc.1
blob: aa69c7bd2a82696248b0a909c26b5866558d41e0 (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
.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
.I file
is a directory,
the search is recursive within that directory.
If
.I file
doesn't match a certain extension, it is skipped
(see
.B \-x
in OPTIONS).
If no
.I file
is given,
the working directory is searched.
.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 fs
Linux kernel system calls.
This can be further subdivided into:
.RS
.TP
.B fsp
Linux kernel system call prototypes.
.TP
.B fsd
Linux kernel system call definitions.
.RE
.RE
.TP
.B m
Macro definitions.
.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
.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 \-g
Restrict the search to files tracked by git.
.TP
.B \-h
Output a help message and exit.
.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
.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" .
.TP
.BI \-x " extension"
Restrict the search to files ending with
.IR extension .
It is interpreted as a PCRE pattern.
Default:
.BR \e.[ch]$ .
.SH EXAMPLES
.EX
.RB \(ti/src/nginx/unit$ " grepc 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 git-ls-files 1 ,
.MR pcregrep 1 ,
.MR pcresyntax 3 ,
.MR pcrepattern 3
.PP
Homepage:
.UR http://www.alejandro-colomar.es/\:src/\:alx/\:alx/\:grepc.git
.UE