svn commit: r228806 - user/gabor/grep/trunk
Gabor Kovesdan
gabor at FreeBSD.org
Thu Dec 22 16:19:51 UTC 2011
Author: gabor
Date: Thu Dec 22 16:19:51 2011
New Revision: 228806
URL: http://svn.freebsd.org/changeset/base/228806
Log:
- Merge some recent changes from HEAD
Modified:
user/gabor/grep/trunk/Makefile
user/gabor/grep/trunk/grep.c
user/gabor/grep/trunk/grep.h
user/gabor/grep/trunk/util.c
Modified: user/gabor/grep/trunk/Makefile
==============================================================================
--- user/gabor/grep/trunk/Makefile Thu Dec 22 16:16:12 2011 (r228805)
+++ user/gabor/grep/trunk/Makefile Thu Dec 22 16:19:51 2011 (r228806)
@@ -25,13 +25,7 @@ LINKS= ${BINDIR}/grep ${BINDIR}/egrep \
${BINDIR}/grep ${BINDIR}/fgrep \
${BINDIR}/grep ${BINDIR}/zgrep \
${BINDIR}/grep ${BINDIR}/zegrep \
- ${BINDIR}/grep ${BINDIR}/zfgrep \
- ${BINDIR}/grep ${BINDIR}/xzgrep \
- ${BINDIR}/grep ${BINDIR}/xzegrep \
- ${BINDIR}/grep ${BINDIR}/xzfgrep \
- ${BINDIR}/grep ${BINDIR}/lzgrep \
- ${BINDIR}/grep ${BINDIR}/lzegrep \
- ${BINDIR}/grep ${BINDIR}/lzfgrep
+ ${BINDIR}/grep ${BINDIR}/zfgrep
MLINKS= grep.1 egrep.1 \
grep.1 fgrep.1 \
@@ -46,6 +40,13 @@ MLINKS= grep.1 egrep.1 \
grep.1 lzfgrep.1
.endif
+LINKS+= ${BINDIR}/${PROG} ${BINDIR}/xzgrep \
+ ${BINDIR}/${PROG} ${BINDIR}/xzegrep \
+ ${BINDIR}/${PROG} ${BINDIR}/xzfgrep \
+ ${BINDIR}/${PROG} ${BINDIR}/lzgrep \
+ ${BINDIR}/${PROG} ${BINDIR}/lzegrep \
+ ${BINDIR}/${PROG} ${BINDIR}/lzfgrep
+
LDADD= -lz -llzma
DPADD= ${LIBZ} ${LIBLZMA}
@@ -53,12 +54,14 @@ DPADD= ${LIBZ} ${LIBLZMA}
LDADD+= -lbz2
DPADD+= ${LIBBZ2}
+.if ${MK_BSD_GREP} == "yes"
LINKS+= ${BINDIR}/grep ${BINDIR}/bzgrep \
${BINDIR}/grep ${BINDIR}/bzegrep \
${BINDIR}/grep ${BINDIR}/bzfgrep
MLINKS+= grep.1 bzgrep.1 \
grep.1 bzegrep.1 \
grep.1 bzfgrep.1
+.endif
.else
CFLAGS+= -DWITHOUT_BZIP2
.endif
Modified: user/gabor/grep/trunk/grep.c
==============================================================================
--- user/gabor/grep/trunk/grep.c Thu Dec 22 16:16:12 2011 (r228805)
+++ user/gabor/grep/trunk/grep.c Thu Dec 22 16:19:51 2011 (r228806)
@@ -148,7 +148,7 @@ static inline const char *init_color(con
bool first = true; /* flag whether we are processing the first match */
bool prev; /* flag whether or not the previous line matched */
int tail; /* lines left to print */
-bool notfound; /* file not found */
+bool file_err; /* file reading error */
/*
* Prints usage information and returns 2.
@@ -728,5 +728,5 @@ main(int argc, char *argv[])
/* Find out the correct return value according to the
results and the command line option. */
- exit(c ? (notfound ? (qflag ? 0 : 2) : 0) : (notfound ? 2 : 1));
+ exit(c ? (file_err ? (qflag ? 0 : 2) : 0) : (file_err ? 2 : 1));
}
Modified: user/gabor/grep/trunk/grep.h
==============================================================================
--- user/gabor/grep/trunk/grep.h Thu Dec 22 16:16:12 2011 (r228805)
+++ user/gabor/grep/trunk/grep.h Thu Dec 22 16:19:51 2011 (r228806)
@@ -119,7 +119,7 @@ extern char *label;
extern const char *color;
extern int binbehave, devbehave, dirbehave, filebehave, grepbehave, linkbehave;
-extern bool first, matchall, notfound, prev;
+extern bool file_err, first, matchall, prev;
extern int tail;
extern unsigned int dpatterns, fpatterns, patterns;
extern struct pat *pattern;
Modified: user/gabor/grep/trunk/util.c
==============================================================================
--- user/gabor/grep/trunk/util.c Thu Dec 22 16:16:12 2011 (r228805)
+++ user/gabor/grep/trunk/util.c Thu Dec 22 16:19:51 2011 (r228806)
@@ -130,7 +130,9 @@ grep_tree(char **argv)
case FTS_DNR:
/* FALLTHROUGH */
case FTS_ERR:
- errx(2, "%s: %s", p->fts_path, strerror(p->fts_errno));
+ file_err = true;
+ if(!sflag)
+ warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
break;
case FTS_D:
/* FALLTHROUGH */
@@ -193,10 +195,9 @@ procfile(const char *fn)
f = grep_open(fn);
}
if (f == NULL) {
+ file_err = true;
if (!sflag)
warn("%s", fn);
- if (errno == ENOENT)
- notfound = true;
return (0);
}
@@ -246,9 +247,9 @@ procfile(const char *fn)
printf("%u\n", c);
}
if (lflag && !qflag && c != 0)
- printf("%s\n", fn);
+ printf("%s%c", fn, nullflag ? 0 : '\n');
if (Lflag && !qflag && c == 0)
- printf("%s\n", fn);
+ printf("%s%c", fn, nullflag ? 0 : '\n');
if (c && !cflag && !lflag && !Lflag &&
binbehave == BINFILE_BIN && f->binary && !qflag)
printf(getstr(8), fn);
@@ -440,13 +441,13 @@ printline(struct str *line, int sep, reg
int i, n = 0;
if (!hflag) {
- if (nullflag == 0)
+ if (!nullflag) {
fputs(line->file, stdout);
- else {
+ ++n;
+ } else {
printf("%s", line->file);
putchar(0);
}
- ++n;
}
if (nflag) {
if (n > 0)
More information about the svn-src-user
mailing list