diff options
author | 2019-11-27 20:54:30 +0000 | |
---|---|---|
committer | 2019-11-27 20:54:30 +0000 | |
commit | 2490d52d8716712aeaede56e70c6b8b1df9b70af (patch) | |
tree | abe6cd2298a8db90fadeb1e9b6026a02bcc9b931 | |
parent | tweak previous: add missing name after .Fn, delete stray .Pp, (diff) | |
download | wireguard-openbsd-2490d52d8716712aeaede56e70c6b8b1df9b70af.tar.xz wireguard-openbsd-2490d52d8716712aeaede56e70c6b8b1df9b70af.zip |
REG_STARTEND is not portable, but it turns out we don't actually need
it. From Evan Green, GitHub issue 1982.
-rw-r--r-- | usr.bin/tmux/regsub.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/usr.bin/tmux/regsub.c b/usr.bin/tmux/regsub.c index 705c27613a6..e815d9c981e 100644 --- a/usr.bin/tmux/regsub.c +++ b/usr.bin/tmux/regsub.c @@ -1,4 +1,4 @@ -/* $OpenBSD: regsub.c,v 1.3 2019/11/24 18:37:23 nicm Exp $ */ +/* $OpenBSD: regsub.c,v 1.4 2019/11/27 20:54:30 nicm Exp $ */ /* * Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -77,10 +77,7 @@ regsub(const char *pattern, const char *with, const char *text, int flags) end = strlen(text); while (start <= end) { - m[0].rm_so = start; - m[0].rm_eo = end; - - if (regexec(&r, text, nitems(m), m, REG_STARTEND) != 0) { + if (regexec(&r, text + start, nitems(m), m, 0) != 0) { regsub_copy(&buf, &len, text, start, end); break; } @@ -89,22 +86,25 @@ regsub(const char *pattern, const char *with, const char *text, int flags) * Append any text not part of this match (from the end of the * last match). */ - regsub_copy(&buf, &len, text, last, m[0].rm_so); + regsub_copy(&buf, &len, text, last, m[0].rm_so + start); /* * If the last match was empty and this one isn't (it is either * later or has matched text), expand this match. If it is * empty, move on one character and try again from there. */ - if (empty || m[0].rm_so != last || m[0].rm_so != m[0].rm_eo) { - regsub_expand(&buf, &len, with, text, m, nitems(m)); - - last = m[0].rm_eo; - start = m[0].rm_eo; + if (empty || + start + m[0].rm_so != last || + m[0].rm_so != m[0].rm_eo) { + regsub_expand(&buf, &len, with, text + start, m, + nitems(m)); + + last = start + m[0].rm_eo; + start += m[0].rm_eo; empty = 0; } else { - last = m[0].rm_eo; - start = m[0].rm_eo + 1; + last = start + m[0].rm_eo; + start += m[0].rm_eo + 1; empty = 1; } |