=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/format.c,v retrieving revision 1.107 retrieving revision 1.108 diff -u -r1.107 -r1.108 --- src/usr.bin/tmux/format.c 2016/05/23 20:39:26 1.107 +++ src/usr.bin/tmux/format.c 2016/10/10 21:29:23 1.108 @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.107 2016/05/23 20:39:26 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.108 2016/10/10 21:29:23 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott @@ -39,34 +39,41 @@ struct format_entry; typedef void (*format_cb)(struct format_tree *, struct format_entry *); -void format_job_callback(struct job *); -char *format_job_get(struct format_tree *, const char *); -void format_job_timer(int, short, void *); +static void format_job_callback(struct job *); +static char *format_job_get(struct format_tree *, const char *); +static void format_job_timer(int, short, void *); -void format_cb_host(struct format_tree *, struct format_entry *); -void format_cb_host_short(struct format_tree *, struct format_entry *); -void format_cb_pid(struct format_tree *, struct format_entry *); -void format_cb_session_alerts(struct format_tree *, struct format_entry *); -void format_cb_window_layout(struct format_tree *, struct format_entry *); -void format_cb_window_visible_layout(struct format_tree *, - struct format_entry *); -void format_cb_start_command(struct format_tree *, struct format_entry *); -void format_cb_current_command(struct format_tree *, struct format_entry *); -void format_cb_history_bytes(struct format_tree *, struct format_entry *); -void format_cb_pane_tabs(struct format_tree *, struct format_entry *); +static void format_cb_host(struct format_tree *, struct format_entry *); +static void format_cb_host_short(struct format_tree *, + struct format_entry *); +static void format_cb_pid(struct format_tree *, struct format_entry *); +static void format_cb_session_alerts(struct format_tree *, + struct format_entry *); +static void format_cb_window_layout(struct format_tree *, + struct format_entry *); +static void format_cb_window_visible_layout(struct format_tree *, + struct format_entry *); +static void format_cb_start_command(struct format_tree *, + struct format_entry *); +static void format_cb_current_command(struct format_tree *, + struct format_entry *); +static void format_cb_history_bytes(struct format_tree *, + struct format_entry *); +static void format_cb_pane_tabs(struct format_tree *, + struct format_entry *); -char *format_find(struct format_tree *, const char *, int); -void format_add_cb(struct format_tree *, const char *, format_cb); -void format_add_tv(struct format_tree *, const char *, struct timeval *); -int format_replace(struct format_tree *, const char *, size_t, char **, - size_t *, size_t *); -char *format_time_string(time_t); +static char *format_find(struct format_tree *, const char *, int); +static void format_add_cb(struct format_tree *, const char *, format_cb); +static void format_add_tv(struct format_tree *, const char *, + struct timeval *); +static int format_replace(struct format_tree *, const char *, size_t, + char **, size_t *, size_t *); -void format_defaults_pane_tabs(struct format_tree *, struct window_pane *); -void format_defaults_session(struct format_tree *, struct session *); -void format_defaults_client(struct format_tree *, struct client *); -void format_defaults_winlink(struct format_tree *, struct session *, - struct winlink *); +static void format_defaults_session(struct format_tree *, + struct session *); +static void format_defaults_client(struct format_tree *, struct client *); +static void format_defaults_winlink(struct format_tree *, struct session *, + struct winlink *); /* Entry in format job tree. */ struct format_job { @@ -82,14 +89,13 @@ }; /* Format job tree. */ -struct event format_job_event; -int format_job_cmp(struct format_job *, struct format_job *); +static struct event format_job_event; +static int format_job_cmp(struct format_job *, struct format_job *); RB_HEAD(format_job_tree, format_job) format_jobs = RB_INITIALIZER(); -RB_PROTOTYPE(format_job_tree, format_job, entry, format_job_cmp); -RB_GENERATE(format_job_tree, format_job, entry, format_job_cmp); +RB_GENERATE_STATIC(format_job_tree, format_job, entry, format_job_cmp); /* Format job tree comparison function. */ -int +static int format_job_cmp(struct format_job *fj1, struct format_job *fj2) { return (strcmp(fj1->cmd, fj2->cmd)); @@ -120,19 +126,18 @@ RB_HEAD(format_entry_tree, format_entry) tree; }; -int format_entry_cmp(struct format_entry *, struct format_entry *); -RB_PROTOTYPE(format_entry_tree, format_entry, entry, format_entry_cmp); -RB_GENERATE(format_entry_tree, format_entry, entry, format_entry_cmp); +static int format_entry_cmp(struct format_entry *, struct format_entry *); +RB_GENERATE_STATIC(format_entry_tree, format_entry, entry, format_entry_cmp); /* Format entry tree comparison function. */ -int +static int format_entry_cmp(struct format_entry *fe1, struct format_entry *fe2) { return (strcmp(fe1->key, fe2->key)); } /* Single-character uppercase aliases. */ -const char *format_upper[] = { +static const char *format_upper[] = { NULL, /* A */ NULL, /* B */ NULL, /* C */ @@ -162,7 +167,7 @@ }; /* Single-character lowercase aliases. */ -const char *format_lower[] = { +static const char *format_lower[] = { NULL, /* a */ NULL, /* b */ NULL, /* c */ @@ -192,7 +197,7 @@ }; /* Format job callback. */ -void +static void format_job_callback(struct job *job) { struct format_job *fj = job->data; @@ -224,7 +229,7 @@ } /* Find a job. */ -char * +static char * format_job_get(struct format_tree *ft, const char *cmd) { struct format_job fj0, *fj; @@ -258,7 +263,7 @@ } /* Remove old jobs. */ -void +static void format_job_timer(__unused int fd, __unused short events, __unused void *arg) { struct format_job *fj, *fj1; @@ -287,7 +292,7 @@ } /* Callback for host. */ -void +static void format_cb_host(__unused struct format_tree *ft, struct format_entry *fe) { char host[HOST_NAME_MAX + 1]; @@ -299,7 +304,7 @@ } /* Callback for host_short. */ -void +static void format_cb_host_short(__unused struct format_tree *ft, struct format_entry *fe) { char host[HOST_NAME_MAX + 1], *cp; @@ -314,14 +319,14 @@ } /* Callback for pid. */ -void +static void format_cb_pid(__unused struct format_tree *ft, struct format_entry *fe) { xasprintf(&fe->value, "%ld", (long)getpid()); } /* Callback for session_alerts. */ -void +static void format_cb_session_alerts(struct format_tree *ft, struct format_entry *fe) { struct session *s = ft->s; @@ -351,7 +356,7 @@ } /* Callback for window_layout. */ -void +static void format_cb_window_layout(struct format_tree *ft, struct format_entry *fe) { struct window *w = ft->w; @@ -366,7 +371,7 @@ } /* Callback for window_visible_layout. */ -void +static void format_cb_window_visible_layout(struct format_tree *ft, struct format_entry *fe) { struct window *w = ft->w; @@ -378,7 +383,7 @@ } /* Callback for pane_start_command. */ -void +static void format_cb_start_command(struct format_tree *ft, struct format_entry *fe) { struct window_pane *wp = ft->wp; @@ -390,7 +395,7 @@ } /* Callback for pane_current_command. */ -void +static void format_cb_current_command(struct format_tree *ft, struct format_entry *fe) { struct window_pane *wp = ft->wp; @@ -413,7 +418,7 @@ } /* Callback for history_bytes. */ -void +static void format_cb_history_bytes(struct format_tree *ft, struct format_entry *fe) { struct window_pane *wp = ft->wp; @@ -438,7 +443,7 @@ } /* Callback for pane_tabs. */ -void +static void format_cb_pane_tabs(struct format_tree *ft, struct format_entry *fe) { struct window_pane *wp = ft->wp; @@ -539,7 +544,7 @@ } /* Add a key and time. */ -void +static void format_add_tv(struct format_tree *ft, const char *key, struct timeval *tv) { struct format_entry *fe; @@ -563,7 +568,7 @@ } /* Add a key and function. */ -void +static void format_add_cb(struct format_tree *ft, const char *key, format_cb cb) { struct format_entry *fe; @@ -587,7 +592,7 @@ } /* Find a format entry. */ -char * +static char * format_find(struct format_tree *ft, const char *key, int modifiers) { struct format_entry *fe, fe_find; @@ -682,7 +687,7 @@ * Replace a key/value pair in buffer. #{blah} is expanded directly, * #{?blah,a,b} is replace with a if blah exists and is nonzero else b. */ -int +static int format_replace(struct format_tree *ft, const char *key, size_t keylen, char **buf, size_t *len, size_t *off) { @@ -1002,7 +1007,7 @@ } /* Set default format keys for a session. */ -void +static void format_defaults_session(struct format_tree *ft, struct session *s) { struct session_group *sg; @@ -1031,7 +1036,7 @@ } /* Set default format keys for a client. */ -void +static void format_defaults_client(struct format_tree *ft, struct client *c) { struct session *s; @@ -1098,7 +1103,7 @@ } /* Set default format keys for a winlink. */ -void +static void format_defaults_winlink(struct format_tree *ft, struct session *s, struct winlink *wl) {