diff options
author | obrien <obrien@FreeBSD.org> | 2012-04-19 03:20:13 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2012-04-19 03:20:13 +0000 |
commit | 248502d7f08de3125e3e3cc808446294565ba5df (patch) | |
tree | c7640efe490a887a5460d7a88d62aca990489d21 /contrib/file/print.c | |
parent | 86e3fa59a2a400ec95b0c84576fb00815631d92f (diff) | |
parent | 15f98df7891f1853090ecb6c4a9cc734e671ef6b (diff) | |
download | FreeBSD-src-248502d7f08de3125e3e3cc808446294565ba5df.zip FreeBSD-src-248502d7f08de3125e3e3cc808446294565ba5df.tar.gz |
Update file(1) to version 5.11.
Diffstat (limited to 'contrib/file/print.c')
-rw-r--r-- | contrib/file/print.c | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/contrib/file/print.c b/contrib/file/print.c index d44a5b3..4187a2e 100644 --- a/contrib/file/print.c +++ b/contrib/file/print.c @@ -32,7 +32,7 @@ #include "file.h" #ifndef lint -FILE_RCSID("@(#)$File: print.c,v 1.66 2009/02/03 20:27:51 christos Exp $") +FILE_RCSID("@(#)$File: print.c,v 1.71 2011/09/20 15:28:09 christos Exp $") #endif /* lint */ #include <string.h> @@ -51,9 +51,8 @@ file_mdump(struct magic *m) { private const char optyp[] = { FILE_OPS }; - (void) fprintf(stderr, "[%u", m->lineno); - (void) fprintf(stderr, ">>>>>>>> %u" + 8 - (m->cont_level & 7), - m->offset); + (void) fprintf(stderr, "%u: %.*s %u", m->lineno, + (m->cont_level & 7) + 1, ">>>>>>>>", m->offset); if (m->flag & INDIR) { (void) fprintf(stderr, "(%s,", @@ -77,10 +76,10 @@ file_mdump(struct magic *m) if (IS_STRING(m->type)) { if (m->str_flags) { (void) fputc('/', stderr); - if (m->str_flags & STRING_COMPACT_BLANK) - (void) fputc(CHAR_COMPACT_BLANK, stderr); - if (m->str_flags & STRING_COMPACT_OPTIONAL_BLANK) - (void) fputc(CHAR_COMPACT_OPTIONAL_BLANK, + if (m->str_flags & STRING_COMPACT_WHITESPACE) + (void) fputc(CHAR_COMPACT_WHITESPACE, stderr); + if (m->str_flags & STRING_COMPACT_OPTIONAL_WHITESPACE) + (void) fputc(CHAR_COMPACT_OPTIONAL_WHITESPACE, stderr); if (m->str_flags & STRING_IGNORE_LOWERCASE) (void) fputc(CHAR_IGNORE_LOWERCASE, stderr); @@ -88,6 +87,24 @@ file_mdump(struct magic *m) (void) fputc(CHAR_IGNORE_UPPERCASE, stderr); if (m->str_flags & REGEX_OFFSET_START) (void) fputc(CHAR_REGEX_OFFSET_START, stderr); + if (m->str_flags & STRING_TEXTTEST) + (void) fputc(CHAR_TEXTTEST, stderr); + if (m->str_flags & STRING_BINTEST) + (void) fputc(CHAR_BINTEST, stderr); + if (m->str_flags & PSTRING_1_BE) + (void) fputc(CHAR_PSTRING_1_BE, stderr); + if (m->str_flags & PSTRING_2_BE) + (void) fputc(CHAR_PSTRING_2_BE, stderr); + if (m->str_flags & PSTRING_2_LE) + (void) fputc(CHAR_PSTRING_2_LE, stderr); + if (m->str_flags & PSTRING_4_BE) + (void) fputc(CHAR_PSTRING_4_BE, stderr); + if (m->str_flags & PSTRING_4_LE) + (void) fputc(CHAR_PSTRING_4_LE, stderr); + if (m->str_flags & PSTRING_LENGTH_INCLUDES_ITSELF) + (void) fputc( + CHAR_PSTRING_LENGTH_INCLUDES_ITSELF, + stderr); } if (m->str_range) (void) fprintf(stderr, "/%u", m->str_range); @@ -120,7 +137,7 @@ file_mdump(struct magic *m) case FILE_BEQUAD: case FILE_LEQUAD: case FILE_QUAD: - (void) fprintf(stderr, "%lld", + (void) fprintf(stderr, "%" INT64_T_FORMAT "d", (unsigned long long)m->value.q); break; case FILE_PSTRING: @@ -218,7 +235,7 @@ file_fmttime(uint32_t v, int local) (void)time(&now); tm1 = localtime(&now); if (tm1 == NULL) - return "*Invalid time*"; + goto out; daylight = tm1->tm_isdst; } #endif /* HAVE_TM_ISDST */ @@ -227,10 +244,14 @@ file_fmttime(uint32_t v, int local) t += 3600; tm = gmtime(&t); if (tm == NULL) - return "*Invalid time*"; + goto out; pp = asctime(tm); } + if (pp == NULL) + goto out; pp[strcspn(pp, "\n")] = '\0'; return pp; +out: + return "*Invalid time*"; } |