summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2018-06-27 17:36:11 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2018-06-27 17:36:11 +0000
commit7440a7b433f83eaea2ebe86791fccdc21d809f50 (patch)
treeaa2c065a3a979a8350d5919dfa9b73a486e6a793
parent7b8f841ac6d309b1f184e16980178394a726e642 (diff)
Allow any punctuation (except :) as separator in s/x/y/, not only
/. From JINNOUCHI Yasushi in GitHub issue 1386.
-rw-r--r--usr.bin/tmux/format.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c
index c29edf6f8cf..c3bc67f2996 100644
--- a/usr.bin/tmux/format.c
+++ b/usr.bin/tmux/format.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format.c,v 1.156 2018/05/29 09:10:30 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.157 2018/06/27 17:36:10 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -19,6 +19,7 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include <ctype.h>
#include <errno.h>
#include <fnmatch.h>
#include <libgen.h>
@@ -891,7 +892,7 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
char **buf, size_t *len, size_t *off)
{
struct window_pane *wp = ft->wp;
- char *copy, *copy0, *endptr, *ptr, *found, *new;
+ char *copy, *copy0, *endptr, *ptr, *found, *new, sep;
char *value, *from = NULL, *to = NULL, *left, *right;
size_t valuelen, newlen, fromlen, tolen, used;
long limit = 0;
@@ -975,20 +976,21 @@ format_replace(struct format_tree *ft, const char *key, size_t keylen,
copy += 2;
break;
case 's':
- if (copy[1] != '/')
+ sep = copy[1];
+ if (sep == ':' || !ispunct((u_char)sep))
break;
from = copy + 2;
- for (copy = from; *copy != '\0' && *copy != '/'; copy++)
+ for (copy = from; *copy != '\0' && *copy != sep; copy++)
/* nothing */;
- if (copy[0] != '/' || copy == from) {
+ if (copy[0] != sep || copy == from) {
copy = copy0;
break;
}
copy[0] = '\0';
to = copy + 1;
- for (copy = to; *copy != '\0' && *copy != '/'; copy++)
+ for (copy = to; *copy != '\0' && *copy != sep; copy++)
/* nothing */;
- if (copy[0] != '/' || copy[1] != ':') {
+ if (copy[0] != sep || copy[1] != ':') {
copy = copy0;
break;
}