aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Steven Schubiger <stsc@refcnt.org> 2013-07-31 18:25:48 +0200
committerGravatar Steven Schubiger <stsc@refcnt.org> 2013-07-31 18:25:48 +0200
commiteaf4e19237944d1a74d1bbd37fe3930b5b13f15f (patch)
tree21476c660c99eb945a1fc03fe6bbf62bd73d3a7f
parent712d03dec18769c5ce00af7edfc1b5f3f35e48da (diff)
downloadcolorize-eaf4e19237944d1a74d1bbd37fe3930b5b13f15f.tar.gz
colorize-eaf4e19237944d1a74d1bbd37fe3930b5b13f15f.tar.bz2
Add vfprintf_diag and macro
-rw-r--r--colorize.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/colorize.c b/colorize.c
index da444e4..3b80c9e 100644
--- a/colorize.c
+++ b/colorize.c
@@ -196,6 +196,7 @@ static void *realloc_wrap_debug (void *, size_t, const char *, unsigned int);
static void free_wrap (void **);
static char *strdup_wrap (const char *);
static char *str_concat (const char *, const char *);
+static void vfprintf_diag (const char *, ...);
static void vfprintf_fail (const char *, ...);
static void stack_var (void ***, unsigned int *, unsigned int, void *);
static void release_var (void **, unsigned int, void **);
@@ -971,15 +972,24 @@ str_concat (const char *str1, const char *str2)
return str;
}
+#define DO_VFPRINTF(fmt) \
+ va_list ap; \
+ fprintf (stderr, "%s: ", program_name); \
+ va_start (ap, fmt); \
+ vfprintf (stderr, fmt, ap); \
+ va_end (ap); \
+ fprintf (stderr, "\n"); \
+
+static void
+vfprintf_diag (const char *fmt, ...)
+{
+ DO_VFPRINTF (fmt);
+}
+
static void
vfprintf_fail (const char *fmt, ...)
{
- va_list ap;
- fprintf (stderr, "%s: ", program_name);
- va_start (ap, fmt);
- vfprintf (stderr, fmt, ap);
- va_end (ap);
- fprintf (stderr, "\n");
+ DO_VFPRINTF (fmt);
exit (EXIT_FAILURE);
}