Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2023-06-17 23:41:44 +0300
committerJunio C Hamano <gitster@pobox.com>2023-06-18 22:55:30 +0300
commit44ccb337f10a08bb265b911f86deaf5f3347d967 (patch)
tree07762d77de4581021436c997e0f8099219f043b0 /builtin/branch.c
parent3c3d0c4242d834c49d77da321425819c175df61c (diff)
strbuf: factor out strbuf_expand_step()
Extract the part of strbuf_expand that finds the next placeholder into a new function. It allows to build parsers without callback functions and the overhead imposed by them. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/branch.c')
-rw-r--r--builtin/branch.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/builtin/branch.c b/builtin/branch.c
index e6c2655af6..7c20e049a2 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -366,17 +366,8 @@ static const char *quote_literal_for_format(const char *s)
static struct strbuf buf = STRBUF_INIT;
strbuf_reset(&buf);
- while (*s) {
- const char *ep = strchrnul(s, '%');
- if (s < ep)
- strbuf_add(&buf, s, ep - s);
- if (*ep == '%') {
- strbuf_addstr(&buf, "%%");
- s = ep + 1;
- } else {
- s = ep;
- }
- }
+ while (strbuf_expand_step(&buf, &s))
+ strbuf_addstr(&buf, "%%");
return buf.buf;
}