xaizek / zograscope (License: AGPLv3 only) (since 2018-12-07)
Mainly a syntax-aware diff that also provides a number of additional tools.
<root> / man / zs-find.1 (726fb1ef7818b0dfab6b62b4aacf58e312b478a5) (3,250B) (mode 100644) [raw]
'\" t
.\" Automatically generated by Pandoc 2.17.1.1
.\"
.\" Define V font for inline verbatim, using C font in formats
.\" that render this, and otherwise B font.
.ie "\f[CB]x\f[]"x" \{\
. ftr V B
. ftr VI BI
. ftr VB B
. ftr VBI BI
.\}
.el \{\
. ftr V CR
. ftr VI CI
. ftr VB CB
. ftr VBI CBI
.\}
.TH "zs-find" "1" "July 19, 2022" "" ""
.hy
.SH NAME
.PP
\f[I]zs-find\f[R] is a tool for searching in code.
Applications include things like collecting crude statistics about the
code, looking for certain nested configurations or sequences of tokens.
.PP
The syntax and matching abilities are relatively basic and are subject
to significant changes in the future.
.SH INVOCATION
.PP
\f[V]zs-find\f[R] \f[V][options...]\f[R] \f[I][paths\&...]\f[R] :
\f[I]matchers\&...\f[R]
.PP
\f[V]zs-find\f[R] \f[V][options...]\f[R] \f[I][paths\&...]\f[R] :
\f[I][matchers\&...]\f[R] : \f[I][expressions\&...]\f[R]
.PP
\f[V]zs-find\f[R] \f[V][options...]\f[R] \f[I][paths\&...]\f[R] ::
\f[I]expressions\&...\f[R]
.PP
Paths can specify both files and directories.
When no path is specified, \[lq].\[rq] is assumed.
.PP
Either \f[I]matchers\&...\f[R], \f[I]expressions\&...\f[R] or both must
be specified.
.SS Tool-specific Options
.PP
\f[V]-c\f[R], \f[V]--count\f[R]
.PD 0
.P
.PD
only count matches and report statistics
.PP
\f[V]--lang\f[R]
.PD 0
.P
.PD
here this common option also limits set of files to process
.SS Matchers
.PP
.TS
tab(@);
l l.
T{
Matcher
T}@T{
Description
T}
_
T{
\f[V]decl\f[R]
T}@T{
Any sort of declaration
T}
T{
\f[V]stmt\f[R]
T}@T{
Statements
T}
T{
\f[V]func\f[R]
T}@T{
Functions (their definitions only)
T}
T{
\f[V]call\f[R]
T}@T{
Function invocations
T}
T{
\f[V]param\f[R]
T}@T{
Parameters of a function
T}
T{
\f[V]comm\f[R]
T}@T{
Comments of any kind
T}
T{
\f[V]dir\f[R]
T}@T{
Preprocessor-alike directives
T}
T{
\f[V]block\f[R]
T}@T{
Containers of statements
T}
.TE
.SS Expressions
.PP
Each expressions matches a single token.
.PP
.TS
tab(@);
l l.
T{
Expr
T}@T{
What it matches
T}
_
T{
\f[V]x\f[R]
T}@T{
Exactly \f[V]x\f[R]
T}
T{
\f[V]/\[ha]x/\f[R]
T}@T{
Any token that starts with \f[V]x\f[R]
T}
T{
\f[V]/x$/\f[R]
T}@T{
Any token that ends with \f[V]x\f[R]
T}
T{
\f[V]/\[ha]x$/\f[R]
T}@T{
Exactly \f[V]x\f[R]
T}
T{
\f[V]/x/\f[R]
T}@T{
Any token that contains \f[V]x\f[R] as a substring
T}
T{
\f[V]//x/\f[R]
T}@T{
Regular expression \f[V]x\f[R]
T}
T{
\f[V]//\f[R]
T}@T{
Any token
T}
.TE
.SH EXAMPLES
.PP
List all comments in C files:
.IP
.nf
\f[C]
zs-find --lang c : dir
\f[R]
.fi
.PP
Count number of preprocessor directives inside functions in all
supported languages:
.IP
.nf
\f[C]
zs-find --count src/ : func dir
\f[R]
.fi
.PP
Print functions of a specific file if they contain \f[V]return\f[R]
statement:
.IP
.nf
\f[C]
zs-find src/utils/time.hpp : func : return
\f[R]
.fi
.PP
List all statements containing uses of \f[V]exec()\f[R] family of
functions:
.IP
.nf
\f[C]
zs-find : stmt : \[aq]//\[ha](execl[pe]?|execvp?e?)$/\[aq]
\f[R]
.fi
.PP
List all invocations of \f[V]snprintf\f[R] which have single token as
the first argument:
.IP
.nf
\f[C]
zs-find ../src : call : snprintf \[aq](\[aq] // ,
\f[R]
.fi
.SH SEE ALSO
.PP
\f[B]zograscope\f[R](7) for common options and list of all tools there.
.SH AUTHORS
xaizek <xaizek@posteo.net>.
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/zograscope

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/zograscope

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master