]> granicus.if.org Git - file/commitdiff
annotations are attached to the first description entry, print them then.
authorChristos Zoulas <christos@zoulas.com>
Wed, 16 Sep 2015 22:17:12 +0000 (22:17 +0000)
committerChristos Zoulas <christos@zoulas.com>
Wed, 16 Sep 2015 22:17:12 +0000 (22:17 +0000)
src/softmagic.c

index 21b578d5a27c45fb5ae6fae3e6f999653b70cb50..83f3d59e0ea782205815745b860bc8f7e7b1d6a7 100644 (file)
@@ -32,7 +32,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.218 2015/09/11 17:24:09 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.219 2015/09/16 18:25:23 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -228,17 +228,17 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
                        continue;
                }
 
-               if ((e = handle_annotation(ms, m)) != 0) {
-                       *need_separator = 1;
-                       *printed_something = 1;
-                       *returnval = 1;
-                       return e;
-               }
                /*
                 * If we are going to print something, we'll need to print
                 * a blank before we print something else.
                 */
                if (*m->desc) {
+                       if ((e = handle_annotation(ms, m)) != 0) {
+                               *need_separator = 1;
+                               *printed_something = 1;
+                               *returnval = 1;
+                               return e;
+                       }
                        *need_separator = 1;
                        *printed_something = 1;
                        if (print_sep(ms, firstline) == -1)
@@ -318,17 +318,17 @@ match(struct magic_set *ms, struct magic *magic, uint32_t nmagic,
                                                break;
                                } else
                                        ms->c.li[cont_level].got_match = 1;
-                               if ((e = handle_annotation(ms, m)) != 0) {
-                                       *need_separator = 1;
-                                       *printed_something = 1;
-                                       *returnval = 1;
-                                       return e;
-                               }
                                /*
                                 * If we are going to print something,
                                 * make sure that we have a separator first.
                                 */
                                if (*m->desc) {
+                                       if ((e = handle_annotation(ms, m)) != 0) {
+                                               *need_separator = 1;
+                                               *printed_something = 1;
+                                               *returnval = 1;
+                                               return e;
+                                       }
                                        if (!*printed_something) {
                                                *printed_something = 1;
                                                if (print_sep(ms, firstline)
@@ -2166,6 +2166,7 @@ magiccheck(struct magic_set *ms, struct magic *m)
 private int
 handle_annotation(struct magic_set *ms, struct magic *m)
 {
+printf("desc = %s, ext = %s mime = %s\n", m->desc, m->ext, m->mimetype);
        if (ms->flags & MAGIC_APPLE) {
                if (file_printf(ms, "%.8s", m->apple) == -1)
                        return -1;