From 9039ec538b4e00df8b8a2c7cd998de745403ef3a Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Thu, 17 Sep 2015 01:10:51 +0000 Subject: [PATCH] Make the default case print something sane for each of the different styles: apple, mime, encoding, default. Before it just printed data which is confusing. --- src/funcs.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/funcs.c b/src/funcs.c index c9bc6715..192eb87e 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -27,7 +27,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: funcs.c,v 1.83 2015/06/16 14:17:37 christos Exp $") +FILE_RCSID("@(#)$File: funcs.c,v 1.84 2015/09/10 13:32:19 christos Exp $") #endif /* lint */ #include "magic.h" @@ -293,9 +293,18 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((__u simple: /* give up */ m = 1; - if ((!mime || (mime & MAGIC_MIME_TYPE)) && - file_printf(ms, "%s", mime ? type : def) == -1) { - rv = -1; + if (ms->flags & MAGIC_MIME) { + if (file_printf(ms, "%s", type) == -1) + rv = -1; + } else if (ms->flags & MAGIC_APPLE) { + if (file_printf(ms, "UNKNUNKN") == -1) + rv = -1; + } else if (ms->flags & MAGIC_EXTENSION) { + if (file_printf(ms, "???") == -1) + rv = -1; + } else { + if (file_printf(ms, "%s", def) == -1) + rv = -1; } done: if ((ms->flags & MAGIC_MIME_ENCODING) != 0) { -- 2.40.0