1/* $NetBSD: grep.c,v 1.4 2011/02/16 01:31:33 joerg Exp $ */ |
2/* $FreeBSD: head/usr.bin/grep/grep.c 228319 2011-12-07 12:25:28Z gabor $ */ |
3/* $OpenBSD: grep.c,v 1.42 2010/07/02 22:18:03 tedu Exp $ */ 4 5/*- 6 * Copyright (c) 1999 James Howard and Dag-Erling Co��dan Sm��rgrav 7 * Copyright (C) 2008-2009 Gabor Kovesdan <gabor@FreeBSD.org> 8 * All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/usr.bin/grep/grep.c 228319 2011-12-07 12:25:28Z gabor $"); |
34 35#include <sys/stat.h> 36#include <sys/types.h> 37 38#include <ctype.h> 39#include <err.h> 40#include <errno.h> 41#include <fcntl.h> --- 101 unchanged lines hidden (view full) --- 143}; 144 145static inline const char *init_color(const char *); 146 147/* Housekeeping */ 148bool first = true; /* flag whether we are processing the first match */ 149bool prev; /* flag whether or not the previous line matched */ 150int tail; /* lines left to print */ |
151bool file_err; /* file reading error */ |
152 153/* 154 * Prints usage information and returns 2. 155 */ 156static void 157usage(void) 158{ 159 fprintf(stderr, getstr(4), getprogname()); --- 563 unchanged lines hidden (view full) --- 723 } 724 725#ifndef WITHOUT_NLS 726 catclose(catalog); 727#endif 728 729 /* Find out the correct return value according to the 730 results and the command line option. */ |
731 exit(c ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1)); |
732} |