1/* $NetBSD: util.c,v 1.9 2011/02/27 17:33:37 joerg Exp $ */
2/* $FreeBSD: head/usr.bin/grep/util.c 228097 2011-11-28 20:04:26Z gabor $ */
3/* $OpenBSD: util.c,v 1.39 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-2010 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/util.c 228097 2011-11-28 20:04:26Z 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 <fnmatch.h>
--- 83 unchanged lines hidden (view full) ---
125
126 if (!(fts = fts_open(argv, fts_flags, NULL)))
127 err(2, "fts_open");
128 while ((p = fts_read(fts)) != NULL) {
129 switch (p->fts_info) {
130 case FTS_DNR:
131 /* FALLTHROUGH */
132 case FTS_ERR:
133 notfound = true;
134 if(!sflag)
135 warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
136 break;
137 case FTS_D:
138 /* FALLTHROUGH */
139 case FTS_DP:
140 if (dexclude || dinclude)
141 if (!dir_matching(p->fts_name) ||
142 !dir_matching(p->fts_path))
143 fts_set(fts, p, FTS_SKIP);
--- 351 unchanged lines hidden ---
2/* $FreeBSD: head/usr.bin/grep/util.c 228097 2011-11-28 20:04:26Z gabor $ */
3/* $OpenBSD: util.c,v 1.39 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-2010 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/util.c 228097 2011-11-28 20:04:26Z 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 <fnmatch.h>
--- 83 unchanged lines hidden (view full) ---
125
126 if (!(fts = fts_open(argv, fts_flags, NULL)))
127 err(2, "fts_open");
128 while ((p = fts_read(fts)) != NULL) {
129 switch (p->fts_info) {
130 case FTS_DNR:
131 /* FALLTHROUGH */
132 case FTS_ERR:
133 notfound = true;
134 if(!sflag)
135 warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
136 break;
137 case FTS_D:
138 /* FALLTHROUGH */
139 case FTS_DP:
140 if (dexclude || dinclude)
141 if (!dir_matching(p->fts_name) ||
142 !dir_matching(p->fts_path))
143 fts_set(fts, p, FTS_SKIP);
--- 351 unchanged lines hidden ---