diff options
author | obrien <obrien@FreeBSD.org> | 2008-01-13 20:35:16 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2008-01-13 20:35:16 +0000 |
commit | 6678cf7c2ac8c768ea5efe9fe0392f07e522c963 (patch) | |
tree | 5ce2a6ee53483b8b3a7ac87258304920c043207f /contrib/file/ascmagic.c | |
parent | 240c77918bbcf0d5f67799916b808b8a65d434c5 (diff) | |
download | FreeBSD-src-6678cf7c2ac8c768ea5efe9fe0392f07e522c963.zip FreeBSD-src-6678cf7c2ac8c768ea5efe9fe0392f07e522c963.tar.gz |
Import file version 4.23 onto the vendor branch
Diffstat (limited to 'contrib/file/ascmagic.c')
-rw-r--r-- | contrib/file/ascmagic.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/contrib/file/ascmagic.c b/contrib/file/ascmagic.c index 564556d..8d2d9a7 100644 --- a/contrib/file/ascmagic.c +++ b/contrib/file/ascmagic.c @@ -49,7 +49,7 @@ #include "names.h" #ifndef lint -FILE_RCSID("@(#)$File: ascmagic.c,v 1.50 2007/03/15 14:51:00 christos Exp $") +FILE_RCSID("@(#)$File: ascmagic.c,v 1.53 2007/10/29 00:54:08 christos Exp $") #endif /* lint */ typedef unsigned long unichar; @@ -76,6 +76,7 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes) size_t ulen; struct names *p; int rv = -1; + int mime = ms->flags & MAGIC_MIME; const char *code = NULL; const char *code_mime = NULL; @@ -184,13 +185,6 @@ file_ascmagic(struct magic_set *ms, const unsigned char *buf, size_t nbytes) } } - 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; - } - /* look for tokens from names.h - this is expensive! */ if ((ms->flags & MAGIC_NO_CHECK_TOKENS) != 0) @@ -271,21 +265,27 @@ subtype_identified: if (seen_cr && nbytes < HOWMANY) n_cr++; - if ((ms->flags & MAGIC_MIME)) { - if (subtype_mime) { - if (file_printf(ms, subtype_mime) == -1) - goto done; - } else { - if (file_printf(ms, "text/plain") == -1) - goto done; + if (mime) { + if (mime & MAGIC_MIME_TYPE) { + if (subtype_mime) { + if (file_printf(ms, subtype_mime) == -1) + goto done; + } else { + if (file_printf(ms, "text/plain") == -1) + goto done; + } } - if (code_mime) { - if (file_printf(ms, "; charset=") == -1) + if ((mime == 0 || mime == MAGIC_MIME) && code_mime) { + if ((mime & MAGIC_MIME_TYPE) && + file_printf(ms, " charset=") == -1) goto done; if (file_printf(ms, code_mime) == -1) goto done; } + + if (mime == MAGIC_MIME_ENCODING) + file_printf(ms, "binary"); } else { if (file_printf(ms, code) == -1) goto done; |