summaryrefslogtreecommitdiff
path: root/usr.bin/grep
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2003-06-24 17:32:11 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2003-06-24 17:32:11 +0000
commitc44e8aaecb152c728539af2a43be1b9132b65ab6 (patch)
tree24017bf4ea12aff3f841f40bac31263eb1d36960 /usr.bin/grep
parent86b2f8b90d30841f0179c45e709d84526e4e5bd2 (diff)
don't print "Binary file matches" with -q flag. from Sean Farley
Diffstat (limited to 'usr.bin/grep')
-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 */
+}