diff options
author | joerg <joerg@FreeBSD.org> | 1996-12-20 22:19:18 +0000 |
---|---|---|
committer | joerg <joerg@FreeBSD.org> | 1996-12-20 22:19:18 +0000 |
commit | 581f3e28c3e1e8a1e0fdd55dfc7931a87ef6a4ef (patch) | |
tree | 30b46c08a9b535272266e7e44c3e03a1295b6291 /usr.bin/file | |
parent | a09e7bdbced1e487012a00982f981ab057b14b92 (diff) | |
download | FreeBSD-src-581f3e28c3e1e8a1e0fdd55dfc7931a87ef6a4ef.zip FreeBSD-src-581f3e28c3e1e8a1e0fdd55dfc7931a87ef6a4ef.tar.gz |
Move the check for ASCIIness earlier. This avoids the following
misdetection:
j@uriah 307% file X.hga
X.hga: 80386 COFF executable not stripped
j@uriah 308% strings X.hga | head -3
~f&`i
.text
.data
j@uriah 309% strings X.hga | file -
standard input: assembler program text
New version:
j@uriah 310% strings X.hga | ./file -
standard input: International language text
Reviewed by: christos@deshaw.com (Christos Zoulas)
Diffstat (limited to 'usr.bin/file')
-rw-r--r-- | usr.bin/file/ascmagic.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/file/ascmagic.c b/usr.bin/file/ascmagic.c index 4280b51..2250bba 100644 --- a/usr.bin/file/ascmagic.c +++ b/usr.bin/file/ascmagic.c @@ -36,7 +36,7 @@ #ifndef lint static char *moduleid = - "@(#)$Id: ascmagic.c,v 1.2 1995/05/30 06:29:59 rgrimes Exp $"; + "@(#)$Id: ascmagic.c,v 1.3 1996/01/23 12:40:06 mpp Exp $"; #endif /* lint */ /* an optimisation over plain strcmp() */ @@ -88,6 +88,12 @@ int nbytes; /* size actually read */ return 1; } + + for (i = 0; i < nbytes; i++) { + if (!isascii(buf[i])) + return 0; /* not all ASCII */ + } + /* look for tokens from names.h - this is expensive! */ /* make a copy of the buffer here because strtok() will destroy it */ s = (unsigned char*) memcpy(nbuf, buf, nbytes); @@ -106,12 +112,6 @@ int nbytes; /* size actually read */ } } - - for (i = 0; i < nbytes; i++) { - if (!isascii(buf[i])) - return 0; /* not all ASCII */ - } - /* all else fails, but it is ASCII... */ ckfputs("ASCII text", stdout); if (has_escapes) { |