diff options
| author | Louis Burda <quent.burda@gmail.com> | 2024-06-19 21:06:02 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2024-06-19 21:06:02 +0200 |
| commit | 614c44ef97fe4f1d91e4161bd77e028a9ee2d214 (patch) | |
| tree | 378fbbf5ee6de2a97a6159cd5ae74c260d546446 | |
| parent | be2d017c214f92a22d1f24520f841ea1180c9ab4 (diff) | |
| download | bgrep-master.tar.gz bgrep-master.zip | |
| -rw-r--r-- | bgrep.c | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -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; } |
