]> granicus.if.org Git - file/commitdiff
Make the default case print something sane for each of the different styles:
authorChristos Zoulas <christos@zoulas.com>
Thu, 17 Sep 2015 01:10:51 +0000 (01:10 +0000)
committerChristos Zoulas <christos@zoulas.com>
Thu, 17 Sep 2015 01:10:51 +0000 (01:10 +0000)
apple, mime, encoding, default. Before it just printed data which is confusing.

src/funcs.c

index 97d4a0afaacf5118793e5affe689bf2c414962a2..3cd9a54f4b25a34e563fb015f3e173bf6050978f 100644 (file)
@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.84 2015/09/10 13:32:19 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.85 2015/09/17 01:10:51 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) {