]>
git.ipfire.org Git - thirdparty/man-pages.git/log
Alejandro Colomar [Wed, 5 Nov 2025 15:27:26 +0000 (16:27 +0100)]
src/bin/grepc_c: -tuf: Split regex for the function body
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 5 Nov 2025 15:07:30 +0000 (16:07 +0100)]
src/bin/grepc_c: -tuf: Fix regex
Fixes: 91c6563acf5e (2025-10-29; "grepc, grepc.1: Add -tu to search for uses")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 5 Nov 2025 14:44:02 +0000 (15:44 +0100)]
src/bin/grepc_c: -tuf: Reuse grepc_c_fld_decl_()
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 5 Nov 2025 14:40:05 +0000 (15:40 +0100)]
src/bin/grepc_c: -tfld: Split regex
This will be reused for -tuf.
I copied '[\w\s,;[\]*\?:+-]*\)' from grepc_c_f_params_().
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 5 Nov 2025 14:31:52 +0000 (15:31 +0100)]
src/bin/grepc_c: -tfd: Split regex for the function body
This regex part will be reused by other regexes.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 5 Nov 2025 13:58:25 +0000 (14:58 +0100)]
src/bin/grepc_c: -tflp: Simplify implementation
This reuses the regex used by -tfp.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 5 Nov 2025 13:37:20 +0000 (14:37 +0100)]
src/bin/grepc_c: -tf: These can appear in a parameter list: '+', '-', '?', ':'
This adds support for function declarators such as:
int
main(int argc, char *argv[argc + 1]);
char *
seprintf(char dst[], const char end[];
char dst[dst ? end - dst : 0], const char end[0],
const char *restrict fmt, ...);
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 5 Nov 2025 13:26:14 +0000 (14:26 +0100)]
src/bin/grepc_c: -tf: Use a named capturing group
This allows $identifier to contain capturing groups.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 5 Nov 2025 13:22:36 +0000 (14:22 +0100)]
src/bin/grepc_c: Split regex
The regex for a function declarator is too complex. Split it into
helper functions that prints the parts of the regex, so that each one
is easier to understand.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 5 Nov 2025 17:49:35 +0000 (18:49 +0100)]
share/mk/: $SHELLCHECKFLAGS: Disable SC2028
It's known that echo(1) doesn't expand anything. No need to warn.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 5 Nov 2025 12:43:49 +0000 (13:43 +0100)]
src/bin/grepc_*: Use echo(1) instead of printf(1) where possible
echo(1) is fine as long as the first argument doesn't start with a dash.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 5 Nov 2025 12:40:02 +0000 (13:40 +0100)]
src/bin/grepc_c: srcfix (align code)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 4 Nov 2025 14:27:30 +0000 (15:27 +0100)]
src/bin/grepc: -r, -l: Don't color the output of -l
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 4 Nov 2025 14:18:43 +0000 (15:18 +0100)]
src/bin/grepc: -r: Simplify implementation, removing a conditional
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 4 Nov 2025 14:11:50 +0000 (15:11 +0100)]
src/bin/grepc: -r: Reimplement with grep(1)
With grep(1), we don't need to hard-code escape sequences.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 3 Nov 2025 10:30:20 +0000 (11:30 +0100)]
src/bin/sortman: Fix portability issue
POSIX allows blank characters before '!', but not after.
Reported-by: <onf@disroot.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 2 Nov 2025 20:29:04 +0000 (21:29 +0100)]
src/bin/grepc: -x: Simplify implementation
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 2 Nov 2025 20:04:24 +0000 (21:04 +0100)]
man/man1/grepc{,_c}.1: Split documentation into a manual page for the driver
I've left grepc_mk undocumented for the moment, as it's still not
as stable as the C driver.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 2 Nov 2025 16:11:42 +0000 (17:11 +0100)]
src/bin/grepc{,_c,_mk}: Align code after split
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 2 Nov 2025 15:50:50 +0000 (16:50 +0100)]
src/bin/grepc{,_c,_mk}: Split grepc(1) into helper programs
These programs print the PCRE2 patterns used by grepc(1). This allows
easily implementing different drivers for parsing different languages.
It also allows easily using pcre2grep(1) in cases where grepc(1) might
be limited; for example, searching in non-regular files, or passing
other flags that grepc(1) doesn't pass to pcre2grep(1).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 2 Nov 2025 19:11:44 +0000 (20:11 +0100)]
src/bin/: Disable pathname expansion
We don't use globs within these scripts, so disable them, for safety
reasons.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 2 Nov 2025 15:44:18 +0000 (16:44 +0100)]
src/bin/grepc: Add missing quotes
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 31 Oct 2025 11:48:12 +0000 (12:48 +0100)]
man/man1/grepc.1: SEE ALSO: Fix references
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 31 Oct 2025 10:50:28 +0000 (11:50 +0100)]
man/man1/grepc.1: ffix
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 30 Oct 2025 23:58:42 +0000 (00:58 +0100)]
src/bin/grepc: Handle xargs(1) errors properly
'xargs grep' is hard, because grep(1) exits with a status of 1 for no
match, which is not an error, but xargs(1) takes that as an error, which
is confused with other errors.
This trick with sh(1) was suggested by Paul, and nicely solves this
problem.
We also need to change $opts to be a normal variable.
We can't export bash array variables, and passing them to sh(1) -c is
not great; escapes could be messed. It's more robust to use a normal
variable.
Link: <https://lists.gnu.org/archive/html/bug-grep/2025-10/msg00029.html>
Suggested-by: Paul Eggert <eggert@cs.ucla.edu>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 22:38:20 +0000 (23:38 +0100)]
src/bin/grepc: Use the same error code as grep(1)
Exit with 2 on error.
If nothing matches, it's a success, and it exits with 0 normally.
This is different from grep(1), but I don't know how to write
the script to exit with 1 if nothing matches.
This implementation may also ignore some xargs(1) errors. A future
commit --with code suggested by Paul Eggert-- will fix this.
Link: <https://software.codidact.com/posts/294883>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 2 Nov 2025 16:01:18 +0000 (17:01 +0100)]
src/bin/grepc: Use if/then/fi instead of &&
It will allow using 'set -Eeuo pipefail' and trap(1) ERR.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 30 Oct 2025 09:50:40 +0000 (10:50 +0100)]
man/man1/grepc.1: EXAMPLES: Fix command
The output shows the line number, so it must have been called with -n.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 30 Oct 2025 09:41:55 +0000 (10:41 +0100)]
src/bin/grepc: Refactor to avoid process substitution
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 22:43:37 +0000 (23:43 +0100)]
src/bin/grepc: Add defensive check
This is safer than silencing shellcheck(1).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 22:40:38 +0000 (23:40 +0100)]
src/bin/grepc: Add defensive check
In theory, getopts(1) will make sure that no other values arrive here.
However, it's easy to add a check, and that will be safer than silencing
shellcheck(1).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 22:34:55 +0000 (23:34 +0100)]
src/bin/grepc: srcfix (Simplify case/esac)
We don't need ';;&' since the commit referenced below.
Fixes: 0ba68dd03564 (2024-09-19, 2025-10-29; "bin/grepc, grepc.1: -k: Remove flag")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 21:49:26 +0000 (22:49 +0100)]
Adapt grepc(1) to the Linux man-pages project
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 21:20:43 +0000 (22:20 +0100)]
man/man1/grepc.1: Use a smaller example
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 21:12:09 +0000 (22:12 +0100)]
src/bin/grepc: Use if/else instead of && and ||
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 21:04:50 +0000 (22:04 +0100)]
src/bin/grepc: Quote variables
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 21:01:59 +0000 (22:01 +0100)]
src/bin/grepc: Ignore shellcheck(1) diagnostics
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 20:57:48 +0000 (21:57 +0100)]
src/bin/grepc: Use test(1) instead of [(1)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 20:47:15 +0000 (21:47 +0100)]
man/man1/grepc.1, src/bin/grepc: Add copyright notice
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 20:39:01 +0000 (21:39 +0100)]
src/bin/grepc: Handle errors
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 20:37:02 +0000 (21:37 +0100)]
man/man1/grepc.1: Adapt to the Linux man-pages project
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 20:31:08 +0000 (21:31 +0100)]
man/man1/grepc.1: Move manual page to man/man1/
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 20:30:18 +0000 (21:30 +0100)]
src/bin/grepc: Move script to src/bin/
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 29 Oct 2025 20:48:02 +0000 (21:48 +0100)]
Import grepc(1) (script and manual page) from separate project
It started as a script in the Linux man-pages project, under scripts/
within scripts/bash_aliases.
Eventually, I turned it into a large script, and moved it into a
separate project, to be able to work on it more freely.
The original scripts were removed from this project in commit
c3752af0549c (2022-11-22; "bash_aliases: Remove grep_syscall(),
grep_syscall_def(), and grep_glibc_prototype()").
Now, grepc(1) has stabilized, and I find it very useful for maintaining
this project (as well as others), so let's merge it back. This will
allow distros to package it sooner than if it remained as a standalone
project.
I've imported the git history (ignoring files we don't care about) with
the help of git-filter-repo(1).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 9 Oct 2025 19:03:23 +0000 (21:03 +0200)]
bin/grepc: -tuf: Reuse grepc_c_f_decl_() for the function declarator
It's slightly different than the regex we were using, but I can't see a
reason for it. It was probably due to forgetting to improve this regex.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 9 Oct 2025 18:59:15 +0000 (20:59 +0200)]
bin/grepc: -tf: Factor out regex for function declarators
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 9 Oct 2025 10:36:08 +0000 (12:36 +0200)]
bin/grepc: -tt: Add word boundary around the identifier
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 3 May 2025 12:37:19 +0000 (14:37 +0200)]
bin/grepc: Add robustness against non-portable pathnames
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 1 Mar 2025 16:52:43 +0000 (17:52 +0100)]
bin/grepc: Use <() instead of $()
Files are simpler to handle. It results in less flags, and simpler
command invocations. And it allows breaking the line more nicely,
without having to break in the middle of a quoted region.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Wed, 27 Nov 2024 12:50:53 +0000 (13:50 +0100)]
bin/grepc: -tfp, -tfd: Add support for forward-declarations of parameters
This is currently a (very useful) GNU extension, and soon might become
standard in C2y.
Link: n3394 <https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3394.pdf>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 19 Sep 2024 12:12:57 +0000 (14:12 +0200)]
bin/grepc, grepc.1: -k: Remove flag
Just behave like grep(1) and pcre2grep(1). If the user wants to see it
more nicely, they can do it themselves.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Tue, 7 Nov 2023 17:06:55 +0000 (18:06 +0100)]
bin/grepc: bugfix: Pass options to grep(1) correctly
Fixes: 92dca8e97bfa ("bin/grepc: srcfix (Variables for options hold their '-')")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 10 May 2024 10:42:01 +0000 (12:42 +0200)]
bin/, man/: -m: Add flag, and pass it to pcre2grep(1)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Mon, 26 Feb 2024 23:43:09 +0000 (00:43 +0100)]
bin/grepc: -x: c, mk: Add support for Makefile code
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 16:56:08 +0000 (17:56 +0100)]
bin/grepc: Ignore a shellcheck(1) warning
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 16:47:27 +0000 (17:47 +0100)]
bin/grepc: srcfix (Compact cases a little bit)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 16:43:22 +0000 (17:43 +0100)]
bin/grepc: srcfix (Remove unnecessary comment)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 16:33:26 +0000 (17:33 +0100)]
bin/grepc: srcfix (Use printf '%s\n' instead of echo)
Reported-by: terdon <https://linux.codidact.com/users/57088>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 15:59:21 +0000 (16:59 +0100)]
bin/grepc: srcfix (Use bash(1) array variable)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 15:29:23 +0000 (16:29 +0100)]
bin/grepc: srcfix (Remove grepc_search() and main())
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 15:26:02 +0000 (16:26 +0100)]
bin/grepc: srcfix (Remove grepc_patterns())
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 15:23:10 +0000 (16:23 +0100)]
bin/grepc: srcfix (Remove grepc_parse_cmd())
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 14:14:39 +0000 (15:14 +0100)]
bin/grepc: srcfix (Simplify 'case's thanks to bash(1)'s ';;&')
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 16:41:06 +0000 (17:41 +0100)]
bin/grepc: srcfix (Escape '?' in bash(1) case following getopts(1))
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 12:39:23 +0000 (13:39 +0100)]
bin/grepc: srcfix (Compact single-line cases)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 12:31:33 +0000 (13:31 +0100)]
bin/grepc, grepc.1: -c: Add option to count matches
As in pcre2grep(1) and grep(1).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 12:23:29 +0000 (13:23 +0100)]
bin/grepc, grepc.1: Rename option -c to -r
This leaves -c unused, so we can add -c with the same meaning of
grep(1): count.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 12:14:51 +0000 (13:14 +0100)]
grepc.1: -c: Remove outdated sentence
Since
83cfbb6042d1 ("bin/grepc: Optimize"), we color also in ther types
of code. Update the manual page.
Fixes: 83cfbb6042d1 ("bin/grepc: Optimize")
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 12:06:15 +0000 (13:06 +0100)]
bin/grepc, grepc.1: Use 'l' instead of 's' for Linux system calls
To avoid confusion to users of other kernels.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 12:03:15 +0000 (13:03 +0100)]
bin/grepc: srcfix (Reorder some function definitions)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 02:12:53 +0000 (03:12 +0100)]
bin/grepc, grepc.1: -n: Add option to control printing of line numbers
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 01:49:37 +0000 (02:49 +0100)]
bin/grepc: srcfix (Actually create file with mktemp(1))
This ensures we own the file, removing any races.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sun, 5 Nov 2023 01:47:09 +0000 (02:47 +0100)]
bin/grepc: srcfix (Add some tabs, and remove a function)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 4 Nov 2023 21:00:57 +0000 (22:00 +0100)]
bin/grepc, grepc.1: -A, -B, -C: Add flags for printing context.
These flags are passed to pcre2grep(1).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 4 Nov 2023 20:53:13 +0000 (21:53 +0100)]
bin/grepc: srcfix (Variables for options hold their '-')
This is to allow adding options that have arguments that are passed to
pcre2grep(1).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 4 Nov 2023 20:47:44 +0000 (21:47 +0100)]
bin/grepc, grepc.1: -h: Add option to suppress prefixing file names
Equivalent to grep(1)'s -h, except that we always default to -H behavior.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 4 Nov 2023 20:04:32 +0000 (21:04 +0100)]
bin/grepc: srcfix (Add missing variable definition)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 4 Nov 2023 19:59:06 +0000 (20:59 +0100)]
bin/grepc, grepc.1: Remove -h flag
There's already a manual page, and the short help from -h was quite
unhelpful. I want to reuse -h for grep(1)'s meaning (don't print the
filename).
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 4 Nov 2023 19:56:16 +0000 (20:56 +0100)]
bin/grepc: srcfix (Change variable names)
Use single-letter names for variables that hold command-line options.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Sat, 4 Nov 2023 19:45:11 +0000 (20:45 +0100)]
bin/grepc, grepc.1: Always enable recursive mode; remove -r
The non-recursive behavior is so slow that it's quite useless. It is
only useful when reading from standard input, but for several files it's
useless. Make '-r' the default when any files are specified, and remove
the flag (since now it's always enabled). This happens to bring back a
behavior close to what we had before
2fb22befdfb9 ("Don't find files recursively").
Non-seekable files can still be read, if redirected to standard input.
Update the example from the manual page to reflect current usage.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 3 Nov 2023 21:21:30 +0000 (22:21 +0100)]
Add recursive search back in with -r
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 3 Nov 2023 17:48:51 +0000 (18:48 +0100)]
Allow specifying several files
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 3 Nov 2023 17:46:09 +0000 (18:46 +0100)]
bin/grepc: Don't use pcre2grep(1)'s --label
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 3 Nov 2023 17:26:00 +0000 (18:26 +0100)]
bin/grepc: Simplify (remove grepc_search())
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 3 Nov 2023 17:23:44 +0000 (18:23 +0100)]
bin/grepc: Compact code
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 3 Nov 2023 16:41:22 +0000 (17:41 +0100)]
bin/grepc: Optimize
Call pcre2grep(1) only once, which allows removing named pipes. This is
an important optimization, and will also allow accepting several file
names in the command line (in a future commit). The source code is also
significantly simplified.
It has a caveat: this single call to pcre2grep(1) will consume more
resources, and will crash on certain input files. The workaround is to
restrict the search to just one or a few types of code. Document this
in the manual page. This caveat only applies to very specific files,
which so far I've only found in the Linux kernel source tree.
Alejandro Colomar [Fri, 3 Nov 2023 14:08:49 +0000 (15:08 +0100)]
Don't find files recursively
grep only one file (or stdin).
The current implementation doesn't allow filterin standard input, which
I miss some times. I'm removing this feature now, to be able to rewrite
most of the program in a way that allows filtering stdin, and then will
consider adding back a recursive mode if necessary.
Also, don't remove the two blanks at the start of the output, for
consistency when calling this program via xargs(1), which will become
more common now that it only handles single files.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 2 Nov 2023 15:11:45 +0000 (16:11 +0100)]
Remove '-g' option
This program shouldn't know about file names. If that is wanted, use
something like `find ... | grep ... | xargs grepc ...`.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 2 Nov 2023 15:08:31 +0000 (16:08 +0100)]
Remove '-x' option
This program shouldn't know about file extensions. If that is wanted,
use something like `find ... | grep ... | xargs grepc ...`.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 3 Nov 2023 00:16:42 +0000 (01:16 +0100)]
bin/grepc, grepc.1: -tmf, -tmo: Add options to find only function-like macros, or other macros
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Fri, 3 Nov 2023 00:01:07 +0000 (01:01 +0100)]
bin/grepc: Shorten function names
Also, use names consistent with the command-line option arguments.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 2 Nov 2023 19:12:31 +0000 (20:12 +0100)]
bin/grepc: Shorten variable names
Also, use names consistent with the command-line option arguments.
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 2 Nov 2023 18:52:57 +0000 (19:52 +0100)]
bin/grepc: Simplify (remove grepc_use_func())
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 2 Nov 2023 18:38:43 +0000 (19:38 +0100)]
bin/grepc: Simplify (remove grepc_use_type())
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 2 Nov 2023 18:33:54 +0000 (19:33 +0100)]
bin/grepc: Simplify (remove grepc_type())
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 2 Nov 2023 18:30:00 +0000 (19:30 +0100)]
bin/grepc: Simplify (remove grepc_type_typedef())
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 2 Nov 2023 18:21:22 +0000 (19:21 +0100)]
bin/grepc: Simplify (remove grepc_macro())
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 2 Nov 2023 18:15:33 +0000 (19:15 +0100)]
bin/grepc: Compact one-liner definitions
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 2 Nov 2023 18:10:43 +0000 (19:10 +0100)]
bin/grepc: Simplify (remove grepc_glibc_func_def())
Signed-off-by: Alejandro Colomar <alx@kernel.org>
Alejandro Colomar [Thu, 2 Nov 2023 17:52:04 +0000 (18:52 +0100)]
bin/grepc: Improve error messages
Signed-off-by: Alejandro Colomar <alx@kernel.org>