#ifndef lint
-FILE_RCSID("@(#)$Id: softmagic.c,v 1.78 2006/03/12 22:09:33 christos Exp $")
+FILE_RCSID("@(#)$Id: softmagic.c,v 1.79 2006/05/03 15:18:30 christos Exp $")
#endif /* lint */
private int match(struct magic_set *, struct magic *, uint32_t,
const unsigned char *, size_t, size_t);
private int mconvert(struct magic_set *, union VALUETYPE *, struct magic *);
private int check_mem(struct magic_set *, unsigned int);
+private int print_sep(struct magic_set *, int);
/*
* softmagic - lookup one file in database
continue;
}
- if (!firstline) { /* we found another match */
- /* put a newline and '-' to do some simple formatting*/
- if (file_printf(ms, "\n- ") == -1)
+ /*
+ * If we are going to print something, we'll need to print
+ * a blank before we print something else.
+ */
+ if (magic[magindex].desc[0]) {
+ need_separator = 1;
+ if (print_sep(ms, firstline) == -1)
return -1;
}
if ((ms->c.off[cont_level] = mprint(ms, &p, &magic[magindex]))
== -1)
return -1;
- /*
- * If we printed something, we'll need to print
- * a blank before we print something else.
- */
- if (magic[magindex].desc[0])
- need_separator = 1;
+
/* and any continuations that match */
if (check_mem(ms, ++cont_level) == -1)
return -1;
case 0:
break;
default:
+ /*
+ * If we are going to print something,
+ * make sure that we have a separator first.
+ */
+ if (magic[magindex].desc[0]) {
+ if (print_sep(ms, firstline) == -1)
+ return -1;
+ }
/*
* This continuation matched.
* Print its message, with
mprint(struct magic_set *ms, union VALUETYPE *p, struct magic *m)
{
uint32_t v;
- int32_t t=0 ;
+ int32_t t = 0;
switch (m->type) {
return matched;
}
+
+private int
+print_sep(struct magic_set *ms, int firstline)
+{
+ if (firstline)
+ return 0;
+ /*
+ * we found another match
+ * put a newline and '-' to do some simple formatting
+ */
+ return file_printf(ms, "\n- ");
+}