Merge "Sync with upstream grep."

This commit is contained in:
Elliott Hughes 2014-07-11 02:54:28 +00:00 committed by Gerrit Code Review
commit 8098114c90
4 changed files with 19 additions and 19 deletions

View file

@ -31,6 +31,9 @@
/* We want chown to support user.group as well as user:group. */
#define SUPPORT_DOT
/* We don't localize /system/bin! */
#define WITHOUT_NLS
__BEGIN_DECLS
extern int uid_from_user(const char* name, uid_t* uid);

View file

@ -402,7 +402,7 @@ grep_main(int argc, char *argv[])
Aflag = 0;
else if (Aflag > LLONG_MAX / 10) {
errno = ERANGE;
err(2, "%llu", Aflag);
err(2, NULL);
}
Aflag = Bflag = (Aflag * 10) + (c - '0');
break;
@ -419,10 +419,10 @@ grep_main(int argc, char *argv[])
l = strtoull(optarg, &ep, 10);
if (((errno == ERANGE) && (l == ULLONG_MAX)) ||
((errno == EINVAL) && (l == 0)))
err(2, "strtoull");
err(2, NULL);
else if (ep[0] != '\0') {
errno = EINVAL;
err(2, "empty");
err(2, NULL);
}
if (c == 'A')
Aflag = l;
@ -508,10 +508,10 @@ grep_main(int argc, char *argv[])
mcount = strtoull(optarg, &ep, 10);
if (((errno == ERANGE) && (mcount == ULLONG_MAX)) ||
((errno == EINVAL) && (mcount == 0)))
err(2, "strtoull");
err(2, NULL);
else if (ep[0] != '\0') {
errno = EINVAL;
err(2, "empty");
err(2, NULL);
}
break;
case 'n':

View file

@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
#ifdef ANDROID
#define WITHOUT_NLS
#endif
#ifndef ANDROID
#include <bzlib.h>
#endif

View file

@ -1,4 +1,4 @@
/* $NetBSD: util.c,v 1.16 2012/05/06 22:32:05 joerg Exp $ */
/* $NetBSD: util.c,v 1.17 2013/01/21 03:24:43 msaitoh Exp $ */
/* $FreeBSD: head/usr.bin/grep/util.c 211496 2010-08-19 09:28:59Z des $ */
/* $OpenBSD: util.c,v 1.39 2010/07/02 22:18:03 tedu Exp $ */
@ -34,7 +34,7 @@
#endif
#include <sys/cdefs.h>
__RCSID("$NetBSD: util.c,v 1.16 2012/05/06 22:32:05 joerg Exp $");
__RCSID("$NetBSD: util.c,v 1.17 2013/01/21 03:24:43 msaitoh Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@ -74,9 +74,10 @@ file_matching(const char *fname)
for (i = 0; i < fpatterns; ++i) {
if (fnmatch(fpattern[i].pat, fname, 0) == 0 ||
fnmatch(fpattern[i].pat, fname_base, 0) == 0) {
if (fpattern[i].mode == EXCL_PAT)
if (fpattern[i].mode == EXCL_PAT) {
free(fname_copy);
return (false);
else
} else
ret = true;
}
}
@ -128,7 +129,7 @@ grep_tree(char **argv)
break;
default:
fts_flags = FTS_LOGICAL;
}
fts_flags |= FTS_NOSTAT | FTS_NOCHDIR;
@ -273,7 +274,7 @@ procfile(const char *fn)
return (c);
}
#define iswword(x) (iswalnum((wint_t)(x)) || (x) == L'_')
#define iswword(x) (iswalnum((x)) || (x) == L'_')
/*
* Processes a line comparing it with the specified patterns. Each pattern
@ -323,7 +324,7 @@ procline(struct str *l, int nottext)
continue;
/* Check for whole word match */
if (fg_pattern[i].word && pmatch.rm_so != 0) {
wchar_t wbegin, wend;
wint_t wbegin, wend;
wbegin = wend = L' ';
if (pmatch.rm_so != 0 &&
@ -474,13 +475,13 @@ printline(struct str *line, int sep, regmatch_t *matches, int m)
if (!oflag)
fwrite(line->dat + a, matches[i].rm_so - a, 1,
stdout);
if (color)
if (color)
fprintf(stdout, "\33[%sm\33[K", color);
fwrite(line->dat + matches[i].rm_so,
fwrite(line->dat + matches[i].rm_so,
matches[i].rm_eo - matches[i].rm_so, 1,
stdout);
if (color)
if (color)
fprintf(stdout, "\33[m\33[K");
a = matches[i].rm_eo;
if (oflag)