1
0
mirror of https://github.com/tmux/tmux.git synced 2025-04-23 21:08:48 +00:00

Sync OpenBSD patchset 467:

tabs are better; ok nicm
This commit is contained in:
Tiago Cunha 2009-10-28 23:12:38 +00:00
parent e65aa04ad7
commit a5acabd923
11 changed files with 84 additions and 84 deletions

View File

@ -1,4 +1,4 @@
/* $Id: array.h,v 1.7 2008-09-29 16:58:02 nicm Exp $ */ /* $Id: array.h,v 1.8 2009-10-28 23:12:38 tcunha Exp $ */
/* /*
* Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2006 Nicholas Marriott <nicm@users.sourceforge.net>
@ -85,7 +85,7 @@
ARRAY_ITEMSIZE(a) * ((a)->num - (i) - 1)); \ ARRAY_ITEMSIZE(a) * ((a)->num - (i) - 1)); \
} \ } \
(a)->num--; \ (a)->num--; \
if ((a)->num == 0) \ if ((a)->num == 0) \
ARRAY_FREE(a); \ ARRAY_FREE(a); \
} while (0) } while (0)

6
cfg.c
View File

@ -1,4 +1,4 @@
/* $Id: cfg.c,v 1.22 2009-08-24 16:27:03 tcunha Exp $ */ /* $Id: cfg.c,v 1.23 2009-10-28 23:12:38 tcunha Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -53,9 +53,9 @@ cfg_error(unused struct cmd_ctx *ctx, const char *fmt, ...)
int int
load_cfg(const char *path, struct cmd_ctx *ctxin, char **cause) load_cfg(const char *path, struct cmd_ctx *ctxin, char **cause)
{ {
FILE *f; FILE *f;
u_int n; u_int n;
char *buf, *line, *ptr; char *buf, *line, *ptr;
size_t len; size_t len;
struct cmd_list *cmdlist; struct cmd_list *cmdlist;
struct cmd_ctx ctx; struct cmd_ctx ctx;

View File

@ -1,4 +1,4 @@
/* $Id: cmd-server-info.c,v 1.30 2009-10-15 01:51:09 tcunha Exp $ */ /* $Id: cmd-server-info.c,v 1.31 2009-10-28 23:12:38 tcunha Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -70,8 +70,8 @@ cmd_server_info_exec(unused struct cmd *self, struct cmd_ctx *ctx)
"tmux " BUILD ", pid %ld, started %s", (long) getpid(), tim); "tmux " BUILD ", pid %ld, started %s", (long) getpid(), tim);
ctx->print(ctx, "socket path %s, debug level %d%s", ctx->print(ctx, "socket path %s, debug level %d%s",
socket_path, debug_level, be_quiet ? ", quiet" : ""); socket_path, debug_level, be_quiet ? ", quiet" : "");
if (uname(&un) == 0) { if (uname(&un) == 0) {
ctx->print(ctx, "system is %s %s %s %s", ctx->print(ctx, "system is %s %s %s %s",
un.sysname, un.release, un.version, un.machine); un.sysname, un.release, un.version, un.machine);
} }
if (cfg_file != NULL) if (cfg_file != NULL)

View File

@ -1,4 +1,4 @@
/* $Id: cmd-string.c,v 1.23 2009-08-09 17:48:55 tcunha Exp $ */ /* $Id: cmd-string.c,v 1.24 2009-10-28 23:12:38 tcunha Exp $ */
/* /*
* Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net>
@ -204,33 +204,33 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
char *buf, *t; char *buf, *t;
size_t len; size_t len;
buf = NULL; buf = NULL;
len = 0; len = 0;
while ((ch = cmd_string_getc(s, p)) != endch) { while ((ch = cmd_string_getc(s, p)) != endch) {
switch (ch) { switch (ch) {
case EOF: case EOF:
goto error; goto error;
case '\\': case '\\':
if (!esc) if (!esc)
break; break;
switch (ch = cmd_string_getc(s, p)) { switch (ch = cmd_string_getc(s, p)) {
case EOF: case EOF:
goto error; goto error;
case 'e': case 'e':
ch = '\033'; ch = '\033';
break; break;
case 'r': case 'r':
ch = '\r'; ch = '\r';
break; break;
case 'n': case 'n':
ch = '\n'; ch = '\n';
break; break;
case 't': case 't':
ch = '\t'; ch = '\t';
break; break;
} }
break; break;
case '$': case '$':
if (!esc) if (!esc)
break; break;
@ -241,13 +241,13 @@ cmd_string_string(const char *s, size_t *p, char endch, int esc)
len += strlen(t); len += strlen(t);
xfree(t); xfree(t);
continue; continue;
} }
if (len >= SIZE_MAX - 2) if (len >= SIZE_MAX - 2)
goto error; goto error;
buf = xrealloc(buf, 1, len + 1); buf = xrealloc(buf, 1, len + 1);
buf[len++] = ch; buf[len++] = ch;
} }
buf = xrealloc(buf, 1, len + 1); buf = xrealloc(buf, 1, len + 1);
buf[len] = '\0'; buf[len] = '\0';
@ -272,7 +272,7 @@ cmd_string_variable(const char *s, size_t *p)
((ch) >= 'a' && (ch) <= 'z') || ((ch) >= 'A' && (ch) <= 'Z') || \ ((ch) >= 'a' && (ch) <= 'z') || ((ch) >= 'A' && (ch) <= 'Z') || \
((ch) >= '0' && (ch) <= '9')) ((ch) >= '0' && (ch) <= '9'))
buf = NULL; buf = NULL;
len = 0; len = 0;
fch = EOF; fch = EOF;

6
cmd.c
View File

@ -1,4 +1,4 @@
/* $Id: cmd.c,v 1.125 2009-10-15 01:56:45 tcunha Exp $ */ /* $Id: cmd.c,v 1.126 2009-10-28 23:12:38 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -178,7 +178,7 @@ struct cmd *
cmd_parse(int argc, char **argv, char **cause) cmd_parse(int argc, char **argv, char **cause)
{ {
const struct cmd_entry **entryp, *entry; const struct cmd_entry **entryp, *entry;
struct cmd *cmd; struct cmd *cmd;
char s[BUFSIZ]; char s[BUFSIZ];
int opt, ambiguous = 0; int opt, ambiguous = 0;
@ -841,7 +841,7 @@ cmd_find_pane(struct cmd_ctx *ctx,
/* Get the current session. */ /* Get the current session. */
if ((s = cmd_current_session(ctx)) == NULL) { if ((s = cmd_current_session(ctx)) == NULL) {
ctx->error(ctx, "can't establish current session"); ctx->error(ctx, "can't establish current session");
return (NULL); return (NULL);
} }
if (sp != NULL) if (sp != NULL)

View File

@ -1,4 +1,4 @@
/* $Id: input.c,v 1.100 2009-10-25 10:39:48 tcunha Exp $ */ /* $Id: input.c,v 1.101 2009-10-28 23:12:38 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -128,7 +128,7 @@ input_sequence_cmp(const void *a, const void *b)
void void
input_new_argument(struct input_ctx *ictx) input_new_argument(struct input_ctx *ictx)
{ {
struct input_arg *arg; struct input_arg *arg;
ARRAY_EXPAND(&ictx->args, 1); ARRAY_EXPAND(&ictx->args, 1);
@ -139,7 +139,7 @@ input_new_argument(struct input_ctx *ictx)
int int
input_add_argument(struct input_ctx *ictx, u_char ch) input_add_argument(struct input_ctx *ictx, u_char ch)
{ {
struct input_arg *arg; struct input_arg *arg;
if (ARRAY_LENGTH(&ictx->args) == 0) if (ARRAY_LENGTH(&ictx->args) == 0)
return (0); return (0);
@ -792,7 +792,7 @@ input_handle_sequence(u_char ch, struct input_ctx *ictx)
{ {
struct input_sequence_entry *entry, find; struct input_sequence_entry *entry, find;
struct screen *s = ictx->ctx.s; struct screen *s = ictx->ctx.s;
u_int i; u_int i;
struct input_arg *iarg; struct input_arg *iarg;
log_debug2("-- sq %zu: %hhu (%c): %u [sx=%u, sy=%u, cx=%u, cy=%u, " log_debug2("-- sq %zu: %hhu (%c): %u [sx=%u, sy=%u, cx=%u, cy=%u, "

View File

@ -1,4 +1,4 @@
/* $Id: server-client.c,v 1.8 2009-10-28 23:06:41 tcunha Exp $ */ /* $Id: server-client.c,v 1.9 2009-10-28 23:12:38 tcunha Exp $ */
/* /*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@ -491,8 +491,8 @@ server_client_msg_dispatch(struct client *c)
struct msg_environ_data environdata; struct msg_environ_data environdata;
ssize_t n, datalen; ssize_t n, datalen;
if ((n = imsg_read(&c->ibuf)) == -1 || n == 0) if ((n = imsg_read(&c->ibuf)) == -1 || n == 0)
return (-1); return (-1);
for (;;) { for (;;) {
if ((n = imsg_get(&c->ibuf, &imsg)) == -1) if ((n = imsg_get(&c->ibuf, &imsg)) == -1)

View File

@ -1,4 +1,4 @@
/* $Id: server.c,v 1.212 2009-10-28 23:11:07 tcunha Exp $ */ /* $Id: server.c,v 1.213 2009-10-28 23:12:38 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -670,12 +670,12 @@ void
server_lock_sessions(void) server_lock_sessions(void)
{ {
struct session *s; struct session *s;
u_int i; u_int i;
int timeout; int timeout;
time_t t; time_t t;
t = time(NULL); t = time(NULL);
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
if ((s = ARRAY_ITEM(&sessions, i)) == NULL) if ((s = ARRAY_ITEM(&sessions, i)) == NULL)
continue; continue;

12
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.181 2009-10-28 22:48:35 tcunha Exp $ */ /* $Id: tmux.c,v 1.182 2009-10-28 23:12:38 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -353,10 +353,10 @@ main(int argc, char **argv)
case 'v': case 'v':
debug_level++; debug_level++;
break; break;
default: default:
usage(); usage();
} }
} }
argc -= optind; argc -= optind;
argv += optind; argv += optind;
@ -578,7 +578,7 @@ main(int argc, char **argv)
if (pfd.revents & (POLLERR|POLLHUP|POLLNVAL)) if (pfd.revents & (POLLERR|POLLHUP|POLLNVAL))
fatalx("socket error"); fatalx("socket error");
if (pfd.revents & POLLIN) { if (pfd.revents & POLLIN) {
if (dispatch_imsg(ibuf, shellcmd, &retcode) != 0) if (dispatch_imsg(ibuf, shellcmd, &retcode) != 0)
break; break;
} }
@ -603,7 +603,7 @@ dispatch_imsg(struct imsgbuf *ibuf, const char *shellcmd, int *retcode)
struct msg_print_data printdata; struct msg_print_data printdata;
struct msg_shell_data shelldata; struct msg_shell_data shelldata;
if ((n = imsg_read(ibuf)) == -1 || n == 0) if ((n = imsg_read(ibuf)) == -1 || n == 0)
fatalx("imsg_read failed"); fatalx("imsg_read failed");
for (;;) { for (;;) {

4
tty.c
View File

@ -1,4 +1,4 @@
/* $Id: tty.c,v 1.163 2009-10-28 22:48:35 tcunha Exp $ */ /* $Id: tty.c,v 1.164 2009-10-28 23:12:38 tcunha Exp $ */
/* /*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -147,7 +147,7 @@ tty_start_tty(struct tty *tty)
tio.c_lflag &= ~(IEXTEN|ICANON|ECHO|ECHOE|ECHONL|ECHOCTL| tio.c_lflag &= ~(IEXTEN|ICANON|ECHO|ECHOE|ECHONL|ECHOCTL|
ECHOPRT|ECHOKE|ECHOCTL|ISIG); ECHOPRT|ECHOKE|ECHOCTL|ISIG);
tio.c_cc[VMIN] = 1; tio.c_cc[VMIN] = 1;
tio.c_cc[VTIME] = 0; tio.c_cc[VTIME] = 0;
if (tcsetattr(tty->fd, TCSANOW, &tio) != 0) if (tcsetattr(tty->fd, TCSANOW, &tio) != 0)
fatal("tcsetattr failed"); fatal("tcsetattr failed");

View File

@ -1,4 +1,4 @@
/* $Id: xmalloc.c,v 1.11 2009-10-28 23:08:04 tcunha Exp $ */ /* $Id: xmalloc.c,v 1.12 2009-10-28 23:12:38 tcunha Exp $ */
/* /*
* Copyright (c) 2004 Nicholas Marriott <nicm@users.sourceforge.net> * Copyright (c) 2004 Nicholas Marriott <nicm@users.sourceforge.net>
@ -42,16 +42,16 @@ xstrdup(const char *s)
void * void *
xcalloc(size_t nmemb, size_t size) xcalloc(size_t nmemb, size_t size)
{ {
void *ptr; void *ptr;
if (size == 0 || nmemb == 0) if (size == 0 || nmemb == 0)
fatalx("zero size"); fatalx("zero size");
if (SIZE_MAX / nmemb < size) if (SIZE_MAX / nmemb < size)
fatalx("nmemb * size > SIZE_MAX"); fatalx("nmemb * size > SIZE_MAX");
if ((ptr = calloc(nmemb, size)) == NULL) if ((ptr = calloc(nmemb, size)) == NULL)
fatal("xcalloc failed"); fatal("xcalloc failed");
return (ptr); return (ptr);
} }
void * void *
@ -59,12 +59,12 @@ xmalloc(size_t size)
{ {
void *ptr; void *ptr;
if (size == 0) if (size == 0)
fatalx("zero size"); fatalx("zero size");
if ((ptr = malloc(size)) == NULL) if ((ptr = malloc(size)) == NULL)
fatal("xmalloc failed"); fatal("xmalloc failed");
return (ptr); return (ptr);
} }
void * void *
@ -74,13 +74,13 @@ xrealloc(void *oldptr, size_t nmemb, size_t size)
void *newptr; void *newptr;
if (newsize == 0) if (newsize == 0)
fatalx("zero size"); fatalx("zero size");
if (SIZE_MAX / nmemb < size) if (SIZE_MAX / nmemb < size)
fatalx("nmemb * size > SIZE_MAX"); fatalx("nmemb * size > SIZE_MAX");
if ((newptr = realloc(oldptr, newsize)) == NULL) if ((newptr = realloc(oldptr, newsize)) == NULL)
fatal("xrealloc failed"); fatal("xrealloc failed");
return (newptr); return (newptr);
} }
void void
@ -94,12 +94,12 @@ xfree(void *ptr)
int printflike2 int printflike2
xasprintf(char **ret, const char *fmt, ...) xasprintf(char **ret, const char *fmt, ...)
{ {
va_list ap; va_list ap;
int i; int i;
va_start(ap, fmt); va_start(ap, fmt);
i = xvasprintf(ret, fmt, ap); i = xvasprintf(ret, fmt, ap);
va_end(ap); va_end(ap);
return (i); return (i);
} }
@ -110,21 +110,21 @@ xvasprintf(char **ret, const char *fmt, va_list ap)
int i; int i;
i = vasprintf(ret, fmt, ap); i = vasprintf(ret, fmt, ap);
if (i < 0 || *ret == NULL) if (i < 0 || *ret == NULL)
fatal("xvasprintf failed"); fatal("xvasprintf failed");
return (i); return (i);
} }
int printflike3 int printflike3
xsnprintf(char *buf, size_t len, const char *fmt, ...) xsnprintf(char *buf, size_t len, const char *fmt, ...)
{ {
va_list ap; va_list ap;
int i; int i;
va_start(ap, fmt); va_start(ap, fmt);
i = xvsnprintf(buf, len, fmt, ap); i = xvsnprintf(buf, len, fmt, ap);
va_end(ap); va_end(ap);
return (i); return (i);
} }
@ -138,8 +138,8 @@ xvsnprintf(char *buf, size_t len, const char *fmt, va_list ap)
fatalx("len > INT_MAX"); fatalx("len > INT_MAX");
i = vsnprintf(buf, len, fmt, ap); i = vsnprintf(buf, len, fmt, ap);
if (i < 0) if (i < 0)
fatal("vsnprintf failed"); fatal("vsnprintf failed");
return (i); return (i);
} }