]> granicus.if.org Git - file/commitdiff
- Add a file_separator function that prints the separator.
authorChristos Zoulas <christos@zoulas.com>
Mon, 6 May 2019 21:22:13 +0000 (21:22 +0000)
committerChristos Zoulas <christos@zoulas.com>
Mon, 6 May 2019 21:22:13 +0000 (21:22 +0000)
- Don't append a separator after ascmagic since this is the last test.

src/file.h
src/funcs.c

index 2b372714c8a373e503e5a5e65915004b718e8004..d96be4f99d1663ae37f643b453e430dce9def859 100644 (file)
@@ -27,7 +27,7 @@
  */
 /*
  * file.h - definitions for file(1) program
- * @(#)$File: file.h,v 1.204 2019/03/28 20:54:57 christos Exp $
+ * @(#)$File: file.h,v 1.205 2019/05/06 21:22:13 christos Exp $
  */
 
 #ifndef __file_h__
@@ -460,6 +460,7 @@ protected int file_fsmagic(struct magic_set *, const char *, struct stat *);
 protected int file_pipe2file(struct magic_set *, int, const void *, size_t);
 protected int file_vprintf(struct magic_set *, const char *, va_list)
     __attribute__((__format__(__printf__, 2, 0)));
+protected int file_separator(struct magic_set *);
 protected size_t file_printedlen(const struct magic_set *);
 protected int file_replace(struct magic_set *, const char *, const char *);
 protected int file_printf(struct magic_set *, const char *, ...)
index eca99ad77fa2bfa5c7f3af67444371457c78275c..0fc53ad75a362e411536c30aa9b022eb0bf9f4b9 100644 (file)
@@ -27,7 +27,7 @@
 #include "file.h"
 
 #ifndef        lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.102 2019/02/20 02:35:27 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.103 2019/05/06 21:22:13 christos Exp $")
 #endif /* lint */
 
 #include "magic.h"
@@ -160,12 +160,18 @@ file_badread(struct magic_set *ms)
 
 #ifndef COMPILE_ONLY
 
+protected int
+file_separator(struct magic_set *ms)
+{
+       return file_printf(ms, "\n- ");
+}
+
 static int
 checkdone(struct magic_set *ms, int *rv)
 {
        if ((ms->flags & MAGIC_CONTINUE) == 0)
                return 1;
-       if (file_printf(ms, "\n- ") == -1)
+       if (file_separator(ms) == -1)
                *rv = -1;
        return 0;
 }
@@ -335,8 +341,7 @@ file_buffer(struct magic_set *ms, int fd, const char *inname __attribute__ ((__u
                if ((ms->flags & MAGIC_DEBUG) != 0)
                        (void)fprintf(stderr, "[try ascmagic %d]\n", m);
                if (m) {
-                       if (checkdone(ms, &rv))
-                               goto done;
+                       goto done;
                }
        }