summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2003-06-24 17:32:10 +0000
committertedu <tedu@openbsd.org>2003-06-24 17:32:10 +0000
commit0c0c855b49ba18df7d804ba9248f774b5a4c330c (patch)
tree9cff7dcb3485489e06dc179170ae15d02c731603
parentPull in change 17805 by hv@hv-crypt.org on 2002/08/29 13:49:04 (diff)
downloadwireguard-openbsd-0c0c855b49ba18df7d804ba9248f774b5a4c330c.tar.xz
wireguard-openbsd-0c0c855b49ba18df7d804ba9248f774b5a4c330c.zip
don't print "Binary file matches" with -q flag. from Sean Farley
-rw-r--r--usr.bin/grep/util.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/usr.bin/grep/util.c b/usr.bin/grep/util.c
index 42959fb4447..59bff4096d4 100644
--- a/usr.bin/grep/util.c
+++ b/usr.bin/grep/util.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: util.c,v 1.6 2003/06/23 22:05:23 tedu Exp $ */
+/* $OpenBSD: util.c,v 1.7 2003/06/24 17:32:10 tedu Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
@@ -152,7 +152,7 @@ procfile(char *fn)
if (Lflag && c == 0)
printf("%s\n", fn);
if (c && !cflag && !lflag && !Lflag &&
- binbehave == BIN_FILE_BIN && nottext)
+ binbehave == BIN_FILE_BIN && nottext && !qflag)
printf("Binary file %s matches\n", fn);
return c;
@@ -512,3 +512,29 @@ printline(str_t *line, int sep)
fwrite(line->dat, line->len, 1, stdout);
putchar('\n');
}
+
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+ register char *d = dst;
+ register const char *s = src;
+ register size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0 && --n != 0) {
+ do {
+ if ((*d++ = *s++) == 0)
+ break;
+ } while (--n != 0);
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}