summaryrefslogtreecommitdiffstats
path: root/contrib/file/ascmagic.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/file/ascmagic.c')
-rw-r--r--contrib/file/ascmagic.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/contrib/file/ascmagic.c b/contrib/file/ascmagic.c
index 81525c8..564556d 100644
--- a/contrib/file/ascmagic.c
+++ b/contrib/file/ascmagic.c
@@ -49,7 +49,7 @@
#include "names.h"
#ifndef lint
-FILE_RCSID("@(#)$Id: ascmagic.c,v 1.46 2006/10/20 21:04:15 christos Exp $")
+FILE_RCSID("@(#)$File: ascmagic.c,v 1.50 2007/03/15 14:51:00 christos Exp $")
#endif /* lint */
typedef unsigned long unichar;
@@ -92,7 +92,7 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
int n_cr = 0;
int n_nel = 0;
- int last_line_end = -1;
+ size_t last_line_end = (size_t)-1;
int has_long_lines = 0;
/*
@@ -167,7 +167,7 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
* I believe Plan 9 troff allows non-ASCII characters in the names
* of macros, so this test might possibly fail on such a file.
*/
- if (*ubuf == '.') {
+ if ((ms->flags & MAGIC_NO_CHECK_TROFF) == 0 && *ubuf == '.') {
unichar *tp = ubuf + 1;
while (ISSPC(*tp))
@@ -184,7 +184,8 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
}
}
- if ((*buf == 'c' || *buf == 'C') && ISSPC(buf[1])) {
+ if ((ms->flags & MAGIC_NO_CHECK_FORTRAN) == 0 &&
+ (*buf == 'c' || *buf == 'C') && ISSPC(buf[1])) {
subtype_mime = "text/fortran";
subtype = "fortran program";
goto subtype_identified;
@@ -192,6 +193,9 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
/* look for tokens from names.h - this is expensive! */
+ if ((ms->flags & MAGIC_NO_CHECK_TOKENS) != 0)
+ goto subtype_identified;
+
i = 0;
while (i < ulen) {
size_t end;
@@ -461,7 +465,7 @@ private int
looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf,
size_t *ulen)
{
- int i;
+ size_t i;
*ulen = 0;
@@ -480,7 +484,7 @@ looks_ascii(const unsigned char *buf, size_t nbytes, unichar *ubuf,
private int
looks_latin1(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
{
- int i;
+ size_t i;
*ulen = 0;
@@ -500,7 +504,7 @@ private int
looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf,
size_t *ulen)
{
- int i;
+ size_t i;
*ulen = 0;
@@ -519,7 +523,8 @@ looks_extended(const unsigned char *buf, size_t nbytes, unichar *ubuf,
private int
looks_utf8(const unsigned char *buf, size_t nbytes, unichar *ubuf, size_t *ulen)
{
- int i, n;
+ size_t i;
+ int n;
unichar c;
int gotone = 0;
@@ -583,7 +588,7 @@ looks_unicode(const unsigned char *buf, size_t nbytes, unichar *ubuf,
size_t *ulen)
{
int bigend;
- int i;
+ size_t i;
if (nbytes < 2)
return 0;
@@ -702,7 +707,7 @@ private unsigned char ebcdic_1047_to_8859[] = {
private void
from_ebcdic(const unsigned char *buf, size_t nbytes, unsigned char *out)
{
- int i;
+ size_t i;
for (i = 0; i < nbytes; i++) {
out[i] = ebcdic_to_ascii[buf[i]];
OpenPOWER on IntegriCloud