From: Christos Zoulas Date: Mon, 6 May 2019 21:22:13 +0000 (+0000) Subject: - Add a file_separator function that prints the separator. X-Git-Tag: FILE5_37~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d232c0289d91d29d77f9338496172558f9453980;p=file - Add a file_separator function that prints the separator. - Don't append a separator after ascmagic since this is the last test. --- diff --git a/src/file.h b/src/file.h index 2b372714..d96be4f9 100644 --- a/src/file.h +++ b/src/file.h @@ -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 *, ...) diff --git a/src/funcs.c b/src/funcs.c index eca99ad7..0fc53ad7 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.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; } }