summaryrefslogtreecommitdiff
path: root/print.c
diff options
context:
space:
mode:
Diffstat (limited to 'print.c')
-rw-r--r--print.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/print.c b/print.c
index d44a5b3b1be82..3bc4d85322146 100644
--- a/print.c
+++ b/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.70 2011/08/14 09:03:12 christos Exp $")
#endif /* lint */
#include <string.h>
@@ -51,8 +51,7 @@ 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),
+ (void) fprintf(stderr, "%.*s %u", (m->cont_level & 7) + 1, ">>>>>>>>",
m->offset);
if (m->flag & INDIR) {
@@ -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);
@@ -120,7 +119,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 +217,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 +226,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*";
}