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)
This commit is contained in:
Joerg Wunsch 1996-12-20 22:19:18 +00:00
parent edb2a14fa4
commit 4205b53dc0

View File

@ -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) {