aboutsummaryrefslogtreecommitdiffstats
path: root/man/man1/grepc_c.1
blob: f743014a58a7125677b43d521eea3b3a7ba472f9 (plain)
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
.\" Copyright, the authors of the Linux man-pages project
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
.TH grepc_c 1 (date) "Linux man-pages (unreleased)"
.SH NAME
grepc_c \- print PCRE patterns for searching C code
.SH SYNOPSIS
.B grepc_c
.RI [ option\~ .\|.\|.\&]
.I pattern
.SH DESCRIPTION
.BR grepc_c (1)
is a driver for
.BR grepc (1).
It prints PCRE patterns that
.BR grepc (1)
will use to
search for declarations, definitions, and/or uses of
.I pattern
in C source code.
.P
.I pattern
is a PCRE pattern.
It normally represents a C identifier,
and word boundaries are implicitly added to it in most cases.
.SS Types of code
This program can produce PCRE pattern 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 \-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 EXAMPLES
.EX
.RB alx@devuan:\[ti]$ " grepc_c \-tm alignof" ;
(?s)\[ha][ \[rs]t]*#\[rs]s*define\[rs]s[\[rs]s\[rs]\[rs]]*alignof\[rs](.*?[\[ha]\[rs]\[rs]]$
(?s)\[ha][ \[rs]t]*#\[rs]s*define\[rs]s[\[rs]s\[rs]\[rs]]*alignof\[rs]b(?!\[rs]().*?(?<!\[rs]\[rs])$
.RB alx@devuan:\[ti]$ " cd /usr/lib/gcc/" ;
.RB alx@devuan:/usr/lib/gcc$ " pcre2grep \-rnMf <(grepc_c \-tm alignof) .";
\&./x86_64\-linux\-gnu/15/include/stdalign.h:33:#define alignof _Alignof
.EE
.SH SEE ALSO
.BR grepc (1),
.BR pcre2grep (1),
.BR pcre2syntax (3),
.BR pcre2pattern (3)