bgrep

Grep for binary files
git clone https://git.sinitax.com/sinitax/bgrep
Log | Files | Refs | LICENSE | sfeed.txt

commit 614c44ef97fe4f1d91e4161bd77e028a9ee2d214
parent be2d017c214f92a22d1f24520f841ea1180c9ab4
Author: Louis Burda <quent.burda@gmail.com>
Date:   Wed, 19 Jun 2024 21:06:02 +0200

Minor tweaks

Diffstat:
Mbgrep.c | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/bgrep.c b/bgrep.c @@ -1,14 +1,16 @@ #define PCRE2_CODE_UNIT_WIDTH 8 + #include <pcre2.h> #include <unistd.h> + #include <stdio.h> #include <stdarg.h> #include <string.h> #include <stdbool.h> #include <stdlib.h> -static const char *marker = "\n"; +static const char *marker = ""; static const char *pattern = NULL; static bool overlap = false; static size_t group = 0; @@ -85,11 +87,11 @@ writef(const char *fmt, ...) va_start(cpy, fmt); vsnprintf(buf, bufsize, fmt, cpy); va_end(cpy); - + writeall(buf, size); } -void +static void parse(int argc, const char **argv) { const char **arg; @@ -148,7 +150,7 @@ main(int argc, const char **argv) filecap = BUFSIZ; filesize = 0; file = malloc(filecap); - if (!file) die("mallo:"); + if (!file) die("malloc:"); pos = 0; lastmatch = 0; @@ -183,9 +185,9 @@ main(int argc, const char **argv) lastmatch = ovector[1]; } - writef("0x%zx:", filesize + ovector[0]); + writef("%s:0x%zx:", marker, filesize + ovector[0]); writeall(match, match_size); - writef("%s", marker); + writef("\n"); } else { break; }