mirror of
https://github.com/tmux/tmux.git
synced 2026-10-09 11:44:23 +00:00
Merge branch 'obsd-master'
This commit is contained in:
15
regsub.c
15
regsub.c
@@ -90,6 +90,15 @@ regsub(const char *pattern, const char *with, const char *text, int flags)
|
|||||||
*/
|
*/
|
||||||
regsub_copy(&buf, &len, text, last, m[0].rm_so + start);
|
regsub_copy(&buf, &len, text, last, m[0].rm_so + start);
|
||||||
|
|
||||||
|
/* For anchored patterns, replace the first match only. */
|
||||||
|
if (*pattern == '^') {
|
||||||
|
regsub_expand(&buf, &len, with, text + start, m,
|
||||||
|
nitems(m));
|
||||||
|
last = start + m[0].rm_eo;
|
||||||
|
regsub_copy(&buf, &len, text, last, end);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the last match was empty and this one isn't (it is either
|
* 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
|
* later or has matched text), expand this match. If it is
|
||||||
@@ -109,12 +118,6 @@ regsub(const char *pattern, const char *with, const char *text, int flags)
|
|||||||
start += m[0].rm_eo + 1;
|
start += m[0].rm_eo + 1;
|
||||||
empty = 1;
|
empty = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stop now if anchored to start. */
|
|
||||||
if (*pattern == '^') {
|
|
||||||
regsub_copy(&buf, &len, text, start, end);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user