Merge branch 'obsd-master'

pull/210/head
Thomas Adam 2015-11-18 16:01:23 +00:00
commit 7fe8edc396
31 changed files with 141 additions and 83 deletions

View File

@ -35,7 +35,7 @@ int alerts_check_silence(struct session *, struct winlink *);
void alerts_ring_bell(struct session *);
void
alerts_timer(unused int fd, unused short events, void *arg)
alerts_timer(__unused int fd, __unused short events, void *arg)
{
struct window *w = arg;
@ -45,7 +45,7 @@ alerts_timer(unused int fd, unused short events, void *arg)
}
void
alerts_callback(unused int fd, unused short events, unused void *arg)
alerts_callback(__unused int fd, __unused short events, __unused void *arg)
{
struct window *w;
struct session *s;

2
cfg.c
View File

@ -132,7 +132,7 @@ load_cfg(const char *path, struct cmd_q *cmdq, char **cause)
}
void
cfg_default_done(unused struct cmd_q *cmdq)
cfg_default_done(__unused struct cmd_q *cmdq)
{
if (--cfg_references != 0)
return;

View File

@ -413,7 +413,8 @@ client_send_identify(const char *ttynam, const char *cwd)
/* Callback for client stdin read events. */
void
client_stdin_callback(unused int fd, unused short events, unused void *arg)
client_stdin_callback(__unused int fd, __unused short events,
__unused void *arg)
{
struct msg_stdin_data data;
@ -515,7 +516,7 @@ client_signal(int sig)
/* Callback for client read events. */
void
client_dispatch(struct imsg *imsg, unused void *arg)
client_dispatch(struct imsg *imsg, __unused void *arg)
{
if (imsg == NULL) {
client_exitreason = CLIENT_EXIT_LOST_SERVER;

View File

@ -46,7 +46,7 @@ const struct cmd_entry cmd_start_server_entry = {
};
enum cmd_retval
cmd_kill_server_exec(struct cmd *self, unused struct cmd_q *cmdq)
cmd_kill_server_exec(struct cmd *self, __unused struct cmd_q *cmdq)
{
if (self->entry == &cmd_kill_server_entry)
kill(getpid(), SIGTERM);

View File

@ -41,7 +41,7 @@ const struct cmd_entry cmd_list_buffers_entry = {
};
enum cmd_retval
cmd_list_buffers_exec(unused struct cmd *self, struct cmd_q *cmdq)
cmd_list_buffers_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
struct paste_buffer *pb;

View File

@ -30,7 +30,7 @@
enum cmd_retval cmd_list_keys_exec(struct cmd *, struct cmd_q *);
enum cmd_retval cmd_list_keys_table(struct cmd *, struct cmd_q *);
enum cmd_retval cmd_list_keys_commands(struct cmd *, struct cmd_q *);
enum cmd_retval cmd_list_keys_commands(struct cmd_q *);
const struct cmd_entry cmd_list_keys_entry = {
"list-keys", "lsk",
@ -60,7 +60,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
int repeat, width, tablewidth, keywidth;
if (self->entry == &cmd_list_commands_entry)
return (cmd_list_keys_commands(self, cmdq));
return (cmd_list_keys_commands(cmdq));
if (args_has(args, 't'))
return (cmd_list_keys_table(self, cmdq));
@ -178,7 +178,7 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
}
enum cmd_retval
cmd_list_keys_commands(unused struct cmd *self, struct cmd_q *cmdq)
cmd_list_keys_commands(struct cmd_q *cmdq)
{
const struct cmd_entry **entryp;
const struct cmd_entry *entry;

View File

@ -51,7 +51,7 @@ const struct cmd_entry cmd_lock_client_entry = {
};
enum cmd_retval
cmd_lock_server_exec(struct cmd *self, unused struct cmd_q *cmdq)
cmd_lock_server_exec(struct cmd *self, __unused struct cmd_q *cmdq)
{
struct args *args = self->args;
struct client *c;

View File

@ -141,8 +141,8 @@ cmd_pipe_pane_exec(struct cmd *self, struct cmd_q *cmdq)
}
void
cmd_pipe_pane_error_callback(
unused struct bufferevent *bufev, unused short what, void *data)
cmd_pipe_pane_error_callback(__unused struct bufferevent *bufev,
__unused short what, void *data)
{
struct window_pane *wp = data;

View File

@ -350,7 +350,7 @@ cmd_set_option_set(struct cmd *self, struct cmd_q *cmdq,
/* Set a string option. */
struct options_entry *
cmd_set_option_string(struct cmd *self, unused struct cmd_q *cmdq,
cmd_set_option_string(struct cmd *self, __unused struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo,
const char *value)
{
@ -372,7 +372,7 @@ cmd_set_option_string(struct cmd *self, unused struct cmd_q *cmdq,
/* Set a number option. */
struct options_entry *
cmd_set_option_number(unused struct cmd *self, struct cmd_q *cmdq,
cmd_set_option_number(__unused struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo,
const char *value)
{
@ -390,7 +390,7 @@ cmd_set_option_number(unused struct cmd *self, struct cmd_q *cmdq,
/* Set a key option. */
struct options_entry *
cmd_set_option_key(unused struct cmd *self, struct cmd_q *cmdq,
cmd_set_option_key(__unused struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo,
const char *value)
{
@ -406,7 +406,7 @@ cmd_set_option_key(unused struct cmd *self, struct cmd_q *cmdq,
/* Set a colour option. */
struct options_entry *
cmd_set_option_colour(unused struct cmd *self, struct cmd_q *cmdq,
cmd_set_option_colour(__unused struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo,
const char *value)
{
@ -422,7 +422,7 @@ cmd_set_option_colour(unused struct cmd *self, struct cmd_q *cmdq,
/* Set an attributes option. */
struct options_entry *
cmd_set_option_attributes(unused struct cmd *self, struct cmd_q *cmdq,
cmd_set_option_attributes(__unused struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo,
const char *value)
{
@ -438,7 +438,7 @@ cmd_set_option_attributes(unused struct cmd *self, struct cmd_q *cmdq,
/* Set a flag option. */
struct options_entry *
cmd_set_option_flag(unused struct cmd *self, struct cmd_q *cmdq,
cmd_set_option_flag(__unused struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo,
const char *value)
{
@ -466,7 +466,7 @@ cmd_set_option_flag(unused struct cmd *self, struct cmd_q *cmdq,
/* Set a choice option. */
struct options_entry *
cmd_set_option_choice(unused struct cmd *self, struct cmd_q *cmdq,
cmd_set_option_choice(__unused struct cmd *self, struct cmd_q *cmdq,
const struct options_table_entry *oe, struct options *oo,
const char *value)
{

View File

@ -111,7 +111,7 @@ cmd_wait_for_remove(struct wait_channel *wc)
}
enum cmd_retval
cmd_wait_for_exec(struct cmd *self, unused struct cmd_q *cmdq)
cmd_wait_for_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
const char *name = args->argv[0];
@ -130,7 +130,7 @@ cmd_wait_for_exec(struct cmd *self, unused struct cmd_q *cmdq)
}
enum cmd_retval
cmd_wait_for_signal(unused struct cmd_q *cmdq, const char *name,
cmd_wait_for_signal(__unused struct cmd_q *cmdq, const char *name,
struct wait_channel *wc)
{
struct cmd_q *wq, *wq1;

View File

@ -101,7 +101,7 @@ control_notify_window_layout_changed(struct window *w)
}
void
control_notify_window_unlinked(unused struct session *s, struct window *w)
control_notify_window_unlinked(__unused struct session *s, struct window *w)
{
struct client *c;
struct session *cs;
@ -119,7 +119,7 @@ control_notify_window_unlinked(unused struct session *s, struct window *w)
}
void
control_notify_window_linked(unused struct session *s, struct window *w)
control_notify_window_linked(__unused struct session *s, struct window *w)
{
struct client *c;
struct session *cs;
@ -183,7 +183,7 @@ control_notify_session_renamed(struct session *s)
}
void
control_notify_session_created(unused struct session *s)
control_notify_session_created(__unused struct session *s)
{
struct client *c;
@ -196,7 +196,7 @@ control_notify_session_created(unused struct session *s)
}
void
control_notify_session_close(unused struct session *s)
control_notify_session_close(__unused struct session *s)
{
struct client *c;

View File

@ -51,7 +51,7 @@ control_write_buffer(struct client *c, struct evbuffer *buffer)
/* Control input callback. Read lines and fire commands. */
void
control_callback(struct client *c, int closed, unused void *data)
control_callback(struct client *c, int closed, __unused void *data)
{
char *line, *cause;
struct cmd_list *cmdlist;

View File

@ -101,6 +101,7 @@ format_job_cmp(struct format_job *fj1, struct format_job *fj2)
#define FORMAT_TIMESTRING 0x1
#define FORMAT_BASENAME 0x2
#define FORMAT_DIRNAME 0x4
#define FORMAT_SUBSTITUTE 0x8
/* Entry in format tree. */
struct format_entry {
@ -260,7 +261,7 @@ format_job_get(struct format_tree *ft, const char *cmd)
/* Remove old jobs. */
void
format_job_timer(unused int fd, unused short events, unused void *arg)
format_job_timer(__unused int fd, __unused short events, __unused void *arg)
{
struct format_job *fj, *fj1;
time_t now;
@ -289,7 +290,7 @@ format_job_timer(unused int fd, unused short events, unused void *arg)
/* Callback for host. */
void
format_cb_host(unused struct format_tree *ft, struct format_entry *fe)
format_cb_host(__unused struct format_tree *ft, struct format_entry *fe)
{
char host[HOST_NAME_MAX + 1];
@ -301,7 +302,7 @@ format_cb_host(unused struct format_tree *ft, struct format_entry *fe)
/* Callback for host_short. */
void
format_cb_host_short(unused struct format_tree *ft, struct format_entry *fe)
format_cb_host_short(__unused struct format_tree *ft, struct format_entry *fe)
{
char host[HOST_NAME_MAX + 1], *cp;
@ -316,7 +317,7 @@ format_cb_host_short(unused struct format_tree *ft, struct format_entry *fe)
/* Callback for pid. */
void
format_cb_pid(unused struct format_tree *ft, struct format_entry *fe)
format_cb_pid(__unused struct format_tree *ft, struct format_entry *fe)
{
xasprintf(&fe->value, "%ld", (long)getpid());
}
@ -699,8 +700,9 @@ int
format_replace(struct format_tree *ft, const char *key, size_t keylen,
char **buf, size_t *len, size_t *off)
{
char *copy, *copy0, *endptr, *ptr, *saved, *trimmed, *value;
size_t valuelen;
char *copy, *copy0, *endptr, *ptr, *found, *new, *value;
char *from = NULL, *to = NULL;
size_t valuelen, newlen, fromlen, tolen, used;
u_long limit = 0;
int modifiers = 0, brackets;
@ -738,6 +740,29 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
modifiers |= FORMAT_TIMESTRING;
copy += 2;
break;
case 's':
if (copy[1] != '/')
break;
from = copy + 2;
for (copy = from; *copy != '\0' && *copy != '/'; copy++)
/* nothing */;
if (copy[0] != '/' || copy == from) {
copy = copy0;
break;
}
copy[0] = '\0';
to = copy + 1;
for (copy = to; *copy != '\0' && *copy != '/'; copy++)
/* nothing */;
if (copy[0] != '/' || copy[1] != ':') {
copy = copy0;
break;
}
copy[0] = '\0';
modifiers |= FORMAT_SUBSTITUTE;
copy += 2;
break;
}
/*
@ -751,7 +776,7 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
*ptr = '\0';
value = ptr + 1;
saved = format_find(ft, copy + 1, modifiers);
found = format_find(ft, copy + 1, modifiers);
brackets = 0;
for (ptr = ptr + 1; *ptr != '\0'; ptr++) {
@ -765,29 +790,56 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
if (*ptr == '\0')
goto fail;
if (saved != NULL && *saved != '\0' &&
(saved[0] != '0' || saved[1] != '\0')) {
if (found != NULL && *found != '\0' &&
(found[0] != '0' || found[1] != '\0')) {
*ptr = '\0';
} else
value = ptr + 1;
value = format_expand(ft, value);
free(saved);
saved = value;
free(found);
} else {
saved = value = format_find(ft, copy, modifiers);
value = format_find(ft, copy, modifiers);
if (value == NULL)
saved = value = xstrdup("");
value = xstrdup("");
}
/* Perform substitution if any. */
if (modifiers & FORMAT_SUBSTITUTE) {
fromlen = strlen(from);
tolen = strlen(to);
newlen = strlen(value) + 1;
copy = new = xmalloc(newlen);
for (ptr = value; *ptr != '\0'; /* nothing */) {
if (strncmp(ptr, from, fromlen) != 0) {
*new++ = *ptr++;
continue;
}
used = new - copy;
newlen += tolen;
copy = xrealloc(copy, newlen);
new = copy + used;
memcpy(new, to, tolen);
new += tolen;
ptr += fromlen;
}
*new = '\0';
free(value);
value = copy;
}
/* Truncate the value if needed. */
if (limit != 0) {
value = trimmed = utf8_trimcstr(value, limit);
free(saved);
saved = trimmed;
new = utf8_trimcstr(value, limit);
free(value);
value = new;
}
valuelen = strlen(value);
/* Expand the buffer and copy in the value. */
valuelen = strlen(value);
while (*len - *off < valuelen + 1) {
*buf = xreallocarray(*buf, 2, *len);
*len *= 2;
@ -795,7 +847,7 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
memcpy(*buf + *off, value, valuelen);
*off += valuelen;
free(saved);
free(value);
free(copy0);
return (0);

5
job.c
View File

@ -149,7 +149,7 @@ job_free(struct job *job)
/* Called when output buffer falls below low watermark (default is 0). */
void
job_write_callback(unused struct bufferevent *bufev, void *data)
job_write_callback(__unused struct bufferevent *bufev, void *data)
{
struct job *job = data;
size_t len = EVBUFFER_LENGTH(EVBUFFER_OUTPUT(job->event));
@ -165,7 +165,8 @@ job_write_callback(unused struct bufferevent *bufev, void *data)
/* Job buffer error callback. */
void
job_callback(unused struct bufferevent *bufev, unused short events, void *data)
job_callback(__unused struct bufferevent *bufev, __unused short events,
void *data)
{
struct job *job = data;

2
log.c
View File

@ -32,7 +32,7 @@ void log_vwrite(const char *, va_list);
/* Log callback for libevent. */
void
log_event_cb(unused int severity, const char *msg)
log_event_cb(__unused int severity, const char *msg)
{
log_debug("%s", msg);
}

View File

@ -29,7 +29,7 @@ void name_time_callback(int, short, void *);
int name_time_expired(struct window *, struct timeval *);
void
name_time_callback(unused int fd, unused short events, void *arg)
name_time_callback(__unused int fd, __unused short events, void *arg)
{
struct window *w = arg;

4
proc.c
View File

@ -52,7 +52,7 @@ static int peer_check_version(struct tmuxpeer *, struct imsg *);
static void proc_update_event(struct tmuxpeer *);
static void
proc_event_cb(unused int fd, short events, void *arg)
proc_event_cb(__unused int fd, short events, void *arg)
{
struct tmuxpeer *peer = arg;
ssize_t n;
@ -100,7 +100,7 @@ proc_event_cb(unused int fd, short events, void *arg)
}
static void
proc_signal_cb(int signo, unused short events, void *arg)
proc_signal_cb(int signo, __unused short events, void *arg)
{
struct tmuxproc *tp = arg;

View File

@ -42,7 +42,7 @@ screen_write_start(struct screen_write_ctx *ctx, struct window_pane *wp,
/* Finish writing. */
void
screen_write_stop(unused struct screen_write_ctx *ctx)
screen_write_stop(__unused struct screen_write_ctx *ctx)
{
}

View File

@ -244,7 +244,7 @@ server_client_unref(struct client *c)
/* Free dead client. */
void
server_client_free(unused int fd, unused short events, void *arg)
server_client_free(__unused int fd, __unused short events, void *arg)
{
struct client *c = arg;
@ -826,7 +826,7 @@ server_client_reset_state(struct client *c)
/* Repeat time callback. */
void
server_client_repeat_timer(unused int fd, unused short events, void *data)
server_client_repeat_timer(__unused int fd, __unused short events, void *data)
{
struct client *c = data;
@ -1227,7 +1227,7 @@ server_client_dispatch_shell(struct client *c)
/* Event callback to push more stdout data if any left. */
static void
server_client_stdout_cb(unused int fd, unused short events, void *arg)
server_client_stdout_cb(__unused int fd, __unused short events, void *arg)
{
struct client *c = arg;
@ -1268,7 +1268,7 @@ server_client_push_stdout(struct client *c)
/* Event callback to push more stderr data if any left. */
static void
server_client_stderr_cb(unused int fd, unused short events, void *arg)
server_client_stderr_cb(__unused int fd, __unused short events, void *arg)
{
struct client *c = arg;

View File

@ -444,7 +444,7 @@ server_clear_identify(struct client *c)
}
void
server_callback_identify(unused int fd, unused short events, void *data)
server_callback_identify(__unused int fd, __unused short events, void *data)
{
struct client *c = data;

View File

@ -300,7 +300,7 @@ server_update_socket(void)
/* Callback for server socket. */
void
server_accept(int fd, short events, unused void *data)
server_accept(int fd, short events, __unused void *data)
{
struct sockaddr_storage sa;
socklen_t slen = sizeof sa;

View File

@ -180,7 +180,7 @@ session_unref(struct session *s)
/* Free session. */
void
session_free(unused int fd, unused short events, void *arg)
session_free(__unused int fd, __unused short events, void *arg)
{
struct session *s = arg;
@ -235,7 +235,7 @@ session_check_name(const char *name)
/* Lock session if it has timed out. */
void
session_lock_timer(unused int fd, unused short events, void *arg)
session_lock_timer(__unused int fd, __unused short events, void *arg)
{
struct session *s = arg;

View File

@ -145,7 +145,7 @@ status_prompt_save_history(void)
/* Status timer callback. */
void
status_timer_callback(unused int fd, unused short events, void *arg)
status_timer_callback(__unused int fd, __unused short events, void *arg)
{
struct client *c = arg;
struct session *s = c->session;
@ -604,7 +604,7 @@ status_message_clear(struct client *c)
/* Clear status line message after timer expires. */
void
status_message_callback(unused int fd, unused short event, void *data)
status_message_callback(__unused int fd, __unused short event, void *data)
{
struct client *c = data;

7
tmux.1
View File

@ -3315,6 +3315,13 @@ prefixes are
and
.Xr dirname 3
of the variable respectively.
A prefix of the form
.Ql s/foo/bar/:
will substitute
.Ql foo
with
.Ql bar
throughout.
.Pp
In addition, the first line of a shell command's output may be inserted using
.Ql #() .

3
tmux.h
View File

@ -72,9 +72,6 @@ struct tmuxproc;
#define READ_BACKOFF 512
#define READ_TIME 100
/* Definition to shut gcc up about unused arguments. */
#define unused __attribute__ ((unused))
/* Attribute to make gcc check printf-like arguments. */
#define printflike(a, b) __attribute__ ((format (printf, a, b)))

View File

@ -635,7 +635,7 @@ discard_key:
/* Key timer callback. */
void
tty_keys_callback(unused int fd, unused short events, void *data)
tty_keys_callback(__unused int fd, __unused short events, void *data)
{
struct tty *tty = data;

8
tty.c
View File

@ -172,7 +172,7 @@ tty_open(struct tty *tty, char **cause)
}
void
tty_read_callback(unused struct bufferevent *bufev, void *data)
tty_read_callback(__unused struct bufferevent *bufev, void *data)
{
struct tty *tty = data;
@ -181,8 +181,8 @@ tty_read_callback(unused struct bufferevent *bufev, void *data)
}
void
tty_error_callback(
unused struct bufferevent *bufev, unused short what, unused void *data)
tty_error_callback(__unused struct bufferevent *bufev, __unused short what,
__unused void *data)
{
}
@ -591,7 +591,7 @@ tty_repeat_space(struct tty *tty, u_int n)
* pane.
*/
int
tty_large_region(unused struct tty *tty, const struct tty_ctx *ctx)
tty_large_region(__unused struct tty *tty, const struct tty_ctx *ctx)
{
struct window_pane *wp = ctx->wp;

View File

@ -509,8 +509,8 @@ window_choose_get_item(struct window_pane *wp, key_code key,
}
void
window_choose_key(struct window_pane *wp, unused struct client *c,
unused struct session *sess, key_code key, struct mouse_event *m)
window_choose_key(struct window_pane *wp, __unused struct client *c,
__unused struct session *sess, key_code key, struct mouse_event *m)
{
struct window_choose_mode_data *data = wp->modedata;
struct screen *s = &data->screen;

View File

@ -120,7 +120,7 @@ const char window_clock_table[14][5][5] = {
};
void
window_clock_timer_callback(unused int fd, unused short events, void *arg)
window_clock_timer_callback(__unused int fd, __unused short events, void *arg)
{
struct window_pane *wp = arg;
struct window_clock_mode_data *data = wp->modedata;
@ -185,9 +185,9 @@ window_clock_resize(struct window_pane *wp, u_int sx, u_int sy)
}
void
window_clock_key(struct window_pane *wp, unused struct client *c,
unused struct session *sess, unused key_code key,
unused struct mouse_event *m)
window_clock_key(struct window_pane *wp, __unused struct client *c,
__unused struct session *sess, __unused key_code key,
__unused struct mouse_event *m)
{
window_pane_reset_mode(wp);
}

View File

@ -2232,7 +2232,7 @@ window_copy_rectangle_toggle(struct window_pane *wp)
}
void
window_copy_start_drag(struct client *c, unused struct mouse_event *m)
window_copy_start_drag(struct client *c, struct mouse_event *m)
{
struct window_pane *wp;
u_int x, y;
@ -2253,7 +2253,7 @@ window_copy_start_drag(struct client *c, unused struct mouse_event *m)
}
void
window_copy_drag_update(unused struct client *c, struct mouse_event *m)
window_copy_drag_update(__unused struct client *c, struct mouse_event *m)
{
struct window_pane *wp;
struct window_copy_mode_data *data;
@ -2274,7 +2274,7 @@ window_copy_drag_update(unused struct client *c, struct mouse_event *m)
}
void
window_copy_drag_release(unused struct client *c, struct mouse_event *m)
window_copy_drag_release(__unused struct client *c, struct mouse_event *m)
{
struct window_pane *wp;

View File

@ -929,13 +929,13 @@ window_pane_spawn(struct window_pane *wp, int argc, char **argv,
}
void
window_pane_timer_callback(unused int fd, unused short events, void *data)
window_pane_timer_callback(__unused int fd, __unused short events, void *data)
{
window_pane_read_callback(NULL, data);
}
void
window_pane_read_callback(unused struct bufferevent *bufev, void *data)
window_pane_read_callback(__unused struct bufferevent *bufev, void *data)
{
struct window_pane *wp = data;
struct evbuffer *evb = wp->event->input;
@ -981,8 +981,8 @@ start_timer:
}
void
window_pane_error_callback(unused struct bufferevent *bufev, unused short what,
void *data)
window_pane_error_callback(__unused struct bufferevent *bufev,
__unused short what, void *data)
{
struct window_pane *wp = data;