am 8098114c: Merge "Sync with upstream grep."

* commit '8098114c904923d187368a331ed34a9f2d98cac5':
  Sync with upstream grep.
This commit is contained in:
Elliott Hughes 2014-07-11 03:08:36 +00:00 committed by Android Git Automerger
commit 802943ab51
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. */ /* We want chown to support user.group as well as user:group. */
#define SUPPORT_DOT #define SUPPORT_DOT
/* We don't localize /system/bin! */
#define WITHOUT_NLS
__BEGIN_DECLS __BEGIN_DECLS
extern int uid_from_user(const char* name, uid_t* uid); 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; Aflag = 0;
else if (Aflag > LLONG_MAX / 10) { else if (Aflag > LLONG_MAX / 10) {
errno = ERANGE; errno = ERANGE;
err(2, "%llu", Aflag); err(2, NULL);
} }
Aflag = Bflag = (Aflag * 10) + (c - '0'); Aflag = Bflag = (Aflag * 10) + (c - '0');
break; break;
@ -419,10 +419,10 @@ grep_main(int argc, char *argv[])
l = strtoull(optarg, &ep, 10); l = strtoull(optarg, &ep, 10);
if (((errno == ERANGE) && (l == ULLONG_MAX)) || if (((errno == ERANGE) && (l == ULLONG_MAX)) ||
((errno == EINVAL) && (l == 0))) ((errno == EINVAL) && (l == 0)))
err(2, "strtoull"); err(2, NULL);
else if (ep[0] != '\0') { else if (ep[0] != '\0') {
errno = EINVAL; errno = EINVAL;
err(2, "empty"); err(2, NULL);
} }
if (c == 'A') if (c == 'A')
Aflag = l; Aflag = l;
@ -508,10 +508,10 @@ grep_main(int argc, char *argv[])
mcount = strtoull(optarg, &ep, 10); mcount = strtoull(optarg, &ep, 10);
if (((errno == ERANGE) && (mcount == ULLONG_MAX)) || if (((errno == ERANGE) && (mcount == ULLONG_MAX)) ||
((errno == EINVAL) && (mcount == 0))) ((errno == EINVAL) && (mcount == 0)))
err(2, "strtoull"); err(2, NULL);
else if (ep[0] != '\0') { else if (ep[0] != '\0') {
errno = EINVAL; errno = EINVAL;
err(2, "empty"); err(2, NULL);
} }
break; break;
case 'n': case 'n':

View file

@ -29,10 +29,6 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#ifdef ANDROID
#define WITHOUT_NLS
#endif
#ifndef ANDROID #ifndef ANDROID
#include <bzlib.h> #include <bzlib.h>
#endif #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 $ */ /* $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 $ */ /* $OpenBSD: util.c,v 1.39 2010/07/02 22:18:03 tedu Exp $ */
@ -34,7 +34,7 @@
#endif #endif
#include <sys/cdefs.h> #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/stat.h>
#include <sys/types.h> #include <sys/types.h>
@ -74,9 +74,10 @@ file_matching(const char *fname)
for (i = 0; i < fpatterns; ++i) { for (i = 0; i < fpatterns; ++i) {
if (fnmatch(fpattern[i].pat, fname, 0) == 0 || if (fnmatch(fpattern[i].pat, fname, 0) == 0 ||
fnmatch(fpattern[i].pat, fname_base, 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); return (false);
else } else
ret = true; ret = true;
} }
} }
@ -273,7 +274,7 @@ procfile(const char *fn)
return (c); 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 * Processes a line comparing it with the specified patterns. Each pattern
@ -323,7 +324,7 @@ procline(struct str *l, int nottext)
continue; continue;
/* Check for whole word match */ /* Check for whole word match */
if (fg_pattern[i].word && pmatch.rm_so != 0) { if (fg_pattern[i].word && pmatch.rm_so != 0) {
wchar_t wbegin, wend; wint_t wbegin, wend;
wbegin = wend = L' '; wbegin = wend = L' ';
if (pmatch.rm_so != 0 && if (pmatch.rm_so != 0 &&