From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Subject: [PATCH 5/5] strbuf: simplify strbuf_expand_literal_cb()
Date: Sat, 17 Jun 2023 22:44:00 +0200 [thread overview]
Message-ID: <ded69969-158d-b05f-fdd4-91b26e9b502b@web.de> (raw)
In-Reply-To: <767baa64-20a6-daf2-d34b-d81f72363749@web.de>
Now that strbuf_expand_literal_cb() is no longer used as a callback,
drop its "_cb" name suffix and unused context parameter.
Signed-off-by: René Scharfe <l.s.r@web.de>
---
builtin/ls-files.c | 2 +-
builtin/ls-tree.c | 2 +-
pretty.c | 4 ++--
strbuf.c | 4 +---
strbuf.h | 6 ++----
5 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 03bf5771b4..0b00bd5d0f 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -274,7 +274,7 @@ static void show_ce_fmt(struct repository *repo, const struct cache_entry *ce,
if (skip_prefix(format, "%", &format))
strbuf_addch(&sb, '%');
- else if ((len = strbuf_expand_literal_cb(&sb, format, NULL)))
+ else if ((len = strbuf_expand_literal(&sb, format)))
format += len;
else if (*format != '(')
die(_("bad ls-files format: element '%s' "
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index 8460d20257..a90f3c81a0 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -108,7 +108,7 @@ static int show_tree_fmt(const struct object_id *oid, struct strbuf *base,
if (skip_prefix(format, "%", &format))
strbuf_addch(&sb, '%');
- else if ((len = strbuf_expand_literal_cb(&sb, format, NULL)))
+ else if ((len = strbuf_expand_literal(&sb, format)))
format += len;
else if (*format != '(')
die(_("bad ls-tree format: element '%s' "
diff --git a/pretty.c b/pretty.c
index cffbf32987..4c08f9856b 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1262,7 +1262,7 @@ static struct strbuf *expand_separator(struct strbuf *sb,
if (skip_prefix(format, "%", &format))
strbuf_addch(sb, '%');
- else if ((len = strbuf_expand_literal_cb(sb, format, NULL)))
+ else if ((len = strbuf_expand_literal(sb, format)))
format += len;
else
strbuf_addch(sb, '%');
@@ -1395,7 +1395,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
char **slot;
/* these are independent of the commit */
- res = strbuf_expand_literal_cb(sb, placeholder, NULL);
+ res = strbuf_expand_literal(sb, placeholder);
if (res)
return res;
diff --git a/strbuf.c b/strbuf.c
index c3d1cee616..55a3cfa5cf 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -427,9 +427,7 @@ int strbuf_expand_step(struct strbuf *sb, const char **formatp)
return 1;
}
-size_t strbuf_expand_literal_cb(struct strbuf *sb,
- const char *placeholder,
- void *context UNUSED)
+size_t strbuf_expand_literal(struct strbuf *sb, const char *placeholder)
{
int ch;
diff --git a/strbuf.h b/strbuf.h
index 95e50e243e..b1eab015f0 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -320,11 +320,9 @@ const char *strbuf_join_argv(struct strbuf *buf, int argc,
/**
* Used with `strbuf_expand_step` to expand the literals %n and %x
* followed by two hexadecimal digits. Returns the number of recognized
- * characters. The context argument is ignored.
+ * characters.
*/
-size_t strbuf_expand_literal_cb(struct strbuf *sb,
- const char *placeholder,
- void *context);
+size_t strbuf_expand_literal(struct strbuf *sb, const char *placeholder);
/**
* If the string pointed to by `formatp` contains a percent sign ("%"),
--
2.41.0
next prev parent reply other threads:[~2023-06-17 20:44 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-17 20:37 [PATCH 0/5] replace strbuf_expand() René Scharfe
2023-06-17 20:40 ` [PATCH 1/5] pretty: factor out expand_separator() René Scharfe
2023-06-17 20:41 ` [PATCH 2/5] strbuf: factor out strbuf_expand_step() René Scharfe
2023-06-19 16:10 ` Taylor Blau
2023-06-20 16:25 ` René Scharfe
2023-06-21 12:26 ` Taylor Blau
2023-06-27 8:26 ` Jeff King
2023-06-27 16:21 ` René Scharfe
2023-06-17 20:42 ` [PATCH 3/5] replace strbuf_expand_dict_cb() with strbuf_expand_step() René Scharfe
2023-06-27 8:29 ` Jeff King
2023-06-27 8:35 ` Jeff King
2023-06-27 16:24 ` René Scharfe
2023-06-17 20:43 ` [PATCH 4/5] replace strbuf_expand() " René Scharfe
2023-06-27 8:54 ` Jeff King
2023-06-27 16:31 ` René Scharfe
2023-06-27 20:19 ` Jeff King
2023-06-17 20:44 ` René Scharfe [this message]
2023-06-27 8:57 ` [PATCH 5/5] strbuf: simplify strbuf_expand_literal_cb() Jeff King
2023-06-27 16:32 ` René Scharfe
2023-06-27 20:21 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ded69969-158d-b05f-fdd4-91b26e9b502b@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).