strbuf: simplify strbuf_expand_literal_cb()

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jun 17, 2023 at 22:44 UTC 4416b86c6b34dad64b556bb1eb6711d5e6595a48
5 files changed +7 -11
builtin/ls-files.c
+1 -1
@@ -274,7 +274,7 @@ static void show_ce_fmt(struct repository *repo, const struct cache_entry *ce,
274
275 if (skip_prefix(format, "%", &format))
276 strbuf_addch(&sb, '%');
277 - else if ((len = strbuf_expand_literal_cb(&sb, format, NULL)))
277 + else if ((len = strbuf_expand_literal(&sb, format)))
278 format += len;
279 else if (*format != '(')
280 die(_("bad ls-files format: element '%s' "
builtin/ls-tree.c
+1 -1
@@ -108,7 +108,7 @@ static int show_tree_fmt(const struct object_id *oid, struct strbuf *base,
108
109 if (skip_prefix(format, "%", &format))
110 strbuf_addch(&sb, '%');
111 - else if ((len = strbuf_expand_literal_cb(&sb, format, NULL)))
111 + else if ((len = strbuf_expand_literal(&sb, format)))
112 format += len;
113 else if (*format != '(')
114 die(_("bad ls-tree format: element '%s' "
pretty.c
+2 -2
@@ -1262,7 +1262,7 @@ static struct strbuf *expand_separator(struct strbuf *sb,
1262
1263 if (skip_prefix(format, "%", &format))
1264 strbuf_addch(sb, '%');
1265 - else if ((len = strbuf_expand_literal_cb(sb, format, NULL)))
1265 + else if ((len = strbuf_expand_literal(sb, format)))
1266 format += len;
1267 else
1268 strbuf_addch(sb, '%');
@@ -1395,7 +1395,7 @@ static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
1395 char **slot;
1396
1397 /* these are independent of the commit */
1398 - res = strbuf_expand_literal_cb(sb, placeholder, NULL);
1398 + res = strbuf_expand_literal(sb, placeholder);
1399 if (res)
1400 return res;
1401
strbuf.c
+1 -3
@@ -427,9 +427,7 @@ int strbuf_expand_step(struct strbuf *sb, const char **formatp)
427 return 1;
428 }
429
430 -size_t strbuf_expand_literal_cb(struct strbuf *sb,
431 - const char *placeholder,
432 - void *context UNUSED)
430 +size_t strbuf_expand_literal(struct strbuf *sb, const char *placeholder)
431 {
432 int ch;
433
strbuf.h
+2 -4
@@ -320,11 +320,9 @@ const char *strbuf_join_argv(struct strbuf *buf, int argc,
320 /**
321 * Used with `strbuf_expand_step` to expand the literals %n and %x
322 * followed by two hexadecimal digits. Returns the number of recognized
323 - * characters. The context argument is ignored.
323 + * characters.
324 */
325 -size_t strbuf_expand_literal_cb(struct strbuf *sb,
326 - const char *placeholder,
327 - void *context);
325 +size_t strbuf_expand_literal(struct strbuf *sb, const char *placeholder);
326
327 /**
328 * If the string pointed to by `formatp` contains a percent sign ("%"),