summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeLines
* bin/grepc: Ignore a shellcheck(1) warningHEADmainAlejandro Colomar2023-11-05-0/+1
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Compact cases a little bit)Alejandro Colomar2023-11-05-16/+8
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Remove unnecessary comment)Alejandro Colomar2023-11-05-1/+1
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Use printf '%s\n' instead of echo)Alejandro Colomar2023-11-05-21/+21
| | | | | Reported-by: terdon <https://linux.codidact.com/users/57088> Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Use bash(1) array variable)Alejandro Colomar2023-11-05-12/+3
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Remove grepc_search() and main())Alejandro Colomar2023-11-05-43/+29
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Remove grepc_patterns())Alejandro Colomar2023-11-05-27/+26
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Remove grepc_parse_cmd())Alejandro Colomar2023-11-05-84/+79
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Simplify 'case's thanks to bash(1)'s ';;&')Alejandro Colomar2023-11-05-75/+43
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Escape '?' in bash(1) case following getopts(1))Alejandro Colomar2023-11-05-1/+1
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Compact single-line cases)Alejandro Colomar2023-11-05-57/+19
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc, grepc.1: -c: Add option to count matchesAlejandro Colomar2023-11-05-2/+15
| | | | | | As in pcre2grep(1) and grep(1). Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc, grepc.1: Rename option -c to -rAlejandro Colomar2023-11-05-10/+11
| | | | | | | 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>
* grepc.1: -c: Remove outdated sentenceAlejandro Colomar2023-11-05-3/+0
| | | | | | | | Since 2be04e240dea ("bin/grepc: Optimize"), we color also in ther types of code. Update the manual page. Fixes: 2be04e240dea ("bin/grepc: Optimize") Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc, grepc.1: Use 'l' instead of 's' for Linux system callsAlejandro Colomar2023-11-05-20/+20
| | | | | | To avoid confusion to users of other kernels. Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Reorder some function definitions)Alejandro Colomar2023-11-05-1/+1
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc, grepc.1: -n: Add option to control printing of line numbersAlejandro Colomar2023-11-05-3/+11
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Actually create file with mktemp(1))Alejandro Colomar2023-11-05-1/+1
| | | | | | This ensures we own the file, removing any races. Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Add some tabs, and remove a function)Alejandro Colomar2023-11-05-23/+22
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc, grepc.1: -A, -B, -C: Add flags for printing context.Alejandro Colomar2023-11-05-1/+31
| | | | | | These flags are passed to pcre2grep(1). Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Variables for options hold their '-')Alejandro Colomar2023-11-05-7/+14
| | | | | | | This is to allow adding options that have arguments that are passed to pcre2grep(1). Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc, grepc.1: -h: Add option to suppress prefixing file namesAlejandro Colomar2023-11-05-3/+10
| | | | | | Equivalent to grep(1)'s -h, except that we always default to -H behavior. Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: srcfix (Add missing variable definition)Alejandro Colomar2023-11-05-0/+1
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc, grepc.1: Remove -h flagAlejandro Colomar2023-11-05-8/+1
| | | | | | | | 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>
* bin/grepc: srcfix (Change variable names)Alejandro Colomar2023-11-05-19/+19
| | | | | | Use single-letter names for variables that hold command-line options. Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc, grepc.1: Always enable recursive mode; remove -rAlejandro Colomar2023-11-05-18/+15
| | | | | | | | | | | | | | | 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 55dd5d7255c8 ("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>
* Add recursive search back in with -rAlejandro Colomar2023-11-03-3/+32
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* Allow specifying several filesAlejandro Colomar2023-11-03-8/+3
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Don't use pcre2grep(1)'s --labelAlejandro Colomar2023-11-03-3/+1
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Simplify (remove grepc_search())Alejandro Colomar2023-11-03-9/+5
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Compact codeAlejandro Colomar2023-11-03-10/+2
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: OptimizeAlejandro Colomar2023-11-03-236/+57
| | | | | | | | | | | | | 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.
* Don't find files recursivelyAlejandro Colomar2023-11-03-56/+64
| | | | | | | | | | | | | | | 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>
* Remove '-g' optionAlejandro Colomar2023-11-03-14/+2
| | | | | | | 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>
* Remove '-x' optionAlejandro Colomar2023-11-03-19/+1
| | | | | | | 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>
* bin/grepc, grepc.1: -tmf, -tmo: Add options to find only function-like ↵Alejandro Colomar2023-11-03-10/+24
| | | | | | macros, or other macros Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Shorten function namesAlejandro Colomar2023-11-03-43/+43
| | | | | | Also, use names consistent with the command-line option arguments. Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Shorten variable namesAlejandro Colomar2023-11-03-117/+96
| | | | | | Also, use names consistent with the command-line option arguments. Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Simplify (remove grepc_use_func())Alejandro Colomar2023-11-03-13/+11
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Simplify (remove grepc_use_type())Alejandro Colomar2023-11-03-16/+18
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Simplify (remove grepc_type())Alejandro Colomar2023-11-03-18/+24
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Simplify (remove grepc_type_typedef())Alejandro Colomar2023-11-03-8/+2
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Simplify (remove grepc_macro())Alejandro Colomar2023-11-03-12/+10
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Compact one-liner definitionsAlejandro Colomar2023-11-03-26/+5
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Simplify (remove grepc_glibc_func_def())Alejandro Colomar2023-11-03-14/+14
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Improve error messagesAlejandro Colomar2023-11-03-11/+7
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Transform some if's to simpler test&&Alejandro Colomar2023-11-03-39/+26
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Simplify (remove grepc_use())Alejandro Colomar2023-11-03-26/+15
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Simplify (remove grepc_glibc_func())Alejandro Colomar2023-11-03-20/+11
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>
* bin/grepc: Simplify (remove grepc_linux_func())Alejandro Colomar2023-11-03-20/+11
| | | | Signed-off-by: Alejandro Colomar <alx@kernel.org>