From 68b1fd0cc60fe8719c04c9cae4a6f3e971b78409 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 15 Jul 2016 09:27:35 +0000 Subject: [PATCH 1/3] Wrap some long lines and apply some static. --- layout-custom.c | 25 ++++++++++++++----------- names.c | 9 ++++++--- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/layout-custom.c b/layout-custom.c index 99c6c3ce..c93e39c0 100644 --- a/layout-custom.c +++ b/layout-custom.c @@ -23,14 +23,17 @@ #include "tmux.h" -struct layout_cell *layout_find_bottomright(struct layout_cell *); -u_short layout_checksum(const char *); -int layout_append(struct layout_cell *, char *, size_t); -struct layout_cell *layout_construct(struct layout_cell *, const char **); -void layout_assign(struct window_pane **, struct layout_cell *); +static struct layout_cell *layout_find_bottomright(struct layout_cell *); +static u_short layout_checksum(const char *); +static int layout_append(struct layout_cell *, char *, + size_t); +static struct layout_cell *layout_construct(struct layout_cell *, + const char **); +static void layout_assign(struct window_pane **, + struct layout_cell *); /* Find the bottom-right cell. */ -struct layout_cell * +static struct layout_cell * layout_find_bottomright(struct layout_cell *lc) { if (lc->type == LAYOUT_WINDOWPANE) @@ -40,7 +43,7 @@ layout_find_bottomright(struct layout_cell *lc) } /* Calculate layout checksum. */ -u_short +static u_short layout_checksum(const char *layout) { u_short csum; @@ -63,12 +66,12 @@ layout_dump(struct layout_cell *root) if (layout_append(root, layout, sizeof layout) != 0) return (NULL); - xasprintf(&out, "%04x,%s", layout_checksum(layout), layout); + xasprintf(&out, "%04hx,%s", layout_checksum(layout), layout); return (out); } /* Append information for a single cell. */ -int +static int layout_append(struct layout_cell *lc, char *buf, size_t len) { struct layout_cell *lcchild; @@ -182,7 +185,7 @@ fail: } /* Assign panes into cells. */ -void +static void layout_assign(struct window_pane **wp, struct layout_cell *lc) { struct layout_cell *lcchild; @@ -201,7 +204,7 @@ layout_assign(struct window_pane **wp, struct layout_cell *lc) } /* Construct a cell from all or part of a layout tree. */ -struct layout_cell * +static struct layout_cell * layout_construct(struct layout_cell *lcparent, const char **layout) { struct layout_cell *lc, *lcchild; diff --git a/names.c b/names.c index a03f6f5b..485155ff 100644 --- a/names.c +++ b/names.c @@ -73,12 +73,15 @@ check_window_name(struct window *w) if (!event_initialized(&w->name_event)) evtimer_set(&w->name_event, name_time_callback, w); if (!evtimer_pending(&w->name_event, NULL)) { - log_debug("@%u name timer queued (%d left)", w->id, left); + log_debug("@%u name timer queued (%d left)", w->id, + left); timerclear(&next); next.tv_usec = left; event_add(&w->name_event, &next); - } else - log_debug("@%u name timer already queued (%d left)", w->id, left); + } else { + log_debug("@%u name timer already queued (%d left)", + w->id, left); + } return; } memcpy(&w->name_time, &tv, sizeof w->name_time); From 1718420c48737a3038966611c83f37f3c272901e Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 15 Jul 2016 09:28:32 +0000 Subject: [PATCH 2/3] Log environment to new panes. --- environ.c | 10 ++++++++++ tmux.h | 1 + window.c | 1 + 3 files changed, 12 insertions(+) diff --git a/environ.c b/environ.c index 31e57e0e..7709f29d 100644 --- a/environ.c +++ b/environ.c @@ -203,3 +203,13 @@ environ_push(struct environ *env) setenv(envent->name, envent->value, 1); } } + +/* Log the environment. */ +void +environ_log(struct environ *env) +{ + struct environ_entry *envent; + + RB_FOREACH(envent, environ, env) + log_debug("%s=%s", envent->name, envent->value); +} diff --git a/tmux.h b/tmux.h index f461c495..95d942f2 100644 --- a/tmux.h +++ b/tmux.h @@ -1693,6 +1693,7 @@ void environ_put(struct environ *, const char *); void environ_unset(struct environ *, const char *); void environ_update(const char *, struct environ *, struct environ *); void environ_push(struct environ *); +void environ_log(struct environ *); /* tty.c */ void tty_create_log(void); diff --git a/window.c b/window.c index 0b24d57a..2f158e3a 100644 --- a/window.c +++ b/window.c @@ -842,6 +842,7 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv, log_debug("spawn: %s -- %s", wp->shell, cmd); for (i = 0; i < wp->argc; i++) log_debug("spawn: argv[%d] = %s", i, wp->argv[i]); + environ_log(env); memset(&ws, 0, sizeof ws); ws.ws_col = screen_size_x(&wp->base); From 9436a316038d1d1c9bc161d282564ed67e2f8ce2 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 15 Jul 2016 09:52:34 +0000 Subject: [PATCH 3/3] Tweak output of environment logging. --- environ.c | 10 +++++++--- tmux.h | 2 +- window.c | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/environ.c b/environ.c index 7709f29d..5d06afbf 100644 --- a/environ.c +++ b/environ.c @@ -206,10 +206,14 @@ environ_push(struct environ *env) /* Log the environment. */ void -environ_log(struct environ *env) +environ_log(struct environ *env, const char *prefix) { struct environ_entry *envent; - RB_FOREACH(envent, environ, env) - log_debug("%s=%s", envent->name, envent->value); + RB_FOREACH(envent, environ, env) { + if (envent->value != NULL && *envent->name != '\0') { + log_debug("%s%s=%s", prefix, envent->name, + envent->value); + } + } } diff --git a/tmux.h b/tmux.h index 95d942f2..bad1d87e 100644 --- a/tmux.h +++ b/tmux.h @@ -1693,7 +1693,7 @@ void environ_put(struct environ *, const char *); void environ_unset(struct environ *, const char *); void environ_update(const char *, struct environ *, struct environ *); void environ_push(struct environ *); -void environ_log(struct environ *); +void environ_log(struct environ *, const char *); /* tty.c */ void tty_create_log(void); diff --git a/window.c b/window.c index 2f158e3a..c58313d5 100644 --- a/window.c +++ b/window.c @@ -842,7 +842,7 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv, log_debug("spawn: %s -- %s", wp->shell, cmd); for (i = 0; i < wp->argc; i++) log_debug("spawn: argv[%d] = %s", i, wp->argv[i]); - environ_log(env); + environ_log(env, "spawn: "); memset(&ws, 0, sizeof ws); ws.ws_col = screen_size_x(&wp->base);