Skip to content

Commit

Permalink
Treat ^H as non-binary. OK hshoexer@, brad@ and deraadt@
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd Miller authored and howardjp committed Nov 28, 2009
1 parent 87b669f commit 9c0da7e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions binary.c
@@ -1,4 +1,4 @@
/* $OpenBSD: binary.c,v 1.9 2003/09/18 22:29:30 beck Exp $ */
/* $OpenBSD: binary.c,v 1.10 2003/12/29 21:20:55 canacar Exp $ */

/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
Expand Down Expand Up @@ -32,6 +32,8 @@

#include "grep.h"

#define isbinary(ch) (!isprint((ch)) && !isspace((ch)) && (ch) != '\b')

int
bin_file(FILE *f)
{
Expand All @@ -46,7 +48,7 @@ bin_file(FILE *f)
return 0;

for (i = 0; i < m; i++)
if (!isprint(buf[i]) && !isspace(buf[i])) {
if (isbinary(buf[i])) {
ret = 1;
break;
}
Expand All @@ -70,7 +72,7 @@ gzbin_file(gzFile *f)
return 0;

for (i = 0; i < m; i++)
if (!isprint(buf[i]) && !isspace(buf[i])) {
if (isbinary(buf[i])) {
ret = 1;
break;
}
Expand All @@ -87,7 +89,7 @@ mmbin_file(mmf_t *f)

/* XXX knows too much about mmf internals */
for (i = 0; i < BUFSIZ && i < f->len; i++)
if (!isprint(f->base[i]) && !isspace(f->base[i]))
if (isbinary(f->base[i]))
return 1;
return 0;
}

0 comments on commit 9c0da7e

Please sign in to comment.