=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/file/Attic/ascmagic.c,v retrieving revision 1.2 retrieving revision 1.3 diff -c -r1.2 -r1.3 *** src/usr.bin/file/Attic/ascmagic.c 1996/06/26 05:32:54 1.2 --- src/usr.bin/file/Attic/ascmagic.c 1997/02/09 23:58:18 1.3 *************** *** 1,4 **** ! /* $OpenBSD: ascmagic.c,v 1.2 1996/06/26 05:32:54 deraadt Exp $ */ /* * ASCII magic -- file types that we know based on keywords * that can appear anywhere in the file. --- 1,5 ---- ! /* $OpenBSD: ascmagic.c,v 1.3 1997/02/09 23:58:18 millert Exp $ */ ! /* * ASCII magic -- file types that we know based on keywords * that can appear anywhere in the file. *************** *** 36,42 **** #include "names.h" #ifndef lint ! static char *moduleid = "$OpenBSD: ascmagic.c,v 1.2 1996/06/26 05:32:54 deraadt Exp $"; #endif /* lint */ /* an optimisation over plain strcmp() */ --- 37,43 ---- #include "names.h" #ifndef lint ! static char *moduleid = "$OpenBSD: ascmagic.c,v 1.3 1997/02/09 23:58:18 millert Exp $"; #endif /* lint */ /* an optimisation over plain strcmp() */ *************** *** 88,93 **** --- 89,101 ---- return 1; } + + /* Make sure we are dealing with ascii text before looking for tokens */ + 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); *************** *** 104,115 **** return 1; } } - } - - - for (i = 0; i < nbytes; i++) { - if (!isascii(buf[i])) - return 0; /* not all ASCII */ } /* all else fails, but it is ASCII... */ --- 112,117 ----