Mirror of git://git.busybox.net/busybox with our patches on top
Source
xxxxxxxxxx
static int file_action_grep(const char *filename, struct stat *statbuf, void* matched, int depth)
/* vi: set sw=4 ts=4: */
/*
* Mini grep implementation for busybox using libc regex.
*
* Copyright (C) 1999,2000,2001 by Lineo, inc. and Mark Whitley
* Copyright (C) 1999,2000,2001 by Mark Whitley <markw@codepoet.org>
*
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
/* BB_AUDIT SUSv3 defects - unsupported option -x. */
/* BB_AUDIT GNU defects - always acts as -a. */
/* http://www.opengroup.org/onlinepubs/007904975/utilities/grep.html */
/*
* 2004,2006 (C) Vladimir Oleynik <dzo@simtreas.ru> -
* correction "-e pattern1 -e pattern2" logic and more optimizations.
* precompiled regex
*/
/*
* (C) 2006 Jac Goudsmit added -o option
*/
/* options */
typedef unsigned char byte_t;
static int reflags;
static byte_t invert_search;
static byte_t print_filename;
static byte_t open_errors;
static int lines_before;
static int lines_after;
static char **before_buf;
static int last_line_printed;
/* ENABLE_FEATURE_GREP_CONTEXT */
/* globals used internally */
static llist_t *pattern_head; /* growable list of patterns to match */
static const char *cur_file; /* the current file we are reading */
typedef struct GREP_LIST_DATA {
char *pattern;
regex_t preg;
int flg_mem_alocated_compiled;