Make environ_log prefix take a format.

This commit is contained in:
nicm 2017-05-11 07:34:54 +00:00
parent c54a5b3690
commit 349cdd6110
2 changed files with 10 additions and 2 deletions

View File

@ -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. */

2
tmux.h
View File

@ -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 */