Deleted Added
full compact
grep.c (211496) grep.c (211519)
1/* $OpenBSD: grep.c,v 1.42 2010/07/02 22:18:03 tedu Exp $ */
2
3/*-
4 * Copyright (c) 1999 James Howard and Dag-Erling Co��dan Sm��rgrav
5 * Copyright (C) 2008-2009 Gabor Kovesdan <gabor@FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
1/* $OpenBSD: grep.c,v 1.42 2010/07/02 22:18:03 tedu Exp $ */
2
3/*-
4 * Copyright (c) 1999 James Howard and Dag-Erling Co��dan Sm��rgrav
5 * Copyright (C) 2008-2009 Gabor Kovesdan <gabor@FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 14 unchanged lines hidden (view full) ---

23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30#include <sys/cdefs.h>
31__FBSDID("$FreeBSD: head/usr.bin/grep/grep.c 211496 2010-08-19 09:28:59Z des $");
31__FBSDID("$FreeBSD: head/usr.bin/grep/grep.c 211519 2010-08-19 22:55:17Z delphij $");
32
33#include <sys/stat.h>
34#include <sys/types.h>
35
36#include <ctype.h>
37#include <err.h>
38#include <errno.h>
39#include <getopt.h>

--- 636 unchanged lines hidden (view full) ---

676 if ((aargc == 0 || aargc == 1) && !Hflag)
677 hflag = true;
678
679 if (aargc == 0)
680 exit(!procfile("-"));
681
682 if (dirbehave == DIR_RECURSE)
683 c = grep_tree(aargv);
32
33#include <sys/stat.h>
34#include <sys/types.h>
35
36#include <ctype.h>
37#include <err.h>
38#include <errno.h>
39#include <getopt.h>

--- 636 unchanged lines hidden (view full) ---

676 if ((aargc == 0 || aargc == 1) && !Hflag)
677 hflag = true;
678
679 if (aargc == 0)
680 exit(!procfile("-"));
681
682 if (dirbehave == DIR_RECURSE)
683 c = grep_tree(aargv);
684 else {
685 if (aargc == 1)
686 hflag = true;
684 else
687 for (c = 0; aargc--; ++aargv) {
688 if ((finclude || fexclude) && !file_matching(*aargv))
689 continue;
690 c+= procfile(*aargv);
691 }
685 for (c = 0; aargc--; ++aargv) {
686 if ((finclude || fexclude) && !file_matching(*aargv))
687 continue;
688 c+= procfile(*aargv);
689 }
692 }
693
694#ifndef WITHOUT_NLS
695 catclose(catalog);
696#endif
697
698 /* Find out the correct return value according to the
699 results and the command line option. */
700 exit(c ? (notfound ? (qflag ? 0 : 2) : 0) : (notfound ? 2 : 1));
701}
690
691#ifndef WITHOUT_NLS
692 catclose(catalog);
693#endif
694
695 /* Find out the correct return value according to the
696 results and the command line option. */
697 exit(c ? (notfound ? (qflag ? 0 : 2) : 0) : (notfound ? 2 : 1));
698}