Main patch. - Lauri
-- http://www.fastmail.fm - IMAP accessible web-mail
From 8ca7017c19ce188768d3646df73890caf690201a Mon Sep 17 00:00:00 2001 From: Lauri Kasanen <[email protected]> Date: Tue, 23 Aug 2011 12:06:28 +0300 Subject: [PATCH 1/2] grep: Support -f emptyfile Signed-off-by: Lauri Kasanen <[email protected]> --- findutils/grep.c | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/findutils/grep.c b/findutils/grep.c index 3acfa91..ff470d1 100644 --- a/findutils/grep.c +++ b/findutils/grep.c @@ -564,6 +564,8 @@ static void load_regexes_from_file(llist_t *fopt) { char *line; FILE *f; + long size; + char empty = '\0'; while (fopt) { llist_t *cur = fopt; @@ -572,6 +574,18 @@ static void load_regexes_from_file(llist_t *fopt) fopt = cur->link; free(cur); f = xfopen_stdin(ffile); + + fseek(f, 0, SEEK_END); + size = ftell(f); + rewind(f); + + if (size == 0) { + llist_add_to(&pattern_head, + new_grep_list_data(&empty, 0)); + invert_search ^= 1; + continue; + } + while ((line = xmalloc_fgetline(f)) != NULL) { llist_add_to(&pattern_head, new_grep_list_data(line, ALLOCATED)); -- 1.7.2.1
_______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
