logo

bootstrap-initrd

Linux initrd generator to bootstrap a POSIX-ish system from a reasonably small binary seed git clone https://hacktivis.me/git/make-initrd.git
commit: f3b26efff86c5c6631da0c9f4f6e0662b9bfad0d
parent 18701dae6fddca053a98f465a2ac422155dfdda6
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 30 Apr 2024 00:15:58 +0200

grep-stub.c: Fix $ anchor vs. newline

Diffstat:

Mgrep-stub.c8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/grep-stub.c b/grep-stub.c @@ -37,13 +37,17 @@ do_grep(FILE *stream, char *filename) int count = 0; - while(getline(&line, &len, stream) != -1) + ssize_t nread = 0; + while((nread = getline(&line, &len, stream)) != -1) { + if(line[nread-1] == '\n') line[nread-1] = 0; + bool found = false; if(fixed_str) { for(struct char_list *pattern = patterns; pattern != NULL; pattern = pattern->next) { + // FIXME: Case insensitive (strcasestr) if(strstr(line, pattern->data) != NULL) { found = true; @@ -68,7 +72,7 @@ do_grep(FILE *stream, char *filename) if(found != invert) { count++; - if(!count_only) printf("%s", line); + if(!count_only) printf("%s\n", line); } }