summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-11-24 18:37:24 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-11-24 18:37:24 +0000
commit642f8038aca9a3b96af20ff8226f7fcf10e46325 (patch)
tree8b2ec926ea50565d4eb4d5e61939c4259682eb8a /usr.bin/tmux
parent7729d31af8b6765ca64ccfb340cf79ad5c0f1e2f (diff)
Only substitute patterns starting with ^ once.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/regsub.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/usr.bin/tmux/regsub.c b/usr.bin/tmux/regsub.c
index cf5b917aee3..705c27613a6 100644
--- a/usr.bin/tmux/regsub.c
+++ b/usr.bin/tmux/regsub.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: regsub.c,v 1.2 2019/06/20 15:40:14 nicm Exp $ */
+/* $OpenBSD: regsub.c,v 1.3 2019/11/24 18:37:23 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -107,6 +107,12 @@ regsub(const char *pattern, const char *with, const char *text, int flags)
start = m[0].rm_eo + 1;
empty = 1;
}
+
+ /* Stop now if anchored to start. */
+ if (*pattern == '^') {
+ regsub_copy(&buf, &len, text, start, end);
+ break;
+ }
}
buf[len] = '\0';