From 349cdd6110b548db2f47bd458fef257260052dbc Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 11 May 2017 07:34:54 +0000 Subject: [PATCH] Make environ_log prefix take a format. --- environ.c | 10 +++++++++- tmux.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/environ.c b/environ.c index d884330e..29191ee5 100644 --- a/environ.c +++ b/environ.c @@ -208,9 +208,15 @@ environ_push(struct environ *env) /* Log the environment. */ void -environ_log(struct environ *env, const char *prefix) +environ_log(struct environ *env, const char *fmt, ...) { struct environ_entry *envent; + va_list ap; + char *prefix; + + va_start(ap, fmt); + vasprintf(&prefix, fmt, ap); + va_end(ap); RB_FOREACH(envent, environ, env) { if (envent->value != NULL && *envent->name != '\0') { @@ -218,6 +224,8 @@ environ_log(struct environ *env, const char *prefix) envent->value); } } + + free(prefix); } /* Create initial environment for new child. */ diff --git a/tmux.h b/tmux.h index 5fd57ee4..a91ed2e1 100644 --- a/tmux.h +++ b/tmux.h @@ -1621,7 +1621,7 @@ void environ_put(struct environ *, const char *); void environ_unset(struct environ *, const char *); void environ_update(struct options *, struct environ *, struct environ *); void environ_push(struct environ *); -void environ_log(struct environ *, const char *); +void printflike(2, 3) environ_log(struct environ *, const char *, ...); struct environ *environ_for_session(struct session *, int); /* tty.c */