From b1be0f5746f5a3fb02c0dde0f4c1ee50413c9279 Mon Sep 17 00:00:00 2001 From: Christos Zoulas Date: Fri, 16 May 2008 14:25:00 +0000 Subject: [PATCH] fix vprintf bug. --- ChangeLog | 6 ++++++ src/funcs.c | 21 +++++++++++++++------ src/magic.c | 3 +-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index e2004629..a6f203eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-05-16 10:25 Christos Zoulas + + * Fix compiler warnings. + + * remove stray printf, and fix a vprintf bug. (Martin Dorey) + 2008-05-06 00:13 Robert Byrnes * src/Makefile.am: diff --git a/src/funcs.c b/src/funcs.c index ef3d3e7d..600c9b11 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -38,24 +38,21 @@ #endif #ifndef lint -FILE_RCSID("@(#)$File: funcs.c,v 1.39 2008/03/01 22:21:49 rrt Exp $") +FILE_RCSID("@(#)$File: funcs.c,v 1.40 2008/05/09 14:20:28 christos Exp $") #endif /* lint */ /* * Like printf, only we append to a buffer. */ protected int -file_printf(struct magic_set *ms, const char *fmt, ...) +file_vprintf(struct magic_set *ms, const char *fmt, va_list ap) { - va_list ap; int len; char *buf, *newstr; - va_start(ap, fmt); len = vasprintf(&buf, fmt, ap); if (len < 0) goto out; - va_end(ap); if (ms->o.buf != NULL) { len = asprintf(&newstr, "%s%s", ms->o.buf, buf); @@ -72,6 +69,18 @@ out: return -1; } +protected int +file_printf(struct magic_set *ms, const char *fmt, ...) +{ + int rv; + va_list ap; + + va_start(ap, fmt); + rv = file_vprintf(ms, fmt, ap); + va_end(ap); + return rv; +} + /* * error - print best error message possible */ @@ -88,7 +97,7 @@ file_error_core(struct magic_set *ms, int error, const char *f, va_list va, ms->o.buf = NULL; file_printf(ms, "line %u: ", lineno); } - file_printf(ms, f, va); + file_vprintf(ms, f, va); if (error > 0) file_printf(ms, " (%s)", strerror(error)); ms->haderr++; diff --git a/src/magic.c b/src/magic.c index 8ecbb8f0..0293bdef 100644 --- a/src/magic.c +++ b/src/magic.c @@ -63,7 +63,7 @@ #include "patchlevel.h" #ifndef lint -FILE_RCSID("@(#)$File: magic.c,v 1.49 2008/02/17 19:28:54 rrt Exp $") +FILE_RCSID("@(#)$File: magic.c,v 1.50 2008/02/19 00:58:59 rrt Exp $") #endif /* lint */ #ifndef PIPE_BUF @@ -302,7 +302,6 @@ file_or_fd(struct magic_set *ms, const char *inname, int fd) (void)strcat(strcpy(tmp, inname), ".exe"); if ((fd = open(tmp, flags)) < 0) { #endif - fprintf(stderr, "couldn't open file\n"); if (info_from_stat(ms, sb.st_mode) == -1) goto done; rv = 0; -- 2.40.0